Uploaded image for project: 'Crowd Data Center'
  1. Crowd Data Center
  2. CWD-6172

Restarting Crowd logs a DB duplicate key error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • High
    • None
    • 5.2.0
    • Core features, DC Core
    • None

    Description

      Issue Summary

      While clustering is enabled, restarting Crowd logs an error since it tries to insert a row that already exists and is unique.

      This is reproducible on Data Center: yes

      Steps to Reproduce

      1. Verify that clustering is enabled from, crowd-home/shared/crowd.cfg.xml
      2. Restart Crowd

      Expected Results

      No errors were written on the logs.

      Actual Results

      The below exception is thrown in the atlassian-crowd.log file:

      .2023-11-17 10:06:06,825 Caesium-2-4 ERROR [engine.jdbc.spi.SqlExceptionHelper] Batch entry 0 insert into cwd_cluster_lock (lock_timestamp, node_id, lock_name) values (1700215566819, NULL, 'com.atlassian.crowd.manager.directory.monitor.DirectoryMonitorRefresherJob-lock') was aborted: ERROR: duplicate key value violates unique constraint "cwd_cluster_lock_pkey"
        Detail: Key (lock_name)=(com.atlassian.crowd.manager.directory.monitor.DirectoryMonitorRefresherJob-lock) already exists.  Call getNextException to see other errors in the batch.
      2023-11-17 10:06:06,825 Caesium-2-4 ERROR [engine.jdbc.spi.SqlExceptionHelper] ERROR: duplicate key value violates unique constraint "cwd_cluster_lock_pkey"
        Detail: Key (lock_name)=(com.atlassian.crowd.manager.directory.monitor.DirectoryMonitorRefresherJob-lock) already exists.
      

      Workaround

      When the debug log is enabled we can see that after the above error, it updates the existing entry:

      2023-11-17 10:06:06,840 Caesium-2-4 TRACE [resource.jdbc.internal.ResourceRegistryStandardImpl] Registering statement [com.mchange.v2.c3p0.impl.NewProxyPreparedStatement@bd6c7f3 [wrapping: update cwd_cluster_lock set node_id=?, lock_timestamp=? where lock_name=? and (node_id is null or node_id in (select clusterhea1_.node_id from cwd_cluster_heartbeat clusterhea1_ where clusterhea1_.hearbeat_timestamp<?) or node_id=?)]]
      2023-11-17 10:06:06,840 Caesium-2-4 TRACE [type.descriptor.sql.BasicBinder] binding parameter [1] as [VARCHAR] - [c0092599-9e79-4e5a-9c8c-41cc29468c00]
      2023-11-17 10:06:06,840 Caesium-2-4 TRACE [type.descriptor.sql.BasicBinder] binding parameter [2] as [BIGINT] - [1700215566840]
      2023-11-17 10:06:06,840 Caesium-2-4 TRACE [type.descriptor.sql.BasicBinder] binding parameter [3] as [VARCHAR] - [com.atlassian.crowd.manager.directory.monitor.DirectoryMonitorRefresherJob-lock]
      2023-11-17 10:06:06,840 Caesium-2-4 TRACE [type.descriptor.sql.BasicBinder] binding parameter [4] as [BIGINT] - [1700215266840]
      2023-11-17 10:06:06,840 Caesium-2-4 TRACE [type.descriptor.sql.BasicBinder] binding parameter [5] as [VARCHAR] - [c0092599-9e79-4e5a-9c8c-41cc29468c00]
      

      So we can ignore the error since it's able to update the entry successfully.

      Attachments

        Activity

          People

            Unassigned Unassigned
            cf398590ce2c Cihan
            Votes:
            6 Vote for this issue
            Watchers:
            12 Start watching this issue

            Dates

              Created:
              Updated: