HIBERNATE_UNIQUE_KEY has multiple entries

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: High
    • 5.5
    • Affects Version/s: 5.0
    • Component/s: Infrastructure
    • None

      bamboo=> select * from HIBERNATE_UNIQUE_KEY;
      next_hi 
      ---------
          2253
          2253
          2253
          2253
          2253
          2492
          2235
          2235
      (8 rows)
      

      This is the table Hibernate uses to generate unique keys for database rows via the Hilo algorithm. It should only have one row, but in our case it had 8. This caused hibernate to generate a duplicate key, causing a DataIntegrityViolationException.

      Our specific symptom was:

      org.springframework.dao.DataIntegrityViolationException: Hibernate operation: Could not execute JDBC batch update; SQL []; Batch entry 0 insert into USER_COMMIT (REPOSITORY_CHANGESET_ID, AUTHOR_ID, COMMIT_DATE, COMMIT_REVISION, COMMIT_COMMENT_CLOB, COMMIT_ID) values ('73629697', '70516741', '2013-11-27 19:43:57.523000 -06:00:00', '17308', 'DRC-755 : added the class to the serializer
      
      -Pushyami', '73662465') was aborted.  Call getNextException to see the cause.; nested exception is java.sql.BatchUpdateException: Batch entry 0 insert into USER_COMMIT (REPOSITORY_CHANGESET_ID, AUTHOR_ID, COMMIT_DATE, COMMIT_REVISION, COMMIT_COMMENT_CLOB, COMMIT_ID) values ('73629697', '70516741', '2013-11-27 19:43:57.523000 -06:00:00', '17308', 'DRC-755 : added the class to the serializer
      
      -Pushyami', '73662465') was aborted.  Call getNextException to see the cause.
      ...
      ...
      ...
      2013-11-27 20:42:43,369 WARN [3-DelayedChangeDetectionThread:pool-6-thread-1] [JDBCExceptionReporter] SQL Error: 0, SQLState: 23505
      2013-11-27 20:42:43,369 ERROR [3-DelayedChangeDetectionThread:pool-6-thread-1] [JDBCExceptionReporter] ERROR: duplicate key value violates unique constraint "user_commit_pkey"
        Detail: Key (commit_id)=(73662465) already exists.
      

      This caused the build to error out at the beginning of the build during an SVN update.

      However, this could theoretically happen on any table update that relies on Hibernate generating unique keys.

      I've attached debug logs where the exception occurred, but it's not clear how HIBERNATE_UNIQUE_KEY got into this state.

            Assignee:
            Unassigned
            Reporter:
            TimP
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: