| From: | Joao Rito <joaovictor(dot)rito(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Nitin Jadhav <nitinjadhavpostgres(at)gmail(dot)com> |
| Subject: | Re: [PATCH] Check interrupts while draining received WAL |
| Date: | 2026-11-16 14:02:29 |
| Message-ID: | 20261116140229.1132-1-joaovictor.rito@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Nitin,
Thank you for the patch. I tested v1-0001 and it works for me. These
are my results.
Setup: master at 7fc2f0423320 (2026-11-16), Debian, gcc 14,
--enable-cassert --enable-tap-tests. The patch applies cleanly and
the build has no warnings.
For the reproduction I followed your description. I added a
test-only sleep of 10 ms before each XLogWalRcvWrite() call, read
from an environment variable. I queued about 124 MiB of WAL for the
standby and then acted while the receiver was still draining.
The same instrumentation is in both builds. Only the two lines of
your patch differ. Times are in milliseconds, 3 runs each:
action on the standby without patch with patch
clear primary_conninfo + reload 10812 10770 10929 33 29 40
pg_ctl stop -m fast 10435 10342 10337 104 108 105
pg_ctl promote 10554 10543 10664 117 115 114
Without the patch, the receiver exits only after it drains the
backlog, 10.3 to 10.9 s here. This delay comes from my test-only
sleep (124 MiB, 10 ms per write); it is not a measure of a real
system. With the patch it exits in 0.03 to 0.12 s.
My reload numbers match yours (0.033 s with the patch).
I also ran these recovery tests on the patched tree, without the
instrumentation: 001_stream_rep, 004_timeline_switch,
005_replay_delay and 013_crash_restart. All passed (100 tests).
On the idea: the outer loop already checks interrupts, so the same
check at the top of the inner loop looks right to me. By reading the
code, the check sits between messages, so no write is cut in half.
On exit, WalRcvDie() flushes the WAL already written, and a message
read but not yet written is dropped and sent again after restart. I
only read this; I did not test it.
A small remark. The patch has no test. I understand that a test
needs a way to slow the receiver, so I did not write one.
What I did not test:
- The full recovery suite, make check, isolation, meson, other
platforms.
- The backpatch. I used master only.
- A real slow receiver, without my sleep (real disk and sender).
- Exit while a message is already read but not written: I read the
code but did not test that the WAL is sent again.
- Any cost of the check on the hot path with a high WAL rate.
- Slots or recovery_min_apply_delay combined with this change.
Thanks again.
Best regards,
Joao Rito
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tatsuya Kawata | 2026-11-16 14:16:12 | Hash aggregation shows only the last execution's stats for parallel workers |
| Previous Message | Nikhil Sontakke | 2026-11-16 13:53:31 | Re: Dropping a composite attribute causes data integrity violations |