Incident Library

IL-0321 GitLab · 2021-01-16databasegcp

GCP snapshots on all Patroni nodes stalled GitLab.com's primary PostgreSQL disk, Patroni failed over and 5xx spiked

As a safety measure before a filesystem change (production#2648), snapshots were started on the PostgreSQL data volumes of all Patroni database servers at once. The engineer planning the change believed snapshotting through the GCP API ran in the background without affecting the running nodes, and did not know that GCP persistent disks are network-attached and use network bandwidth shared with the VM instance. The snapshot caused a large spike in IO latency on the primary's data disk, presumably by taking all the network bandwidth available to its persistent disks, and disk access stalled. With that IO latency, and a loss of network connectivity to Consul at the same moment, Patroni failed the primary over from patroni-06 to patroni-03 within about a minute, and requests across the fleet that needed the database returned errors for about four to five minutes.

The team had seen similar cases before in which snapshots led to Patroni failovers. Corrective actions were to update the Patroni and PostgreSQL runbooks with GCP snapshot best practices, add a checklist for change management reviewers and approvers, and talk with Google about IO sensitivities.

Severity
–
Scope
Some GitLab.com requests that needed database writes returned 5xx errors for about 4-5 minutes: about 0.133% of Rails requests and about 2.86% of Workhorse requests
Users affected
All active users during the incident
Region
–
Time to detect
1m
Time to resolve
4m

Symptoms

At 23:38 UTC on 2021-01-16 GitLab.com error rates spiked, and a minute later multiple alerts for service disruption arrived, two minutes after GCP disk snapshots had been started on all Patroni database nodes. Some requests that needed database writes returned 5xx errors for about four to five minutes, while page refreshes checked during the incident responded normally.

Rails logged approximately 2,000 5xx errors in a spike between about 23:38:30 and 23:42:00, out of 1,521,180 requests, an error rate of about 0.133%. Workhorse returned 13,757 errors out of 481,335 requests, about 2.86%. Over the hour from 23:00 to 00:00 UTC the incident used .78 availability points.

On the primary, patroni-06, the data disk saw excessive IO latency and the node lost network connectivity to Consul at the same time. At 23:40 Patroni invalidated the lock held by patroni-06 and began a failover, at 23:41 patroni-03 became the new primary, and at 23:42 the error rates dropped back.

The responders saw more degradation than they had expected and cancelled the snapshots in two of the three zones, but did not realise during the incident that the primary had actually failed over. They noticed the failover only later, when they moved on to the next steps of the change plan. Metrics and logs examined afterwards confirmed the link between the snapshot and the failover, although the metric data looked somewhat contradictory.

Symptom High error rate

Root cause

Trigger
During the change production#2648, at 23:36 UTC an engineer started GCP disk snapshots on all Patroni nodes at the same time, as a safety step before a change to the filesystem, believing the snapshot was a transparent background operation through the GCP API.

Detection

A flood of alerts about downstream impact; multiple service disruption alerts arrived at 23:39 UTC, a minute after the error spikes began. The incident was declared in Slack at 23:56.

Remediation

Action items

Lessons

Do not take a GCP snapshot of a running PostgreSQL leader. Technical reviewers have to review every change or addition to a change request's description before a manager or director approves it. The Datastores team should explain in detail how backups and snapshots work on the production database. No action belonging to a change should start before the change's scheduled start.

Sources

References

Related cases

Check your cluster for this

kubegap audits a Kubernetes cluster for conditions like the ones in this case, Database, Database failover manager, Cloud block storage among them, read-only, from Claude Code or Codex. Its checks cite public reports like this one.

For AI tools and scripts

The API needs no key. The MCP server offers search_incidents, get_incident, list_incidents, get_topic and vocab; both are explained on API and MCP.