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

Space import failing with the error message "could not execute statement"

      We don't plan to backport the fix for this bug to earlier Long Term Support versions

      The fix for this bug isn't suitable for backporting to a bug fix release for any previous LTS versions. This is often because the fix is considered too high risk to implement in an older version.

      The fix for this issue will be included in future Long Term Support versions.

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

      Summary

      Space imports to Confluence Cloud and Server are failing with the following error message displayed on the UI:

      Import failed. Check your server logs for more information. com.atlassian.confluence.importexport.ImportExportException: Unable to complete import: Error while importing backup: org.hibernate.exception.ConstraintViolationException: could not execute statement

      Environment

      • Confluence Cloud 1000.518.1

      Steps to Reproduce

      1. Create two spaces, ABC and DEF
      2. Create a Page "Parent" on space ABC
      3. Create a draft under "Parent" on space ABC but don't publish it
      4. Move "Parent" to space DEF
      5. Do a space export of space ABC, the export has both spaces ABC and DEF
      6. Attempt to import into Confluence Cloud, and it fails to import if Confluence already has DEF space

      Expected Results

      The space is imported successfully into Confluence Cloud.

      Actual Results

      The space failed with the error message mentioned above.

      com.atlassian.confluence.importexport.ImportExportException: com.atlassian.confluence.importexport.ImportExportException: Unable to complete import: Error while importing backup: org.hibernate.exception.ConstraintViolationException: could not execute statement
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEntities(BackupImporter.java:416)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEverything(BackupImporter.java:377)
      	at com.atlassian.confluence.importexport.xmlimport.FileBackupImporter.importEverything(FileBackupImporter.java:145)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter$1.doInTransactionWithoutResult(BackupImporter.java:263)
      	at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:34)
      	at com.atlassian.confluence.importexport.xmlimport.RestorePluginStateStoreTransactionCallbackDecorator.doInTransaction(RestorePluginStateStoreTransactionCallbackDecorator.java:46)
      	at com.atlassian.confluence.importexport.xmlimport.RestoreBandanaValuesTransactionCallbackDecorator.doInTransaction(RestoreBandanaValuesTransactionCallbackDecorator.java:50)
      	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.doImportInternal(BackupImporter.java:225)
      	at com.atlassian.confluence.importexport.Importer.doImport(Importer.java:75)
      	at com.atlassian.confluence.importexport.DefaultImportExportManager.performImportInternal(DefaultImportExportManager.java:96)
      	at com.atlassian.confluence.importexport.DefaultImportExportManager.doPerformImport(DefaultImportExportManager.java:87)
      	at com.atlassian.confluence.importexport.DefaultImportExportManager.performImport(DefaultImportExportManager.java:82)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	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.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
      	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
      	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
      	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.$Proxy142.performImport(Unknown Source)
      	at com.atlassian.confluence.importexport.actions.ImportLongRunningTask.runInternal(ImportLongRunningTask.java:68)
      	at com.atlassian.confluence.util.longrunning.ConfluenceAbstractLongRunningTask.run(ConfluenceAbstractLongRunningTask.java:45)
      	at com.atlassian.confluence.util.longrunning.ManagedTask.run(ManagedTask.java:52)
      	at com.atlassian.confluence.impl.util.concurrent.ConfluenceExecutors$ThreadLocalContextTaskWrapper.lambda$wrap$1(ConfluenceExecutors.java:89)
      	at com.atlassian.confluence.vcache.VCacheRequestContextOperations.lambda$doInRequestContext$0(VCacheRequestContextOperations.java:49)
      	at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContext(VCacheRequestContextManager.java:87)
      	at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContext(VCacheRequestContextManager.java:77)
      	at com.atlassian.confluence.vcache.VCacheRequestContextOperations.doInRequestContext(VCacheRequestContextOperations.java:48)
      	at com.atlassian.confluence.vcache.VCacheRequestContextOperations.lambda$withRequestContext$2(VCacheRequestContextOperations.java:65)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: com.atlassian.confluence.importexport.ImportExportException: Unable to complete import: Error while importing backup: org.hibernate.exception.ConstraintViolationException: could not execute statement
      	at com.atlassian.confluence.importexport.xmlimport.DefaultXmlImporter.doImport(DefaultXmlImporter.java:67)
      	at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEntities(BackupImporter.java:408)
      	... 39 more
      Caused by: org.xml.sax.SAXException: Error while importing backup: org.hibernate.exception.ConstraintViolationException: could not execute statement
      net.sf.hibernate.HibernateException: org.hibernate.exception.ConstraintViolationException: could not execute statement
      	at com.atlassian.confluence.importexport.xmlimport.parser.BackupParser.endElement(BackupParser.java:45)
      	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
      	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
      	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      	at com.atlassian.security.xml.RestrictedXMLReader.parse(RestrictedXMLReader.java:103)
      	at com.atlassian.confluence.importexport.xmlimport.DefaultXmlImporter.parseBackup(DefaultXmlImporter.java:89)
      	at com.atlassian.confluence.importexport.xmlimport.DefaultXmlImporter.doImport(DefaultXmlImporter.java:54)
      	... 40 more
      Caused by: net.sf.hibernate.HibernateException: org.hibernate.exception.ConstraintViolationException: could not execute statement
      	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147)
      	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
      	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162)
      	at com.atlassian.hibernate.util.SessionHelper.flushAllowNoTransaction(SessionHelper.java:83)
      	at com.atlassian.hibernate.adapter.adapters.session.SessionV2Adapter.flush(SessionV2Adapter.java:135)
      	at com.atlassian.confluence.importexport.xmlimport.HibernateImportProcessorContext.flushIfNeeded(HibernateImportProcessorContext.java:174)
      	at com.atlassian.confluence.importexport.xmlimport.HibernateImportProcessorContext.objectImported(HibernateImportProcessorContext.java:59)
      	at com.atlassian.confluence.importexport.xmlimport.DefaultImportProcessor.persist(DefaultImportProcessor.java:44)
      	at com.atlassian.confluence.importexport.xmlimport.DefaultImportProcessor.processObject(DefaultImportProcessor.java:34)
      	at com.atlassian.confluence.importexport.xmlimport.parser.BackupParser.endElement(BackupParser.java:43)
      	... 52 more
      Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
      	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:111)
      	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
      	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207)
      	at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
      	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2934)
      	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3434)
      	at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
      	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:582)
      	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:456)
      	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
      	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
      	at com.atlassian.hibernate.util.SessionHelper.flushAllowNoTransaction(SessionHelper.java:80)
      	... 58 more
      Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "uk_jp1ad5yufsih5r7lqrygakpug"
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
      	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555)
      	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
      	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:363)
      	at sun.reflect.GeneratedMethodAccessor275.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.github.gquintana.metrics.proxy.MethodInvocation.proceed(MethodInvocation.java:75)
      	at com.github.gquintana.metrics.sql.PreparedStatementProxyHandler.execute(PreparedStatementProxyHandler.java:55)
      	at com.github.gquintana.metrics.sql.AbstractStatementProxyHandler.invoke(AbstractStatementProxyHandler.java:61)
      	at com.github.gquintana.metrics.proxy.ProxyHandler.invoke(ProxyHandler.java:73)
      	at com.sun.proxy.$Proxy579.executeUpdate(Unknown Source)
      	at sun.reflect.GeneratedMethodAccessor275.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.vibur.dbcp.proxy.AbstractInvocationHandler.targetInvoke(AbstractInvocationHandler.java:153)
      	at org.vibur.dbcp.proxy.StatementInvocationHandler.processExecute(StatementInvocationHandler.java:141)
      	at org.vibur.dbcp.proxy.StatementInvocationHandler.restrictedInvoke(StatementInvocationHandler.java:83)
      	at org.vibur.dbcp.proxy.StatementInvocationHandler.restrictedInvoke(StatementInvocationHandler.java:40)
      	at org.vibur.dbcp.proxy.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)
      	at com.sun.proxy.$Proxy579.executeUpdate(Unknown Source)
      	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)
      	... 67 more
      

      Additional information and workaround

      The "could not execute statement" message is a symptom for several bugs which made database inconsistent. This ticket is about the invalid drafts issue. It was solved, but we still have several other similar issues which will need to be resolved for a comprehensive solution:

      There is a workaround which allows to fix database inconsistency for all these 3 tickets: https://confluence.atlassian.com/confkb/importing-a-space-fails-with-could-not-execute-statement-error-in-confluence-server-949242294.html

            [CONFSERVER-45278] Space import failing with the error message "could not execute statement"

            Robert Wolf added a comment - - edited

            what version will be "future LTS" version and when will be released? We are on 7.19. thank you.

            Robert Wolf added a comment - - edited what version will be "future LTS" version and when will be released? We are on 7.19. thank you.

            A fix for this issue is available in Confluence Server and Data Center 8.3.0.
            Upgrade now or check out the Release Notes to see what other issues are resolved.

            James Whitehead added a comment - A fix for this issue is available in Confluence Server and Data Center 8.3.0. Upgrade now or check out the Release Notes to see what other issues are resolved.

            Jake Lyell added a comment -

            Resolved by new backup/restore system to be shipped in 8.3

            Jake Lyell added a comment - Resolved by new backup/restore system to be shipped in 8.3

            7.12 is also facing this issue enterprise release of data center.

            Martin Poirier added a comment - 7.12 is also facing this issue enterprise release of data center.

            I too am experiencing this issue in my case it added a username and the actual intended space key, I ended up with a space key of XXXX and another one with ~username in the space table. Im migrating from 7.13.2 to the same version. This is such a gammy bug. i ended up running this sql delete space script and rebuilding the index (see links in this page to rebuilding index). But I think changing the erroneous space value to something else would equally work. but for me the file was so big that uploading it to restore folder 40gb and 2 hours of pain, easier to kill entry from space table etc.... if you have probs editing the xml as its so damn big id recommend vi.

            https://confluence.atlassian.com/confkb/after-a-failed-space-import-it-s-not-possible-to-re-import-because-of-leftover-space-data-217743668.html#Afterafailedspaceimport,it'snotpossibletore-importbecauseofleftoverspacedata-Resolution2

            nick.gleed305@official.mod.uk added a comment - - edited I too am experiencing this issue in my case it added a username and the actual intended space key, I ended up with a space key of XXXX and another one with ~username in the space table. Im migrating from 7.13.2 to the same version. This is such a gammy bug. i ended up running this sql delete space script and rebuilding the index (see links in this page to rebuilding index). But I think changing the erroneous space value to something else would equally work. but for me the file was so big that uploading it to restore folder 40gb and 2 hours of pain, easier to kill entry from space table etc.... if you have probs editing the xml as its so damn big id recommend vi. https://confluence.atlassian.com/confkb/after-a-failed-space-import-it-s-not-possible-to-re-import-because-of-leftover-space-data-217743668.html#Afterafailedspaceimport,it'snotpossibletore-importbecauseofleftoverspacedata-Resolution2

            Facing this issue, while exporting spaces to target source. And how to exactly remove invalid draft pages on the exported XML file.

             

            Manikanth Reddy added a comment - Facing this issue, while exporting spaces to target source. And how to exactly remove invalid draft pages on the exported XML file.  

            still occurs using 7.8.1
            please take a look at your values ;( https://www.atlassian.com/company/values

            Alexander Sowatsch added a comment - still occurs using 7.8.1 please take a look at your values ;( https://www.atlassian.com/company/values

            Hi yevgen.lasman1053119404,

            Yes, we have 3 bugs, you can find links to these tickets in the description of this ticket.

            Best regards,
            George

            George Lipatov added a comment - Hi yevgen.lasman1053119404 , Yes, we have 3 bugs, you can find links to these tickets in the description of this ticket. Best regards, George

            George,

            Do you have a bug tracked for the problem where space export contains more than one space?

            Yevgen Lasman added a comment - George, Do you have a bug tracked for the problem where space export contains more than one space?

            George Lipatov added a comment - - edited

            Hi krishna.ponnekanti1796769546,

            Thank you for this information. You applied SQL scripts, then exported a space, and the exported file contained more than one space, right? In this case, could you please create a support ticket, and attach the exported space there? It will allow us to investigate your issue.

            Thank you,
            George Lipatov

            George Lipatov added a comment - - edited Hi krishna.ponnekanti1796769546 , Thank you for this information. You applied SQL scripts, then exported a space, and the exported file contained more than one space, right? In this case, could you please create a support ticket, and attach the exported space there? It will allow us to investigate your issue. Thank you, George Lipatov

              9af32a41284c Jake Lyell
              eratsimiala ManuR
              Affected customers:
              29 This affects my team
              Watchers:
              64 Start watching this issue

                Created:
                Updated:
                Resolved: