Skip to content

datastore: Fix migration that prunes maintenance-style replication jobs

We 41ca8534 (praefect: Prune stale maintenance-style replication events, 2022-05-20), we have introduced a migration that prunes old maintenance-style replication jobs from our replication queue. That migration was a bit too naive though because it assumed that we had mostly drained the replication queue of such jobs already and that there aren't any stale locks which referenced these jobs. Naturally, the real world shows that such stale locks exist. And because these locks have a foreign-key constraint on the job without cascading deletes we fail to prune any such maintenance-style job that is referenced by a lock.

Fix this issue by deleting job locks before deleting the jobs. Also, let's handle the case where there are acquired job locks that should be unlocked because all job are removed.

Fixes #4275 (closed).

Merge request reports