Skip to content

IntegrityError when cleaning up an archived worker that is used both with and without a config

  1. Create a worker.

  2. Create a worker version on that worker.

  3. Create a process.

  4. Add the worker version to the process.

  5. Create a worker configuration and assign it to the new worker run.

  6. Add the worker version again, this time without a configuration.

  7. Archive the worker.

  8. Wait 30 days, or edit cleanup.worker_delay, or edit the worker's archived date in the Django admin, so that it will be cleaned up.

  9. Run arkindex cleanup.

  10. Sentry Issue: ARKINDEX-BACKEND-28H

    UniqueViolation: duplicate key value violates unique constraint "unique_workerrun"
    DETAIL:  Key (process_id, version_id)=(767a8606-f290-4dc3-9758-1dc866463e5c, 7c90a439-f9b7-496f-8578-44cfe69f1cb8) already exists.
    
      File "django/db/backends/utils.py", line 105, in _execute
        return self.cursor.execute(sql, params)
    
    IntegrityError: duplicate key value violates unique constraint "unique_workerrun"
    DETAIL:  Key (process_id, version_id)=(767a8606-f290-4dc3-9758-1dc866463e5c, 7c90a439-f9b7-496f-8578-44cfe69f1cb8) already exists.
    
    (14 additional frame(s) were not displayed)
    ...
      File "__main__.py", line 17, in <module>
      File "__main__.py", line 13, in main
      File "arkindex/manage.py", line 23, in main
      File "arkindex/documents/management/commands/cleanup.py", line 43, in handle
      File "arkindex/documents/management/commands/cleanup.py", line 307, in cleanup_archived_workers
  11. Cry.