Show loose foreign keys cleanup backlog on database diagnostics page
What does this MR do and why?
Adds a Loose foreign keys cleanup backlog section to
/admin/database_diagnostics, on top of the backend merged in !246222 (merged).
For each gitlab_shared connection it renders a table of the parent tables with a
pending Loose Foreign Keys cleanup backlog, showing the pending record count
(with a + when it hits the cap), the age of the oldest pending record (the
fall-behind signal), and the deferred count. A connection with no backlog renders
a success state. It mirrors the existing collation and schema checker apps: a
"Run backlog check" button triggers the worker, and results are fetched over REST
with polling.
Note: the on-demand check was originally gated by the
loose_foreign_keys_backlog_diagnosticops flag (returns503when off). Removing that flag has been split into its own MR, !250732 (merged), which can be reviewed and merged independently. Once it lands, the "Run backlog check" button works without enabling any flag. Until then, enable the flag to test this frontend locally.
Part of #606252
Screenshots or screen recordings
How to set up and validate locally
- Enable the
loose_foreign_keys_backlog_diagnosticfeature flag (or merge !250732 (merged), which removes it) and seed a backlog on themainconnection:Feature.enable(:loose_foreign_keys_backlog_diagnostic) Gitlab::Database::SharedModel.using_connection(ApplicationRecord.connection) do LooseForeignKeys::DeletedRecord.create!( fully_qualified_table_name: 'public.projects', primary_key_value: 1, created_at: 3.hours.ago ) end - Visit
/admin/database_diagnosticsand click Run backlog check in the new section.
MR acceptance checklist
- Frontend specs added (
spec/frontend/admin/database_diagnostics/**). -
locale/gitlab.potupdated for the new strings.
