| From: | Vadim Ponomarev <vbponomarev(at)gmail(dot)com> |
|---|---|
| To: | Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru> |
| Cc: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: Reduce SyncRepLock contention on the commit path |
| Date: | 2026-09-22 20:36:59 |
| Message-ID: | CANeUpr9_gec4Vmck3zY+aw8g=bfs1KvbbH_gOrisjGM1UeyA_g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Yura,
Thanks for the numbers, backing the series and for the
rebase.
Both code suggestions are great.
v3, on top of your v2, against 9e17d25e79d:
0001
- SyncRepInitWakeList() asserts the list is empty. Nothing between
filling it and draining it can throw today, so this only states
the invariant.
- Latches set front to back. Draining from the end reversed the
release order. Harmless either way; my sense of beauty insisted.
0004
- Accessors renamed SyncRepGetLSN() and SyncRepSetLSN(). The setter
asserts the lock.
- Assert(MyProc->syncRepState == SYNC_REP_NOT_WAITING) moved above the
lock-free exit, which skipped it.
- Comment on lsn[] rewritten: 64-bit atomic read is not a plain
load everywhere. Every access to lsn[] goes through the atomics API
now, including the ones under the lock.
0005 has one real problem. 'standby_1,standby_2' parses as FIRST 1,
so remote_apply waits for standby_1 alone. The test dumps both
standbys and compares them against the primary, taking no wait of its
own. The setval() over pg_sequence right before the dumps is such a
write. Put recovery_min_apply_delay = '10s' on standby_2 and it fails:
ok 10 - compare primary and standby_1 dumps
not ok 11 - compare primary and standby_2 dumps
changed to ANY 2 (standby_1, standby_2) in v3 - remote_apply covers both.
It also exercises the quorum path through SyncRepGetNthLatestSyncRecPtr(),
which 0002 moves out from under the lock
One question in 0005: it runs the whole regression schedule a second
time. Maybe would be behind PG_TEST_EXTRA?
Regards,
Vadim Ponomarev
| Attachment | Content-Type | Size |
|---|---|---|
| v3-0001-Wake-the-released-sync-rep-waiters-after-the-queu.patch | text/x-patch | 6.5 KB |
| v3-0002-Compute-the-synced-positions-before-taking-the-sy.patch | text/x-patch | 3.1 KB |
| v3-0003-Release-the-sync-rep-waiters-once-per-drained-bat.patch | text/x-patch | 16.0 KB |
| v3-0004-Let-a-committer-whose-acknowledgement-already-arr.patch | text/x-patch | 7.9 KB |
| v3-0005-Add-stream-regress-test-for-synchronous-replicati.patch | text/x-patch | 10.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Tom Lane | 2026-09-22 20:31:41 | Re: Up to 50x degradation in dblink performance when receiving notice traffic 19 vs 18 |