Add responsive throttling for placeholder user records reassignment
What does this MR do and why?
This adds responsive throttling to placeholder user records reassignment in order to ease pressure on prod DB tables.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- pull and check out into branch
- restart the gdk:
gdk restart
- in the gdk console ensure
:batched_migrations_health_status_autovacuum
and::batched_migrations_health_status_wal
feature flags are enabled - patch the
autovacuum_active_on_table
health status indicator to dummy a stop signal:
diff --git a/lib/gitlab/database/health_status/indicators/autovacuum_active_on_table.rb b/lib/gitlab/database/health_status/indicators/autovacuum_active_on_table.rb
index 6bf2bbf0c707..ef1838a2b445 100644
--- a/lib/gitlab/database/health_status/indicators/autovacuum_active_on_table.rb
+++ b/lib/gitlab/database/health_status/indicators/autovacuum_active_on_table.rb
@@ -10,6 +10,7 @@ def initialize(context)
end
def evaluate
+ return Signals::Stop.new(self.class, reason: "simulating stop locally")
return Signals::NotAvailable.new(self.class, reason: 'indicator disabled') unless enabled?
autovacuum_active_on = active_autovacuums_for(tables)
- open tail the importer log in a terminal window:
tail -f log/importer.log | jq
- ensure you have a valid
import_source_user
anduser
to reassign collaborations to and from - in the console follow the steps to reassign and accept reassignment:
source_user = Import::SourceUser.find(ID) # Source User
user = User.find(ID) # Reassign to this user
::Import::SourceUsers::ReassignService.new(source_user, user, current_user: User.first).execute
::Import::SourceUsers::AcceptReassignmentService.new(source_user, current_user: user, reassignment_token: source_user.reassignment_token).execute
- observe in the warning logged in the importer log:
{
"feature_category": "importers",
"severity": "WARN",
"time": "2024-11-29T12:22:28.784Z",
"correlation_id": "08950dbd3701c5c35fae8fde38fae81d",
"message": "Database unhealthy. Rescheduling reassignment",
"source_user_id": 490
}
- remove the patch on the
autovacuum_active_on_table
indicator and apply it to thewrite_ahead_log
indicator:
--git a/lib/gitlab/database/health_status/indicators/write_ahead_log.rb b/lib/gitlab/database/health_status/indicators/write_ahead_log.rb
index 253af7c9f0de..a1e6fa1aad17 100644
--- a/lib/gitlab/database/health_status/indicators/write_ahead_log.rb
+++ b/lib/gitlab/database/health_status/indicators/write_ahead_log.rb
@@ -36,6 +36,7 @@ def initialize(context)
end
def evaluate
+ return Signals::Stop.new(self.class, reason: "Simulating for test")
return Signals::NotAvailable.new(self.class, reason: 'indicator disabled') unless enabled?
unless pending_wal_count
- reassign and accept reassignment for another
import_source_user
- observe in the warning logged in the importer log:
{
"feature_category": "importers",
"severity": "WARN",
"time": "2024-11-29T12:22:28.784Z",
"correlation_id": "08950dbd3701c5c35fae8fde38fae81d",
"message": "Database unhealthy. Rescheduling reassignment",
"source_user_id": 491
}
Related to #493977
Edited by Rodrigo Tomonari