Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-31116

Fix shouldBulkMoveToColdStorage unit test randomly failing

    XMLWordPrintable

    Details

    • Tags:
    • Sprint:
      nxplatform #65
    • Story Points:
      1

      Description

      We've got random (but very often) failure on ColdStorage unit tests with Postgres, it is a concurrent update:

      Caused by: java.sql.BatchUpdateException: Batch entry 6 INSERT INTO "hierarchy" ("id", "parentid", "pos", "name", "isproperty", "primarytype", "mixintypes", "ischeckedin", "baseversionid", "majorversion", "minorversion", "isversion", "isrecord", "retainuntil", "haslegalhold", "isretentionactive", "istrashed", "systemchangetoken", "changetoken") VALUES ('e5c56d86-4ad5-4e88-b3df-936cfe146dbe', '289165bd-a04c-46bd-8c6d-9c1bdc1111ed', NULL, 'anyFile.1657088023731', 'FALSE', 'File', ?, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0) was aborted: ERROR: duplicate key value violates unique constraint "hierarchy_unique_child"
        Detail: Key (parentid, name)=(289165bd-a04c-46bd-8c6d-9c1bdc1111ed, anyFile.1657088023731) already exists.  Call getNextException to see other errors in the batch.
      	at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:171)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2298)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:520)
      	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 org.tranql.connector.jdbc.StatementHandle.executeBatch(StatementHandle.java:155)
      	at org.nuxeo.ecm.core.storage.sql.jdbc.JDBCRowMapper.insertSimpleRows(JDBCRowMapper.java:535)
      	... 74 more
      Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "hierarchy_unique_child"
        Detail: Key (parentid, name)=(289165bd-a04c-46bd-8c6d-9c1bdc1111ed, anyFile.1657088023731) already exists.
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2565)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2297)
      	... 80 more
      

      from https://jenkins.napps.dev.nuxeo.com/job/nuxeo/job/release/job/10.10/job/nuxeo-coldstorage/9/testReport/junit/org.nuxeo.coldstorage.service/TestDummyColdStorageService/Unit_Tests___JUnit___pgsql___Run_pgsql_unit_tests___shouldBulkMoveToColdStorage/
      It happens precisely when we commit the transaction here https://github.com/nuxeo/nuxeo-coldstorage/blob/10.10/nuxeo-coldstorage/src/test/java/org/nuxeo/coldstorage/service/TestDummyColdStorageService.java#L103

      The test creates many docs with the same name and if the tests run fast, we can have doc having the same compound id with the name and the timestamp. Postgres has an index with a unicity constraint on this id.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: