Uploaded image for project: 'Dev - Nexus Repo'
  1. Dev - Nexus Repo
  2. NEXUS-31032

OrientDB to Postgres migration failure due to FK constraint violation on <format>_content_repository table

    Details

    • Sprint:
      NXRM Immortals Sprint 31
    • Notability:
      2
    • InvestmentLayer:
      support-escalated
    • Aha Concept:
      non-concept

      Description

      Migrating from Orient DB to Postgres can fail due to a foreign key constraint violation on a <format>_content_repository table due to an expected entry in this table not existing.

      For example, the following exception/failure was observed for Docker components/repos, where an insert into the docker_component table failed due to a foreign key constraint violation (fk_docker_component_repository) caused by a missing entry in the docker_content_repository table:

      18:08:06 [main] ERROR o.s.batch.core.step.AbstractStep - Encountered an error executing step processComponentStep in job migrationFromOrientJob
      org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [INSERT INTO docker_component (component_id, repository_id, namespace, name, kind, version, created, last_updated, attributes)
      VALUES (?, ?, ?, ?, ?, ?, ?, ?, (?::jsonb));
      ]; ERROR: insert or update on table "docker_component" violates foreign key constraint "fk_docker_component_repository"
       Detail: Key (repository_id)=(4) is not present in table "docker_content_repository".; nested exception is org.postgresql.util.PSQLException: ERROR: insert or update on table "docker_component" violates foreign key constraint "fk_docker_component_repository"
       Detail: Key (repository_id)=(4) is not present in table "docker_content_repository".
       at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:251)
       at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
       at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1443)
       at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633)
       at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:647)
       at org.springframework.jdbc.core.JdbcTemplate.batchUpdate(JdbcTemplate.java:936)
       at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.batchUpdate(NamedParameterJdbcTemplate.java:366)
       at org.springframework.batch.item.database.JdbcBatchItemWriter.write(JdbcBatchItemWriter.java:182)
       at com.sonatype.nexus.db.migrator.writer.ComponentWriter.writeByFormat(ComponentWriter.java:51)
       at com.sonatype.nexus.db.migrator.writer.ComponentWriter.write(ComponentWriter.java:45)
       at org.springframework.batch.item.support.ClassifierCompositeItemWriter.write(ClassifierCompositeItemWriter.java:69)
       at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:193)
       at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:159)
       at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:294)
       at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:217)
       at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:77)
       at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:407)
       at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:331)
       at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
       at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:273)
       at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:82)
       at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:375)
       at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
       at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:145)
       at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:258)
       at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:208)
       at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
       at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:68)
       at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:68)
       at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169)
       at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144)
       at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:137)
       at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:319)
       at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:147)
       at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
       at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:140)
       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:344)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
       at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
       at com.sun.proxy.$Proxy51.run(Unknown Source)
       at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.execute(JobLauncherCommandLineRunner.java:192)
       at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.executeLocalJobs(JobLauncherCommandLineRunner.java:166)
       at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.launchJobFromProperties(JobLauncherCommandLineRunner.java:153)
       at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.run(JobLauncherCommandLineRunner.java:148)
       at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:784)
       at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:768)
       at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
       at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
       at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
       at com.sonatype.nexus.db.migrator.MigratorApplication.main(MigratorApplication.java:76)
      
      Caused by: org.postgresql.util.PSQLException: ERROR: insert or update on table "docker_component" violates foreign key constraint "fk_docker_component_repository"
       Detail: Key (repository_id)=(4) is not present in table "docker_content_repository".
       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:521)
       at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:878)
       at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:901)
       at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1644)
       at com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:128)
       at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeBatch(HikariProxyPreparedStatement.java)
       at org.springframework.jdbc.core.JdbcTemplate.lambda$batchUpdate$2(JdbcTemplate.java:950)
       at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:617)
       ... 53 common frames omitted

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            hardeepn Hardeep Nagra
            CC:
            Danny Kitchen
            Last Updated By:
            Rich Seddon Rich Seddon
            Team:
            NXRM - IMMORTALS
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Date of First Response:

                tigCommentSecurity.panel-title