Transient test error - java.sql.SQLIntegrityConstraintViolationException
Ran into this test failure case while building locally
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.599 sec <<< FAILURE! - in io.druid.metadata.SQLMetadataSupervisorManagerTest
testInsertAndGet(io.druid.metadata.SQLMetadataSupervisorManagerTest) Time elapsed: 0.599 sec <<< ERROR!
org.skife.jdbi.v2.exceptions.CallbackFailedException: org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.SQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL160506204201978' defined on 'DRUIDTEST7CB9E3D334F949E0B23A8BE51C7EAFE8_SUPERVISORS'. [statement:"INSERT INTO druidTest7cb9e3d334f949e0b23a8be51c7eafe8_supervisors (id, spec_id, version, payload) VALUES (:id, :spec_id, :version, :payload)", located:"INSERT INTO druidTest7cb9e3d334f949e0b23a8be51c7eafe8_supervisors (id, spec_id, version, payload) VALUES (:id, :spec_id, :version, :payload)", rewritten:"INSERT INTO druidTest7cb9e3d334f949e0b23a8be51c7eafe8_supervisors (id, spec_id, version, payload) VALUES (?, ?, ?, ?)", arguments:{ positional:{}, named:{id:'test-supervisor-1_2016-05-06T20:42:01.963Z',payload:[123, 34, 116, 121, 112, 101, 34, 58, 34, 84, 101, 115, 116, 83, 117, 112, 101, 114, 118, 105, 115, 111, 114, 83, 112, 101, 99, 34, 44, 34, 105, 100, 34, 58, 34, 116, 101, 115, 116, 45, 115, 117, 112, 101, 114, 118, 105, 115, 111, 114, 45, 49, 34, 44, 34, 100, 97, 116, 97, 34, 58, 123, 34, 107, 101, 121, 49, 45, 49, 34, 58, 34, 118, 97, 108, 117, 101, 49, 45, 49, 45, 51, 34, 44, 34, 107, 101, 121, 49, 45, 50, 34, 58, 34, 118, 97, 108, 117, 101, 49, 45, 50, 45, 51, 34, 125, 125],spec_id:'test-supervisor-1',version:'2016-05-06T20:42:01.963Z'}, finder:[]}]
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexChanger.insertAndCheckDups(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexChanger.doInsert(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexChanger.insert(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexSetChanger.insert(Unknown Source)
at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(Unknown Source)
at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(Unknown Source)
at org.apache.derby.impl.sql.execute.InsertResultSet.open(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown Source)
at org.skife.jdbi.v2.SQLStatement.internalExecute(SQLStatement.java:1328)
at org.skife.jdbi.v2.Update.execute(Update.java:56)
at io.druid.metadata.SQLMetadataSupervisorManager$1.withHandle(SQLMetadataSupervisorManager.java:88)
at io.druid.metadata.SQLMetadataSupervisorManager$1.withHandle(SQLMetadataSupervisorManager.java:83)
at org.skife.jdbi.v2.DBI.withHandle(DBI.java:281)
at io.druid.metadata.SQLMetadataSupervisorManager.insert(SQLMetadataSupervisorManager.java:81)
at io.druid.metadata.SQLMetadataSupervisorManagerTest.testInsertAndGet(SQLMetadataSupervisorManagerTest.java:99)
👍 We are also getting this in our builds
18:45:11 Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.606 sec <<< FAILURE! - in io.druid.metadata.SQLMetadataSupervisorManagerTest
18:45:11 testInsertAndGet(io.druid.metadata.SQLMetadataSupervisorManagerTest) Time elapsed: 0.603 sec <<< ERROR!
18:45:11 org.skife.jdbi.v2.exceptions.CallbackFailedException: org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.SQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL160505184511998' defined on 'DRUIDTEST15FEBC9BC5E34E7288D782EA04CA87C7_SUPERVISORS'. [statement:"INSERT INTO druidTest15febc9bc5e34e7288d782ea04ca87c7_supervisors (id, spec_id, version, payload) VALUES (:id, :spec_id, :version, :payload)", located:"INSERT INTO druidTest15febc9bc5e34e7288d782ea04ca87c7_supervisors (id, spec_id, version, payload) VALUES (:id, :spec_id, :version, :payload)", rewritten:"INSERT INTO druidTest15febc9bc5e34e7288d782ea04ca87c7_supervisors (id, spec_id, version, payload) VALUES (?, ?, ?, ?)", arguments:{ positional:{}, named:{payload:[123, 34, 116, 121, 112, 101, 34, 58, 34, 84, 101, 115, 116, 83, 117, 112, 101, 114, 118, 105, 115, 111, 114, 83, 112, 101, 99, 34, 44, 34, 105, 100, 34, 58, 34, 116, 101, 115, 116, 45, 115, 117, 112, 101, 114, 118, 105, 115, 111, 114, 45, 49, 34, 44, 34, 100, 97, 116, 97, 34, 58, 123, 34, 107, 101, 121, 49, 45, 49, 34, 58, 34, 118, 97, 108, 117, 101, 49, 45, 49, 45, 51, 34, 44, 34, 107, 101, 121, 49, 45, 50, 34, 58, 34, 118, 97, 108, 117, 101, 49, 45, 50, 45, 51, 34, 125, 125],spec_id:'test-supervisor-1',id:'test-supervisor-1_2016-05-05T18:45:11.980Z',version:'2016-05-05T18:45:11.980Z'}, finder:[]}]
18:45:11 at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
18:45:11 at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
18:45:11 at org.apache.derby.impl.sql.execute.IndexChanger.insertAndCheckDups(Unknown Source)
18:45:11 at org.apache.derby.impl.sql.execute.IndexChanger.doInsert(Unknown Source)
18:45:11 at org.apache.derby.impl.sql.execute.IndexChanger.insert(Unknown Source)
18:45:11 at org.apache.derby.impl.sql.execute.IndexSetChanger.insert(Unknown Source)
18:45:11 at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(Unknown Source)
18:45:11 at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(Unknown Source)
18:45:11 at org.apache.derby.impl.sql.execute.InsertResultSet.open(Unknown Source)
18:45:11 at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
18:45:11 at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
18:45:11 at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
18:45:11 at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
18:45:11 at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown Source)
18:45:11 at org.skife.jdbi.v2.SQLStatement.internalExecute(SQLStatement.java:1328)
18:45:11 at org.skife.jdbi.v2.Update.execute(Update.java:56)
18:45:11 at io.druid.metadata.SQLMetadataSupervisorManager$1.withHandle(SQLMetadataSupervisorManager.java:98)
18:45:11 at io.druid.metadata.SQLMetadataSupervisorManager$1.withHandle(SQLMetadataSupervisorManager.java:83)
18:45:11 at org.skife.jdbi.v2.DBI.withHandle(DBI.java:281)
18:45:11 at io.druid.metadata.SQLMetadataSupervisorManager.insert(SQLMetadataSupervisorManager.java:81)
18:45:11 at io.druid.metadata.SQLMetadataSupervisorManagerTest.testInsertAndGet(SQLMetadataSupervisorManagerTest.java:99)
Will investigate.
@drcrallen @pjain1 hm, seems like your computers are too fast, slow them down :P
The supervisors table uses the current time as part of the primary key, and when the test creates two entries in quick succession they are getting the same timestamp and thus conflicting. We could put in some logic to handle this, but I don't think this scenario would ever come up outside of a test (the rules table also uses the current time in the same way and I don't think we've had any issues with this), so it might make more sense to just throw some sleeps into the test to ensure we get different timestamps unless someone feels strongly against this.
@dclim Is it possible to use a latch instead of sleeps? Sleeps can be funky in travis and cause more transient errors, although with a large enough sleep it is usually pretty good
@dclim relying on ms time has bitten us in the past. If you can add a UUID or hostname or something in there it should help eliminate the potential for two machines in the cluster to do something in the same ms (or what they think is the same ms)
@drcrallen fair enough, I don't really see any significant issues with adding a uuid to the primary key so I'll do that