Label Security - TO_DATA_LABEL allowing duplicate label strings
We use TO_DATA_LABEL to [auto]generate labels and get the label tag back. This function is called when users log in and pass in a predefined label string. A couple of times, we ended up with duplicate labels, more accurately 2 label rows with the same label string ('BLAH_LEVEL:BLAH_COMPARTMENT:BLAH_GROUP'), but a different label tag (the number). This causes a problem in other internal OLS calls where they get ORA-01422: exact fetch returns more than requested number of rows when they look for that specific label string and get more than 1 row back.
I think this happens when 2 users that have been assigned the same label string login at the exact same time. There is no constraint on the LBACSYS.LBAC$LAB table to prevent this. I can only think that both sessions' TO_DATA_LABEL calls start a check query to see if the string already exists, and then both do an insert at the same time. The NLABEL value assigned to each row is unique, so that passes the constraint checks and both inserts succeed.