Draft: Sliding list partitioning for loose foreign keys
What does this MR do and why?
Describe in detail what your merge request does and why.
Implements the sliding list partitioning strategy from !73406 (merged) for the loose_foreign_keys_deleted_records
table.
This is the second half of #343084 (closed)
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
-
Feature.enable(:partition_pruning)
-
Change the
PARTITION_DURATION
forDeletedRecord
to something very short like1.second
-
Create a
LooseForeignKeys::DeletedRecord
on the console, note that it goes into partition1
(possibly 2 if you had existing records) -
Restart your console or run
Gitlab::Database::Partitioning::PartitionManager.new(LooseForeignKeys::DeletedRecord).sync_partitions
-
\d+ loose_foreign_keys_deleted_records
ingdk psql
and see that the new partition was added -
Mark all the deleted records for your oldest partition as processed (
LooseForeignKeys::DeletedRecord.for_partition(<id>).update_all(status: :processed)
) -
Sync partitions again with
Gitlab::Database::Partitioning::PartitionManager.new(LooseForeignKeys::DeletedRecord).sync_partitions
or a console restart -
\d+ loose_foreign_keys_deleted_records
and see that we removed the old partition Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.