Uploaded image for project: 'Bitbucket Server'
  1. Bitbucket Server
  2. BSERV-12080

User directory synchronisation produces stacktrace

    XMLWordPrintable

    Details

      Description

      Issue Summary

      During a routine user directory synchronization (automatic) a stack trace is logged regarding a database constraint violation (SYS_PK_10133).
      Duplicate values are being inserted into cwd_directory_attribute table

      The synchronisation itself is not affected and all users and groups are property synchronized.

      Steps to Reproduce

      Cannot be reproduced.

      Expected Results

      A successful synchronization should not report errors.

      Actual Results

      The below exception(s) are thrown in the atlassian-bitbucket.log file:

       ERROR [Caesium-1-4] c.a.c.d.DbCachingDirectoryPoller Error occurred while refreshing the cache for directory [ xxxx ]. java.lang.IllegalStateException: Updating end time with no current start synchronisation time.
      

      and

      2019-09-27 13:28:19,313 WARN  [Caesium-1-1]  o.h.e.jdbc.spi.SqlExceptionHelper SQL Error: 2627, SQLState: 23000
      2019-09-27 13:28:19,313 ERROR [Caesium-1-1]  o.h.e.jdbc.spi.SqlExceptionHelper Violation of PRIMARY KEY constraint 'SYS_PK_10133'. Cannot insert duplicate key in object 'dbo.cwd_directory_attribute'. The duplicate key value is (xxxxx, com.atlassian.crowd.directory.sync.currentstartsynctime).
      2019-09-27 13:28:19,313 ERROR [Caesium-1-1]  o.h.i.ExceptionMapperStandardImpl HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute batch]
      2019-09-27 13:28:19,315 ERROR [Caesium-1-1]  c.a.c.d.DbCachingDirectoryPoller Error occurred while refreshing the cache for directory [ xxxx ].
      org.springframework.dao.DataIntegrityViolationException: could not execute batch; SQL [insert into cwd_directory_attribute (directory_id, attribute_name, attribute_value) values (?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute batch
      	at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:247)
      	at org.springframework.orm.hibernate5.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:801)
      	at org.springframework.orm.hibernate5.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:637)
      	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:746)
      	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:714)
      	at com.atlassian.crowd.manager.directory.DirectorySynchroniserImpl.synchronise(DirectorySynchroniserImpl.java:75)
      	at jdk.internal.reflect.GeneratedMethodAccessor782.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at com.atlassian.crowd.directory.DbCachingDirectoryPoller.pollChanges(DbCachingDirectoryPoller.java:45)
      	at com.atlassian.crowd.manager.directory.monitor.poller.DirectoryPollerJobRunner.runJob(DirectoryPollerJobRunner.java:92)
      	at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:134)
      	at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:106)
      	at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:90)
      	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.launchJob(CaesiumSchedulerService.java:435)
      	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeClusteredJob(CaesiumSchedulerService.java:430)
      	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeClusteredJobWithRecoveryGuard(CaesiumSchedulerService.java:454)
      	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeQueuedJob(CaesiumSchedulerService.java:382)
      	at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeJob(SchedulerQueueWorker.java:66)
      	at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeNextJob(SchedulerQueueWorker.java:60)
      	at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.run(SchedulerQueueWorker.java:35)
      	at java.base/java.lang.Thread.run(Thread.java:834)
      	... 17 frames trimmed
      Caused by: org.hibernate.exception.ConstraintViolationException: could not execute batch
      	at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
      	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
      	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
      	at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:129)
      	at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.doExecuteBatch(BatchingBatch.java:105)
      	at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.execute(AbstractBatchImpl.java:147)
      	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.executeBatch(JdbcCoordinatorImpl.java:212)
      	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:633)
      	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478)
      	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:356)
      	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
      	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1484)
      	at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:515)
      	at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3348)
      	at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2519)
      	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:473)
      	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:178)
      	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:39)
      	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:271)
      	at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:104)
      	at org.springframework.orm.hibernate5.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:625)
      	... 19 common frames omitted
      Caused by: java.sql.BatchUpdateException: Violation of PRIMARY KEY constraint 'SYS_PK_10133'. Cannot insert duplicate key in object 'dbo.cwd_directory_attribute'. The duplicate key value is (229378, com.atlassian.crowd.directory.sync.currentstartsynctime).
      	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:2065)
      	at com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:128)
      	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeBatch(HikariProxyPreparedStatement.java)
      	at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:119)
      	... 36 common frames omitted
      

      Workaround

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ckochovski@atlassian.com Christopher Kochovski
              Reporter:
              tathanassiadou Themis
              Votes:
              22 Vote for this issue
              Watchers:
              37 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Backbone Issue Sync