]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Distinguish datacheckums worker invocations more reliably
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 24 Jun 2026 12:07:33 +0000 (15:07 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 24 Jun 2026 12:07:33 +0000 (15:07 +0300)
commita4f02cab4b97027b397d073f6174de8581befbfd
treedb6b0656c34aea751c541e8c1f0e87a2de0f026e
parentc48e7b2c8bd09c3a81658ac2388be28b80b87142
Distinguish datacheckums worker invocations more reliably

In some corner cases, a new datachecksums worker could be launched
while an old one was still running.  If you're really unlucky, the old
worker could set the worker_result in shared memory and mislead the
launcher to think that a newer worker invocation completed
successfully, even though it failed for some reason.  That's highly
unlikely to happen in practice as it requires several race conditions
with workers and launchers starting, failing and succeeding and at the
right moments.  Nevertheless, better to tighten it up.

To distinguish different worker invocations, assign a unique
'worker_invocation' number every time a new worker is launched.  In
the worker, check that the invocation number matches before setting
the worker result.  This ensures that the result always belongs to the
latest invocation.

Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/b283fbb9-298e-4953-9120-eefaf24fae20@iki.fi
src/backend/postmaster/datachecksum_state.c