[GSTG] [2024-08-22] - Upgrade PostgreSQL to v16 on Patroni-CI cluster

Production Change

Change Summary

The Patroni CI cluster currently runs on Postgres 14, an outdated Postgres engine. During the maintenance, we will upgrade a new standby cluster to Postgres 16, and update the Consul service registration to point Gitlab.com applications to the corresponding new Patroni cluster running PG 16.

  • Session 1 Database Upgrade: Thursday 2024-08-22, 0000 AM UTC (duration: 4 hours) - Perform the standby cluster upgrade to during low traffic and enable amcheck. This action is not customer-facing and has no customer impact.

  • Session 2 Service Switchover: Thursday, 2024-08-22, 0400 AM UTC (duration: 3 hours): - Perform cluster switchover, of Reader and Writer endpoints with QA tests between and after.

    • Observability period: 17 hours - During this period we'll observe queries response time for performance regressions that might require rollback to v14.
  • Session 3 Close Rollback Window: Friday, 2024-08-23, 0000 AM UTC (duration: 2 hours): - Close the change rollback window by stopping the reverse logical replication from v16 to v14. This is a point-of-no-return, once executed is not possible to rollback the cluster into the old version.

Key Benefits:

  • Up-to-date Postgresqsl engine will provide increased security and stability.
  • Performance improvements in Postgres 16 will significantly impact our ability to operate the primary database at our current scale

Downtime Requirements:

The PG 16 upgrade process will be an online process with near zero downtime for end-users, the workload should be enqueue during the swichover that should take a few seconds, but there's a risk of downtime of up to 5 mins if manual invervention is required for the Writer endpoint switchover.

However, as the process uses logical replication, we can't allow database migrations (model changes) to be executed during the period of 26 hours (rollback window) in the Staging environment, therefore we require to block deployments in Staging environment during the 26 hours period, but all automatic deployments to .com (including Production) are effectively blocked during the operational lock in GSTG, because our auto-deploy pipeline requires a successful deployment to Staging before deploying to Production.

Postgres Upgrade Rollout Team

Role Assigned To
🐺 Coordinator @daveyleach
🔪 Playbook-Runner @rhenchen.gitlab
Comms-Handler @rmar1
🏆 Quality On-Call @REGISTRY_NOT_REQUIRE
🎩 IMOC @kwanyangu @sabrams
📣 CMOC @ONLY_PRODUCTION
🚑 EOC @fshabir @igorwwwwwwwwwwwwwwwwwwww @sarahwalker
💾 Head Honcho @rmar1

Change Details

  1. Services Impacted - ServicePatroni ServicePatroniCI ServiceAPI ServiceWeb ServicePostgres Database
  2. Change Technician - @rhenchen.gitlab @daveyleach
  3. Change Reviewer - @vitabaks @bshah11 @alexander-sosna
  4. Time tracking - 7 hours
  5. Downtime Component - Near Zero Customer Downtime (Deployment need to be blocked)

Set Maintenance Mode in GitLab

If your change involves scheduled maintenance, add a step to set and unset maintenance mode per our runbooks. This will make sure SLA calculations adjust for the maintenance period.

Detailed steps for the change

We will pretend that GitLab.com would be unavailable during the execution of the CR and we'll use ops.gitlab.net for the detailed instructions. We will use the following issue: https://ops.gitlab.net/gitlab-com/gl-infra/db-migration/-/issues/68

Change Reviewer checklist

C4 C3 C2 C1:

  • 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.

C2 C1:

  • 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 change window has been agreed with Release Managers in advance of the change. If the change is planned for APAC hours, this issue has an agreed pre-change approval.
    • 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-oncall and 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 prior to any C1, C2, or blocks deployments change being rolled out. (In #production channel, mention @release-managers and 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.
Edited by Rafael Henchen