pg.ddx.io  patroni/patroni GitHub issues and pull requests  
help / color / mirror / Atom feed
[patroni/patroni] PR #3816: Make sure checkpointer enforces synchronous_standby_names
4+ messages / 2 participants
[nested] [flat]

* [patroni/patroni] PR #3816: Make sure checkpointer enforces synchronous_standby_names
@ 2026-11-19 21:59  "CyberDem0n (@CyberDem0n)" <noreply+CyberDem0n@github.com>
  0 siblings, 0 replies; 4+ messages in thread

From: CyberDem0n (@CyberDem0n) @ 2026-11-19 21:59 UTC (permalink / raw)
  To: patroni/patroni <noreply+patroni-patroni@github.com>

Backends start waiting for synchronous standbys only after the checkpointer processes the configuration reload, which a busy checkpointer may do only after the current checkpoint finishes. This matters most right after promote, where Patroni requests an immediate `CHECKPOINT`.

When `synchronous_standby_names` changes from empty to non-empty, it is now considered enforced when one of the following is true:
- the last checkpoint started after `pg_conf_load_time()` (on the current timeline);
- a backend whose query started after `pg_conf_load_time()` waits on `CheckpointDone`, meaning the checkpoint it requested has already started (PostgreSQL 12+);
- the checkpointer waits in its main loop (`CheckpointerMain`) or between writes of a spread checkpoint that is on schedule (`CheckpointWriteDelay`), observed at least `CHECKPOINTER_RELOAD_GRACE` (1s) after the reload (PostgreSQL 14+);
- the `CHECKPOINT` requested by Patroni completed. It runs in the thread pool, so the HA loop is not blocked. If it fails, it is requested again not earlier than after `loop_wait` seconds. From PostgreSQL 19 it is `CHECKPOINT (MODE SPREAD)`, which doesn't speed up a running checkpoint.

Only after that do we record the primary flush LSN that new members must reach. Other transitions don't need the checkpointer wait, because backends are already waiting for synchronous standbys.

In synchronous mode, members of `/sync` that are healthy, but not confirmed only because the verification is pending (e.g. right after Patroni restart), get a couple of seconds before they are removed from `/sync`.

**Before promote**, when the new `synchronous_standby_names` value of the standby being promoted is not empty (strict synchronous mode or quorum commit mode), Patroni waits up to `loop_wait` seconds until the checkpointer is known to enforce it, otherwise transactions committed right after promote might not be replicated. From PostgreSQL 14 this usually takes a fraction of a second if the checkpointer is idle (the requested restartpoint starts right away), or about a second if it is running a spread restartpoint on schedule. Older versions, or a busy checkpointer, require a `CHECKPOINT` (a restartpoint on the standby), although from PostgreSQL 12 it is enough to see that the restartpoint has started. The checkpointer keeps enforcing the verified value after promote, therefore the verification isn't repeated after promote. If it doesn't succeed in time, a warning is logged and the promotion is postponed: the standby keeps the leader key and retries, reusing a `CHECKPOINT` that is still running. The wait happens before promote completes the async response, so it can still be cancelled.

Extracted from #3467.

---
Stack replacing #3467, bottom to top:
1. #3814 Reset synchronous replication state on demote (independent, can be merged on its own)
2. #3815 Verify that walsenders apply synchronous_standby_names before updating /sync
3. #3816 Make sure checkpointer enforces synchronous_standby_names ← **this PR**
4. #3817 Make remaining quorum members catch up when quorum becomes stricter


^ permalink  raw  [nested|flat] 4+ messages in thread

* Re: [patroni/patroni] PR #3816: Make sure checkpointer enforces synchronous_standby_names
@ 2026-11-19 21:59  "CyberDem0n (@CyberDem0n)" <noreply+CyberDem0n@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: CyberDem0n (@CyberDem0n) @ 2026-11-19 21:59 UTC (permalink / raw)
  To: patroni/patroni <noreply+patroni-patroni@github.com>

@CyberDem0n applied label "bug".

^ permalink  raw  [nested|flat] 4+ messages in thread

* Re: [patroni/patroni] PR #3816: Make sure checkpointer enforces synchronous_standby_names
@ 2026-11-19 21:59  "CyberDem0n (@CyberDem0n)" <noreply+CyberDem0n@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: CyberDem0n (@CyberDem0n) @ 2026-11-19 21:59 UTC (permalink / raw)
  To: patroni/patroni <noreply+patroni-patroni@github.com>

@CyberDem0n requested a review.

^ permalink  raw  [nested|flat] 4+ messages in thread

* Re: [patroni/patroni] PR #3816: Make sure checkpointer enforces synchronous_standby_names
@ 2026-11-19 22:10  "codecov[bot] (bot) (@codecov[bot])" <noreply+codecov[bot]@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: codecov[bot] (bot) (@codecov[bot]) @ 2026-11-19 22:10 UTC (permalink / raw)
  To: patroni/patroni <noreply+patroni-patroni@github.com>

## [Codecov](https://app.codecov.io/gh/patroni/patroni/pull/3816?dropdown=coverage&src=pr&el=h1&utm_m...) Report
:white_check_mark: All modified and coverable lines are covered by tests.

:loudspeaker: Thoughts on this report? [Let us know!](https://github.com/codecov/feedback/issues/255)

^ permalink  raw  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2026-11-19 22:10 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 21:59 [patroni/patroni] PR #3816: Make sure checkpointer enforces synchronous_standby_names "CyberDem0n (@CyberDem0n)" <noreply+CyberDem0n@github.com>
2026-11-19 21:59 ` "CyberDem0n (@CyberDem0n)" <noreply+CyberDem0n@github.com>
2026-11-19 21:59 ` "CyberDem0n (@CyberDem0n)" <noreply+CyberDem0n@github.com>
2026-11-19 22:10 ` "codecov[bot] (bot) (@codecov[bot])" <noreply+codecov[bot]@github.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox