Uploaded image for project: 'Confluence Cloud'
  1. Confluence Cloud
  2. CONFCLOUD-5254

Duplicate labels can be created

    XMLWordPrintable

Details

    Description

      NOTE: This bug report is for Confluence Cloud. Using Confluence Server? See the corresponding bug report.

      Issue Summary

      In some cases, it's possible for two labels to be created with the same name (even though we do checks for this). It can occur when there are two parallel requests (via the web or XML-RPC), which try to add the same (non-existent) label. Since they're in separate transactions, it's not possible to see that another session is trying to create the label, so both end up in the DB.

      For example, new labels can be created via API using the add labels to content API endpoint. If users use this API endpoint multiple times and fast enough, and no label exists at the start of the execution of their script, then multiple labels will be created with the same name.

      Steps to Reproduce

      1. Have a script that calls the above end point very quickly or in parallel for multiple pieces of content and using the same label name.
      2. Run the script

      Expected Results

      One label is created and is associated with all content

      Actual Results

      Multiple labels are created with the same name. It seems to be random which content gets which duplicate, but typically one label will have the most associations.

      This can be confirmed by using the Label List macro and noting that multiple labels are listed with the same name.

      Workaround

      If duplicate labels have been created:

      1. Remove these labels from all content either manually or by utilizing the remove label from content API endpoint.
      2. Add the labels back either manually or by utilizing the add labels to content API endpoint. Since the label exists by the time these requests are received, only one label will be used this time, regardless of the speed of the API calls.

      The above process will ensure that all labels have one and only one label, rather than any duplicate label.

      To prevent this issue from happening in the future, for each new label to be created, make sure that the label exists first (either via UI or one API call), then subsequent calls will use the already created label regardless of the speed at which those calls are created.

      Possible solutions to this

      Write a periodic task that merges any duplicate labels (and the affected content)
      Isolate the sections of the current transaction in the save process, to narrow the window in which this can occur
      Add some sort of read/write filtering to the transaction so the changes can be seen before the transaction ends

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              8d92d19feb5e Jeremy Higgs
              Votes:
              9 Vote for this issue
              Watchers:
              18 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: