Little checksum worker cleanups

Started by Heikki Linnakangasabout 4 hours ago2 messageshackers
Jump to latest
#1Heikki Linnakangas
heikki.linnakangas@enterprisedb.com

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

Attachments:

0001-Move-DataChecksumsWorkerResult-struct-to-the-.c-file.patchtext/x-patch; charset=UTF-8; name=0001-Move-DataChecksumsWorkerResult-struct-to-the-.c-file.patchDownload+9-13
0002-Clarify-StartDataChecksumsWorkerLauncher-function.patchtext/x-patch; charset=UTF-8; name=0002-Clarify-StartDataChecksumsWorkerLauncher-function.patchDownload+14-19
0003-Avoid-leaving-DataChecksumState-worker_pid-to-an-old.patchtext/x-patch; charset=UTF-8; name=0003-Avoid-leaving-DataChecksumState-worker_pid-to-an-old.patchDownload+2-4
0004-Minor-cleanup-around-checking-datachecksum-worker-re.patchtext/x-patch; charset=UTF-8; name=0004-Minor-cleanup-around-checking-datachecksum-worker-re.patchDownload+19-17
0005-Fix-comment-on-WaitForAllTransactionsToFinish-on-pos.patchtext/x-patch; charset=UTF-8; name=0005-Fix-comment-on-WaitForAllTransactionsToFinish-on-pos.patchDownload+3-6
0006-Distinguish-datacheckums-worker-invocations-more-rel.patchtext/x-patch; charset=UTF-8; name=0006-Distinguish-datacheckums-worker-invocations-more-rel.patchDownload+73-27
#2Daniel Gustafsson
daniel@yesql.se
In reply to: Heikki Linnakangas (#1)
Re: Little checksum worker cleanups

On 23 Jun 2026, at 22:40, Heikki Linnakangas <hlinnaka@iki.fi> wrote:

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.

Thanks! I'll have a proper look at these in the morning with fresh eyes.

--
Daniel Gustafsson