Skip to content

Support multiple dbs when monitoring partitions

What does this MR do and why?

Related to #336898 (closed)

In the previous two MRs !68795 (merged) and !70435 (merged) we added multi-database support for partition management (creating new partitions and detaching old partitions) and partition removal (dropping detached partitions).

This MR continues the work by adding multi-database support for partitioning monitoring, by setting up the proper connection before reading metrics from a partitioned model.

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

  1. From a rails console, gather the partitioned table metrics:

    Gitlab::Database::Partitioning.report_metrics
  2. Also from the rails console, view the partitioned table metrics:

    Gitlab::Metrics.registry.get(:db_partitions_present).values.map { |key, value| [key[:table], value.get] }.to_h

    Should produce something like:

    {"audit_events"=>17, "web_hook_logs"=>10, "incident_management_pending_alert_escalations"=>8, "incident_management_pending_issue_escalations"=>8}
  3. From a psql console, you can verify the count of partitions matching the database:

    \d audit_events

    At the bottom of the output, something like:

    Number of partitions: 17 (Use \d+ to list them.)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Patrick Bair

Merge request reports