pgsql: Distinguish datacheckums worker invocations more reliably

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Distinguish datacheckums worker invocations more reliably
Date: 2026-06-24 12:39:39
Message-ID: E1wcMtH-0001eu-1O@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)yesql(dot)se>
Discussion: https://www.postgresql.org/message-id/b283fbb9-298e-4953-9120-eefaf24fae20@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a4f02cab4b97027b397d073f6174de8581befbfd

Modified Files
--------------
src/backend/postmaster/datachecksum_state.c | 99 +++++++++++++++++++++--------
1 file changed, 73 insertions(+), 26 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2026-06-24 13:07:25 pgsql: Remove extraneous newlines from guc_parameters.dat
Previous Message Michael Paquier 2026-06-24 07:09:20 pgsql: Fix set of typos and grammar mistakes