DependencyTrack / dependency-track

Dependency-Track is an intelligent Component Analysis platform that allows organizations to identify and reduce risk in the software supply chain.
https://dependencytrack.org/
Apache License 2.0
2.66k stars 571 forks source link

Cannot insert duplicate key row in object 'dbo.REPOSITORY_META_COMPONENT' with unique index 'REPOSITORY_META_COMPONENT_COMPOUND_IDX' #901

Open bihe opened 3 years ago

bihe commented 3 years ago

Current Behavior:

When the analyzes job starts for a newly created project the docker console logs the following message.

2021-01-22T13:42:14.437683363Z 13:42:14.436 WARN [Persist] Insert of object "org.dependencytrack.model.RepositoryMetaComponent@12dc7d6" using statement "INSERT INTO REPOSITORY_META_COMPONENT (LAST_CHECK,LATEST_VERSION,"NAME",NAMESPACE,PUBLISHED,REPOSITORY_TYPE) VALUES (?,?,?,?,?,?)" failed : Cannot insert duplicate key row in object 'dbo.REPOSITORY_META_COMPONENT' with unique index 'REPOSITORY_META_COMPONENT_COMPOUND_IDX'. The duplicate key value is (NUGET, <NULL>, System.Data.SQLite.Core).
2021-01-22T13:42:14.448527788Z 13:42:14.448 WARN [General] ExecutionContext closed with active transaction, so rolling back the active transaction
2021-01-22T13:42:14.468963889Z 13:42:14.468 ERROR [LoggableUncaughtExceptionHandler] An unknown error occurred in an asynchronous event or notification thread
2021-01-22T13:42:14.469215399Z javax.jdo.JDODataStoreException: Insert of object "org.dependencytrack.model.RepositoryMetaComponent@12dc7d6" using statement "INSERT INTO REPOSITORY_META_COMPONENT (LAST_CHECK,LATEST_VERSION,"NAME",NAMESPACE,PUBLISHED,REPOSITORY_TYPE) VALUES (?,?,?,?,?,?)" failed : Cannot insert duplicate key row in object 'dbo.REPOSITORY_META_COMPONENT' with unique index 'REPOSITORY_META_COMPONENT_COMPOUND_IDX'. The duplicate key value is (NUGET, <NULL>, System.Data.SQLite.Core).
2021-01-22T13:42:14.469239300Z  at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:542)
2021-01-22T13:42:14.469249200Z  at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:717)
2021-01-22T13:42:14.469257901Z  at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:738)
2021-01-22T13:42:14.469266801Z  at alpine.persistence.AbstractAlpineQueryManager.persist(AbstractAlpineQueryManager.java:398)
2021-01-22T13:42:14.469275201Z  at org.dependencytrack.persistence.QueryManager.synchronizeRepositoryMetaComponent(QueryManager.java:2528)
2021-01-22T13:42:14.469283802Z  at org.dependencytrack.tasks.repositories.RepositoryMetaAnalyzerTask.analyze(RepositoryMetaAnalyzerTask.java:107)
2021-01-22T13:42:14.469292502Z  at org.dependencytrack.tasks.repositories.RepositoryMetaAnalyzerTask.inform(RepositoryMetaAnalyzerTask.java:52)
2021-01-22T13:42:14.469301602Z  at alpine.event.framework.BaseEventService.lambda$publish$0(BaseEventService.java:99)
2021-01-22T13:42:14.469310003Z  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2021-01-22T13:42:14.469318403Z  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2021-01-22T13:42:14.469326703Z  at java.lang.Thread.run(Thread.java:748)
2021-01-22T13:42:14.469335104Z Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert duplicate key row in object 'dbo.REPOSITORY_META_COMPONENT' with unique index 'REPOSITORY_META_COMPONENT_COMPOUND_IDX'. The duplicate key value is (NUGET, <NULL>, System.Data.SQLite.Core).
2021-01-22T13:42:14.469431908Z  at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:255)
2021-01-22T13:42:14.469451208Z  at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1614)
2021-01-22T13:42:14.469460009Z  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:578)
2021-01-22T13:42:14.469468709Z  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:508)
2021-01-22T13:42:14.469477109Z  at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7166)
2021-01-22T13:42:14.469485210Z  at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2869)
2021-01-22T13:42:14.469493810Z  at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:243)
2021-01-22T13:42:14.469502010Z  at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:218)
2021-01-22T13:42:14.469510411Z  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:461)
2021-01-22T13:42:14.469518711Z  at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
2021-01-22T13:42:14.469527111Z  at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
2021-01-22T13:42:14.469535712Z  at org.datanucleus.store.rdbms.ParamLoggingPreparedStatement.executeUpdate(ParamLoggingPreparedStatement.java:393)
2021-01-22T13:42:14.469544212Z  at org.datanucleus.store.rdbms.SQLController.executeStatementUpdate(SQLController.java:435)
2021-01-22T13:42:14.469552612Z  at org.datanucleus.store.rdbms.request.InsertRequest.execute(InsertRequest.java:479)
2021-01-22T13:42:14.469561213Z  at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertObjectInTable(RDBMSPersistenceHandler.java:162)
2021-01-22T13:42:14.469569813Z  at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertObject(RDBMSPersistenceHandler.java:138)
2021-01-22T13:42:14.469578113Z  at org.datanucleus.state.StateManagerImpl.internalMakePersistent(StateManagerImpl.java:4569)
2021-01-22T13:42:14.469586414Z  at org.datanucleus.state.StateManagerImpl.makePersistent(StateManagerImpl.java:4546)
2021-01-22T13:42:14.469594914Z  at org.datanucleus.ExecutionContextImpl.persistObjectInternal(ExecutionContextImpl.java:2026)
2021-01-22T13:42:14.469609714Z  at org.datanucleus.ExecutionContextImpl.persistObjectWork(ExecutionContextImpl.java:1869)
2021-01-22T13:42:14.469618215Z  at org.datanucleus.ExecutionContextImpl.persistObject(ExecutionContextImpl.java:1724)
2021-01-22T13:42:14.469626315Z  at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:712)
2021-01-22T13:42:14.469643716Z  ... 9 common frames omitted

Steps to Reproduce:

Expected Behavior:

Environment:

Additional Details:

stevespringett commented 3 years ago

I do not have access to Azure MSSQL, however, I've tested extensively with Microsoft SQL Server 2017 (RTM-CU18) (KB4527377) - 14.0.3257.3 (X64) and I'm not able to reproduce using the BOM provided.

Note, that Azure MSSQL is not officially supported as that database has different defaults than MSSQL does - especially with relation to read isolation. You may want to disable snapshot isolation and see if that works.

bihe commented 3 years ago

Would be good to be more specific regarding DB support MSSQL-wise (https://docs.dependencytrack.org/getting-started/database-support/). I will try a mySQL approach next (still Azure đŸ˜‰)