agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Distinguish datacheckums worker invocations more reliably
Date: Wed, 24 Jun 2026 12:39:39 +0000
Message-ID: <E1wcMtH-0001eu-1O@gemulon.postgresql.org> (raw)

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

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(-)



Message-ID: <E1wcMtH-0001eu-1O@gemulon.postgresql.org>
Permalink:  ../E1wcMtH-0001eu-1O@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wcMtH-0001eu-1O@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Distinguish datacheckums worker invocations more reliably
  In-Reply-To: <E1wcMtH-0001eu-1O@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox