| From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
|---|---|
| To: | Daniel Gustafsson <daniel(at)yesql(dot)se>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Little checksum worker cleanups |
| Date: | 2026-06-23 20:40:20 |
| Message-ID: | b283fbb9-298e-4953-9120-eefaf24fae20@iki.fi |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
I had another fresh look at datachecksum_state.c while rebasing my
"Interrupts vs signals" patch set, and spotted a few minor things that I
think should be cleaned up. See commit messages for details.
Unless I'm missing something, the last patch fixes a bug, albeit a very
theoretical one. The crux is that when the launcher exits, the worker
might be left running; launcher_exit sends it SIGTERM but it might not
exit instantly. If the launcher is restarted, and it launches a new
worker while the old one is still running, the old launcher might set
the worker's result field in shared memory, misleading the launcher to
believe that the *new* worker succeeded.
That'd race condition would be really hard to hit in practice - I didn't
even try to write a test - but it'd be nice to fix it. The patch adds a
unique ID to each worker invocation to distinguish the old and new
worker if both are running at the same time, ensuring that the old
worker doesn't mess with the new worker's state.
- Heikki
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Move-DataChecksumsWorkerResult-struct-to-the-.c-file.patch | text/x-patch | 2.2 KB |
| 0002-Clarify-StartDataChecksumsWorkerLauncher-function.patch | text/x-patch | 3.5 KB |
| 0003-Avoid-leaving-DataChecksumState-worker_pid-to-an-old.patch | text/x-patch | 2.1 KB |
| 0004-Minor-cleanup-around-checking-datachecksum-worker-re.patch | text/x-patch | 4.4 KB |
| 0005-Fix-comment-on-WaitForAllTransactionsToFinish-on-pos.patch | text/x-patch | 1.7 KB |
| 0006-Distinguish-datacheckums-worker-invocations-more-rel.patch | text/x-patch | 10.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Kirk Wolak | 2026-06-23 20:46:20 | Re: [GSoC 2026] - B-tree Index Bloat Reduction - Approach & Questions |
| Previous Message | Bharath Rupireddy | 2026-06-23 20:39:14 | Re: [PATCH] Improving index selection for logical replication apply with replica identity full |