Reindex top bloated indexes on registry DB
Production Change
Change Summary
In https://gitlab.com/gitlab-com/gl-infra/capacity-planning/-/issues/39 we have identified that the registry DB index bloating has increased substantially. We believe most of the increase happened during Phase 2 of the registry migration (gitlab-org&5523 (closed)) during which the database was intensively inflated with data over several months.
As part of the investigation, we have created a list with details about all indexes here: https://docs.google.com/spreadsheets/d/1HVEXGyqotjXJ6bjrsxl8YUweyUA4n_zk1zXMu2jW220/edit?usp=sharing
We now want to try reindexing all the most bloated indexes once, and see if this is a one-time need, or if the problem returns in a near future, in which case we should consider an automated recurring reindexing strategy like done for the main DB.
We currently do not have the ability to ship post-deployment migrations on the registry (being tracked in gitlab-org/charts/gitlab#3926 (closed)), and the time required for reindexing (and the number of indexes) is prohibitively high for regular migrations. Therefore, this change request is to manually reindex the concerning indexes.
According to https://docs.google.com/spreadsheets/d/1HVEXGyqotjXJ6bjrsxl8YUweyUA4n_zk1zXMu2jW220/edit?usp=sharing, there are 202 indexes with 50%+ bloat. This change request targets the top 30 largest (by size) among those. Why 30? Mostly to not exceed 20 minutes of execution time for this change. We'll then see the impact of this change in the index bloat metric and consider raising more change requests for other indexes.
Change Details
- Services Impacted - ServiceContainer Registry
- Change Technician - @alexander-sosna
- Change Reviewer - @stomlinson
- Time tracking - 25 minutes
- Downtime Component - NA
Detailed steps for the change
Change Steps - steps to take to execute the change
Estimated Time to Complete (mins) - 20 minutes
-
Set label changein-progress /label ~change::in-progress -
Execute the following script on the production database: -- enable timing -- \timing -- capture index size before reindexing \di+ partitions.repository_blobs_p_33_blob_digest_idx \di+ partitions.repository_blobs_p_35_blob_digest_idx \di+ partitions.layers_p_36_digest_idx \di+ partitions.layers_p_15_digest_idx \di+ partitions.repository_blobs_p_61_blob_digest_idx \di+ partitions.repository_blobs_p_49_blob_digest_idx \di+ partitions.repository_blobs_p_53_blob_digest_idx \di+ partitions.layers_p_31_digest_idx \di+ partitions.layers_p_13_digest_idx \di+ partitions.repository_blobs_p_48_blob_digest_idx \di+ partitions.repository_blobs_p_11_blob_digest_idx \di+ partitions.repository_blobs_p_40_blob_digest_idx \di+ partitions.repository_blobs_p_39_blob_digest_idx \di+ partitions.repository_blobs_p_12_blob_digest_idx \di+ partitions.repository_blobs_p_63_blob_digest_idx \di+ partitions.repository_blobs_p_50_blob_digest_idx \di+ partitions.repository_blobs_p_14_blob_digest_idx \di+ partitions.repository_blobs_p_42_blob_digest_idx \di+ partitions.repository_blobs_p_21_blob_digest_idx \di+ partitions.repository_blobs_p_0_blob_digest_idx \di+ partitions.repository_blobs_p_58_blob_digest_idx \di+ partitions.repository_blobs_p_54_blob_digest_idx \di+ partitions.repository_blobs_p_22_blob_digest_idx \di+ partitions.repository_blobs_p_25_blob_digest_idx \di+ partitions.repository_blobs_p_19_blob_digest_idx \di+ partitions.repository_blobs_p_44_blob_digest_idx \di+ partitions.repository_blobs_p_2_blob_digest_idx \di+ partitions.repository_blobs_p_34_blob_digest_idx \di+ partitions.repository_blobs_p_10_blob_digest_idx \di+ partitions.repository_blobs_p_41_blob_digest_idx -- reindex REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_33_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_35_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.layers_p_36_digest_idx; REINDEX INDEX CONCURRENTLY partitions.layers_p_15_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_61_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_49_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_53_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.layers_p_31_digest_idx; REINDEX INDEX CONCURRENTLY partitions.layers_p_13_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_48_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_11_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_40_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_39_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_12_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_63_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_50_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_14_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_42_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_21_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_0_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_58_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_54_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_22_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_25_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_19_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_44_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_2_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_34_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_10_blob_digest_idx; REINDEX INDEX CONCURRENTLY partitions.repository_blobs_p_41_blob_digest_idx; -- capture index size after reindexing \di+ partitions.repository_blobs_p_33_blob_digest_idx \di+ partitions.repository_blobs_p_35_blob_digest_idx \di+ partitions.layers_p_36_digest_idx \di+ partitions.layers_p_15_digest_idx \di+ partitions.repository_blobs_p_61_blob_digest_idx \di+ partitions.repository_blobs_p_49_blob_digest_idx \di+ partitions.repository_blobs_p_53_blob_digest_idx \di+ partitions.layers_p_31_digest_idx \di+ partitions.layers_p_13_digest_idx \di+ partitions.repository_blobs_p_48_blob_digest_idx \di+ partitions.repository_blobs_p_11_blob_digest_idx \di+ partitions.repository_blobs_p_40_blob_digest_idx \di+ partitions.repository_blobs_p_39_blob_digest_idx \di+ partitions.repository_blobs_p_12_blob_digest_idx \di+ partitions.repository_blobs_p_63_blob_digest_idx \di+ partitions.repository_blobs_p_50_blob_digest_idx \di+ partitions.repository_blobs_p_14_blob_digest_idx \di+ partitions.repository_blobs_p_42_blob_digest_idx \di+ partitions.repository_blobs_p_21_blob_digest_idx \di+ partitions.repository_blobs_p_0_blob_digest_idx \di+ partitions.repository_blobs_p_58_blob_digest_idx \di+ partitions.repository_blobs_p_54_blob_digest_idx \di+ partitions.repository_blobs_p_22_blob_digest_idx \di+ partitions.repository_blobs_p_25_blob_digest_idx \di+ partitions.repository_blobs_p_19_blob_digest_idx \di+ partitions.repository_blobs_p_44_blob_digest_idx \di+ partitions.repository_blobs_p_2_blob_digest_idx \di+ partitions.repository_blobs_p_34_blob_digest_idx \di+ partitions.repository_blobs_p_10_blob_digest_idx \di+ partitions.repository_blobs_p_41_blob_digest_idx -
Post console output in a comment -
Set label changecomplete /label ~change::complete
Rollback
Not applicable.
Monitoring
Key metrics to observe
- Metric: Registry DB SLI Apdex
- Location: https://dashboards.gitlab.net/d/registry-main/registry-overview?orgId=1&viewPanel=3734296734
- What changes to this metric should prompt a rollback: While there are no rollback steps here, the execution of the script should be halted if a noticeable dip in the apdex is observed.
Change Reviewer checklist
-
Check if the following applies: - The scheduled day and time of execution of the change is appropriate.
- The change plan is technically accurate.
- The change plan includes estimated timing values based on previous testing.
- The change plan includes a viable rollback plan.
- The specified metrics/monitoring dashboards provide sufficient visibility for the change.
-
Check if the following applies: - The complexity of the plan is appropriate for the corresponding risk of the change. (i.e. the plan contains clear details).
- The change plan includes success measures for all steps/milestones during the execution.
- The change adequately minimizes risk within the environment/service.
- The performance implications of executing the change are well-understood and documented.
- The specified metrics/monitoring dashboards provide sufficient visibility for the change.
- If not, is it possible (or necessary) to make changes to observability platforms for added visibility?
- The change has a primary and secondary SRE with knowledge of the details available during the change window.
- The labels blocks deployments and/or blocks feature-flags are applied as necessary
Change Technician checklist
-
Check if all items below are complete: - The change plan is technically accurate.
- This Change Issue is linked to the appropriate Issue and/or Epic
- Change has been tested in staging and results noted in a comment on this issue.
- A dry-run has been conducted and results noted in a comment on this issue.
- The change execution window respects the Production Change Lock periods.
- For C1 and C2 change issues, the change event is added to the GitLab Production calendar.
- For C1 and C2 change issues, the SRE on-call has been informed prior to change being rolled out. (In #production channel, mention
@sre-oncalland this issue and await their acknowledgement.) - For C1 and C2 change issues, the SRE on-call provided approval with the eoc_approved label on the issue.
- For C1 and C2 change issues, the Infrastructure Manager provided approval with the manager_approved label on the issue.
- Release managers have been informed (If needed! Cases include DB change) prior to change being rolled out. (In #production channel, mention
@release-managersand this issue and await their acknowledgment.) - There are currently no active incidents that are severity1 or severity2
- If the change involves doing maintenance on a database host, an appropriate silence targeting the host(s) should be added for the duration of the change.