Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-20610

Possible to create duplicate project keys with concurrent Bamboo Specs pushes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Low
    • 7.0.0
    • 6.9.0
    • Bamboo Specs
    • None

    Description

      Issue Summary

      Possible to create duplicate project keys with concurrent Bamboo Specs pushes.

      Steps to Reproduce

      1. Create two Bamboo Specs that reference the same project but create different plans
      2. Ensure the project does not already exist (so that it is created)
      3. Push both specs concurrently e.g.
        #!/bin/bash
        cd ~/Documents/bamboo-specs/bamboo-specs/ && mvn -Ppublish-specs &
        cd ~/Documents/bamboo-specs-2/bamboo-specs && mvn -Ppublish-specs &
        
      4. Attempt to browse the project in the UI at Projects >> Project

      There may be some variance in reproducibility as this is a race condition.

      Expected Results

      Only one project is created.

      Actual Results

      Two projects are created with the same key in PROJECTS table:

      project_id created_date updated_date project_key title description marked_for_deletion oid
      218759169 2019-09-04 11:58:32 2019-09-04 11:58:32 PKEY TITLE   false 3225703233104165889
      218759170 2019-09-04 11:58:32 2019-09-04 11:58:32 PKEY TITLE   false 3225703233104165890

      The below exception is thrown in the atlassian-bamboo.log and UI when viewing the project:

      org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2; nested exception is org.hibernate.NonUniqueResultException: query did not return a unique result: 2
      	at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:262)
      	at org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:386)
      	at org.springframework.orm.hibernate5.HibernateTemplate.execute(HibernateTemplate.java:335)
      	at com.atlassian.bamboo.project.ProjectHibernateDao.getProjectByKey(ProjectHibernateDao.java:123)
      	at sun.reflect.GeneratedMethodAccessor983.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
      	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
      	at com.sun.proxy.$Proxy147.getProjectByKey(Unknown Source)
      	at com.atlassian.bamboo.project.DefaultProjectManager.getProjectByKey(DefaultProjectManager.java:96)
      

      Workaround

      Introduce a minor sleep (2 - 4 seconds) between Bamboo Specs pushes.

      Attachments

        Issue Links

          Activity

            People

              mgardias Marcin Gardias
              jowen@atlassian.com Jeremy Owen
              Votes:
              4 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: