diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /app/models/loose_foreign_keys | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'app/models/loose_foreign_keys')
-rw-r--r-- | app/models/loose_foreign_keys/modification_tracker.rb | 22 | ||||
-rw-r--r-- | app/models/loose_foreign_keys/turbo_modification_tracker.rb | 25 |
2 files changed, 40 insertions, 7 deletions
diff --git a/app/models/loose_foreign_keys/modification_tracker.rb b/app/models/loose_foreign_keys/modification_tracker.rb index 72a596d2114..eec9b8ad285 100644 --- a/app/models/loose_foreign_keys/modification_tracker.rb +++ b/app/models/loose_foreign_keys/modification_tracker.rb @@ -2,10 +2,6 @@ module LooseForeignKeys class ModificationTracker - MAX_DELETES = 100_000 - MAX_UPDATES = 50_000 - MAX_RUNTIME = 30.seconds # must be less than the scheduling frequency of the LooseForeignKeys::CleanupWorker cron worker - delegate :monotonic_time, to: :'Gitlab::Metrics::System' def initialize @@ -22,6 +18,18 @@ module LooseForeignKeys ) end + def max_runtime + 30.seconds + end + + def max_deletes + 100_000 + end + + def max_updates + 50_000 + end + def add_deletions(table, count) @delete_count_by_table[table] += count @deletes_counter.increment({ table: table }, count) @@ -33,9 +41,9 @@ module LooseForeignKeys end def over_limit? - @delete_count_by_table.values.sum >= MAX_DELETES || - @update_count_by_table.values.sum >= MAX_UPDATES || - monotonic_time - @start_time >= MAX_RUNTIME + @delete_count_by_table.values.sum >= max_deletes || + @update_count_by_table.values.sum >= max_updates || + monotonic_time - @start_time >= max_runtime end def stats diff --git a/app/models/loose_foreign_keys/turbo_modification_tracker.rb b/app/models/loose_foreign_keys/turbo_modification_tracker.rb new file mode 100644 index 00000000000..5229b17e971 --- /dev/null +++ b/app/models/loose_foreign_keys/turbo_modification_tracker.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module LooseForeignKeys + # This is a modification tracker with the additional limits that can be enabled + # for some database via an OPS Feature Flag. + + class TurboModificationTracker < ModificationTracker + extend ::Gitlab::Utils::Override + + override :max_runtime + def max_runtime + 45.seconds + end + + override :max_deletes + def max_deletes + 200_000 + end + + override :max_updates + def max_updates + 150_000 + end + end +end |