Using REST API endpoint /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/labels might cause duplicated entries in bb_label table.

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Low
    • None
    • Affects Version/s: 7.6.6, 6.10.11
    • Component/s: API - REST
    • 4
    • Severity 3 - Minor
    • 2

      Issue Summary

      Using POST REST API endpoint /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/labels running many requests simultaneously might cause duplicated label names exist in bb_label table.

      Steps to Reproduce

      1. Step 1
        Run multiple POST requests simultaneously to /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/labels with the same label name but against different repositories.

      Expected Results

      • Only one entry is created in the bb_label table.
      • Multiple entries are created in the bb_label_mapping table.
      • All the repositories are labeled with the same label.

      Actual Results

      • More than one entry are created in the bb_label table.
      • Only one repository is labeled.

      The below exception is thrown in the atlassian-bitbucket.log file:

      2021-05-18 10:45:43,332 DEBUG [https-jsse-nio-8443-exec-1] bbuser @1X5NFHEx846x94752x0 1z6x10k 127.0.0.1 "POST /rest/api/latest/projects/PROJ_name/repos/repo_name/labels HTTP/1.1" c.a.s.i.r.e.ServiceExceptionMapper Mapping ServiceException to REST response 500
      com.atlassian.bitbucket.DataStoreException: A database error has occurred.
      ..
      Caused by: org.hibernate.NonUniqueResultException: query did not return a unique result: 3
      

      There is no unique constraint on the bb_label.name, which would probably prevent that issue.

      Workaround

      Currently, there is no known workaround for this behavior. A workaround will be added here when available

            Assignee:
            Unassigned
            Reporter:
            Tomasz Tokarczuk (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: