Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-41732

XML import can cause duplicate key errors

XMLWordPrintable

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

      Example stack trace:

      org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "auditrecord_pkey"
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2182)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1911)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:338)
      	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2888)
      	at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
      	at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
      	at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
      	at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)
      	at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:128)
      	at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2465)
      	at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2419)
      	at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2288)
      	at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
      	at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:510)
      	at com.atlassian.confluence.impl.hibernate.ConfluenceHibernateTransactionManager.doCommit(ConfluenceHibernateTransactionManager.java:67)
      	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
      	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
      	at sun.reflect.GeneratedMethodAccessor79.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:302)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      	at com.sun.proxy.$Proxy92.commit(Unknown Source)
      	at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485)
      	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
      	at com.sun.proxy.$Proxy175.storeRecord(Unknown Source)
      	at com.atlassian.confluence.impl.audit.DefaultAuditManager.storeRecord(DefaultAuditManager.java:34)
      	at com.atlassian.confluence.impl.audit.listener.AbstractAuditListener.lambda$save$0(AbstractAuditListener.java:76)
      	at com.atlassian.fugue.Option.map(Option.java:272)
      	at com.atlassian.confluence.impl.audit.listener.AbstractAuditListener.save(AbstractAuditListener.java:75)
      	at com.atlassian.confluence.impl.audit.listener.ImportExportAuditListener.importFinishedEvent(ImportExportAuditListener.java:35)
      

      HibernateHiLoIdFixer#fixHiLoTable() is called after xml imports. This is being done as site import will replace any identifiers in the database, so the generator needs to be updated as well. Space and page imports in the other hand remap all identifiers to new identifiers using the generator so there is no need to reset the generator after those operations.

      The reason for why the generator resetting can fail is that it might not see latest changes in the database during import.

      The error messages caused by this bug can vary depending on the database used and depending on which entity happens to get a duplicate ID.

              onevalainen Olli Nevalainen
              onevalainen Olli Nevalainen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: