Uploaded image for project: 'Migration Platform'
  1. Migration Platform
  2. MIG-1587

Optimistic locking failure causes attachments migration to fail

    XMLWordPrintable

Details

    • 6
    • Severity 1 - Critical
    • 12

    Description

      Issue Summary

      When trying to migrate attachments only with CCMA, optimistic locking failures are observed in the logs. This issue is seen with postgres database.

      This is reproducible on Data Center:

      Steps to Reproduce

      1. Install latest CCMA on a Confluence configured with postgres database
      2. Try to create a migration plan for attachments
      3. Some of the attachments fail with the optimistic locking failure as shown below

      Expected Results

      Attachments migration is successful.

      Actual Results

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

      2023-10-24T02:48:31.779941Z ERROR Step failed, taskName: Migrate attachments only for space <spacekey> | stepType: ATTACHMENT_UPLOAD | message: Failed to migrate space <spacekey> attachments
      [Exception Details]: org.springframework.orm.hibernate.HibernateOptimisticLockingFailureException: Object of class [com.atlassian.confluence.pages.Attachment] with identifier [267129507]: optimistic locking failed; nested exception is net.sf.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [com.atlassian.confluence.pages.Attachment#267129507] | java.util.concurrent.CompletionException: org.springframework.orm.hibernate.HibernateOptimisticLockingFailureException: Object of class [com.atlassian.confluence.pages.Attachment] with identifier [xxxxxxxxxx]: optimistic locking failed; nested exception is net.sf.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [com.atlassian.confluence.pages.Attachment#xxxxxxxxx]
      	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
      	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
      	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source)
      	at com.atlassian.migration.agent.logging.LoggingContextAwareExecutorService.lambda$execute$3(LoggingContextAwareExecutorService.java:104)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at java.base/java.lang.Thread.run(Unknown Source)
      Caused by: org.springframework.orm.hibernate.HibernateOptimisticLockingFailureException: Object of class [com.atlassian.confluence.pages.Attachment] with identifier [267129507]: optimistic locking failed; nested exception is net.sf.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [com.atlassian.confluence.pages.Attachment#267129507]
      	at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:596)
      	at org.springframework.orm.hibernate.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:610)
      	at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:521)
      	at com.atlassian.confluence.impl.hibernate.ConfluenceHibernateTransactionManager.doCommit(ConfluenceHibernateTransactionManager.java:69)
      	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743)
      	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711)
      	at jdk.internal.reflect.GeneratedMethodAccessor124.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
      	at com.sun.proxy.$Proxy82.commit(Unknown Source)
      	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:152)
      	at com.atlassian.sal.spring.component.SpringHostContextAccessor.doInTransaction(SpringHostContextAccessor.java:68)
      	at com.atlassian.confluence.spring.transaction.interceptor.ConfluenceSpringHostContextAccessor.access$001(ConfluenceSpringHostContextAccessor.java:21)
      	at com.atlassian.confluence.spring.transaction.interceptor.ConfluenceSpringHostContextAccessor.lambda$doInTransaction$3(ConfluenceSpringHostContextAccessor.java:72)
      	at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContextInternal(VCacheRequestContextManager.java:84)
      	at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContext(VCacheRequestContextManager.java:68)
      	at com.atlassian.confluence.spring.transaction.interceptor.ConfluenceSpringHostContextAccessor.doInTransaction(ConfluenceSpringHostContextAccessor.java:72)
      	at com.atlassian.sal.core.transaction.HostContextTransactionTemplate.execute(HostContextTransactionTemplate.java:18)
      	at jdk.internal.reflect.GeneratedMethodAccessor321.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
      	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
      	at com.sun.proxy.$Proxy281.execute(Unknown Source)
      	at jdk.internal.reflect.GeneratedMethodAccessor321.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:137)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
      	at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:137)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
      	at com.sun.proxy.$Proxy774.execute(Unknown Source)
      	at com.atlassian.migration.agent.service.stepexecutor.attachment.AttachmentDataProvider.getAttachmentData(AttachmentDataProvider.java:42)
      	at com.atlassian.migration.agent.service.stepexecutor.attachment.AttachmentMigrator.uploadImpl(AttachmentMigrator.java:58)
      	at com.atlassian.migration.agent.service.stepexecutor.attachment.AttachmentMigrator.lambda$upload$0(AttachmentMigrator.java:51)
      	at com.atlassian.migration.agent.logging.LoggingContextBuilder.execute(LoggingContextBuilder.java:127)
      	at com.atlassian.migration.agent.service.stepexecutor.attachment.AttachmentMigrator.upload(AttachmentMigrator.java:51)
      	at com.atlassian.migration.agent.service.stepexecutor.attachment.AttachmentMigrator.migrate(AttachmentMigrator.java:40)
      	at com.atlassian.migration.agent.service.stepexecutor.attachment.AttachmentsToMigrateConsumer.run(AttachmentsToMigrateConsumer.java:60)
      	... 5 more
      Caused by: net.sf.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [com.atlassian.confluence.pages.Attachment#267129507]
      	at org.hibernate.internal.ExceptionConverterImpl.wrapStaleStateException(ExceptionConverterImpl.java:199)
      	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:88)
      	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
      	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:164)
      	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1443)
      	at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:494)
      	at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3245)
      	at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2451)
      	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:473)
      	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:156)
      	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
      	at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:231)
      	at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
      	at com.atlassian.hibernate.adapter.adapters.TransactionV2Adapter.commit(TransactionV2Adapter.java:30)
      	at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:513)
      	... 54 more
      

      Workaround

      Attempt remigrations or migrate attachments with spaces.

      Attachments

        Issue Links

          Activity

            People

              fb0dd8c8fadd Gaurav Gupta
              kplaha Kanwar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: