diff options
author | Toon Claes <toon@gitlab.com> | 2022-02-15 18:02:38 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2022-02-15 18:02:38 +0300 |
commit | 507f55799f54ed17b3e3ef7fad57041f99492208 (patch) | |
tree | 0a50bce978a77d31ce421535ca0aa66f845b160c | |
parent | 0ff097c4d34856d80fbd2db119c3a3ee1878d60b (diff) |
datastore: Clean completed & dead replication jobs
Previous attempts [1] & [2] were made to avoid completed and dead jobs
being left over in the replication queue. But only in [3] there was made
sure no new jobs were generated.
So now no more of these stale are created, we can run a migration that
wipes all stale records from the database. This change in fact repeats
the `DELETE` query from the migration added in [2].
1. 8f8ae3025 (Replication job acknowledge removes 'completed' and 'dead'
events., 2020-08-05)
2. 2d3fc8063 (Replication job acknowledge removes 'completed' and 'dead'
events., 2020-09-03)
3. 8c4da135f (replication: Remove 'dead' stale jobs., 2021-10-20)
Changelog: performance
Issue: https://gitlab.com/gitlab-org/gitaly/-/issues/3665
-rw-r--r-- | internal/praefect/datastore/migrations/20220215160117_replication_queue_cleanup_again.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/praefect/datastore/migrations/20220215160117_replication_queue_cleanup_again.go b/internal/praefect/datastore/migrations/20220215160117_replication_queue_cleanup_again.go new file mode 100644 index 000000000..b7fa8f885 --- /dev/null +++ b/internal/praefect/datastore/migrations/20220215160117_replication_queue_cleanup_again.go @@ -0,0 +1,17 @@ +package migrations + +import migrate "github.com/rubenv/sql-migrate" + +func init() { + m := &migrate.Migration{ + Id: "20220215160117_replication_queue_cleanup_again", + Up: []string{ + `DELETE FROM replication_queue WHERE state = ANY (ARRAY['dead'::REPLICATION_JOB_STATE, 'completed'::REPLICATION_JOB_STATE])`, + }, + Down: []string{ + // there is no way to restore deleted data + }, + } + + allMigrations = append(allMigrations, m) +} |