Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Our standby received every change for five hours and applied none of them

In August we planned a two minute switchover of our main Postgres database, to patch the primary's kernel. The standby was promoted at seven in the morning and took forty one minutes to accept writes. For forty one minutes every service that writes anything was down. The standby is a streaming replica that also serves reports for our finance team, and reports on a replica have a known problem.…

Our standby Postgres database remained active for five hours during a planned two-minute switchover in August, but made no changes. The primary kernel was being patched, causing our standby to take forty-one minutes to start accepting writes. During this time, every service that wrote data was unavailable, including the finance team's report generation.

Streaming replicas like our standby can cause issues when the primary vacuums away rows that the standby is still processing. To prevent conflicts, Postgres uses max_standby_streaming_delay, which defaults to thirty seconds before canceling queries. Finance had previously set this value to minus one, causing the standby to wait indefinitely.

Before the switchover, finance ran month-end reports, and the standby fell behind by five hours in replay. It kept receiving and writing WAL data to disk but did not apply it. Promotion, which involves replaying all received WAL, took five hours. Our runbook checked replication before the switchover, comparing the primary's position with the standby's flushed position.

However, it was the replay position that mattered, as it determined whether the standby could promote. Finance now have their own replica with relaxed delays and no role in failover. The standby that can be promoted has returned to a thirty-second delay. Our lag alert measures replay, firing at one minute if it exceeds one minute.

The switchover script refuses to start unless replay is within a few seconds. We run monthly switchover tests in staging, timing from promotion to the first successful write. A replica that has received data and a replica that can take over are different things. Our checks measured the first, while failover depended on the second.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

More from Thursday, 15 October 2026 →