| From: | Daniel Gustafsson <dgustafsson(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Improve handling of concurrent checksum requests |
| Date: | 2026-04-30 11:46:34 |
| Message-ID: | E1wIPqk-003SOf-0z@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Improve handling of concurrent checksum requests
When pg_{enable|disable}_data_checksums is called while checksums are
being enabled or disabled, the already running launcher is detected
and the new desired state is recorded. Processing will then pick up
the new state and change its operation to fulfill the new request.
If the same state is requested but with different cost values, the
new cost values will take effect on the next relation processed.
The previous coding had a complex logic of starting a new launcher
for this, which is now avoided with the shared mem structure instead
used to signal current processing.
This makes the logic more robust, and fixes a bug where the launcher
would erroneously revert back to the "off" state.
Access to the shared memory is also protected with LWLocks in all
cases. Since the shmem structure is used for signalling between
the worker and the launcher, and there can be only one of each,
there were no concurrency issues detected but it's better to stick
to proper locking protocol should this ever be updated to handle
multiple workers.
Author: Daniel Gustafsson <daniel(at)yesql(dot)se>
Reviewed-by: Tomas Vondra <tomas(at)vondra(dot)me>
Reviewed-by: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>
Reviewed-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Discussion: https://postgr.es/m/9197F930-DDEB-4CAC-82A2-16FEC715CCE8@yesql.se
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/bf25e5571b325875e0e48bac2e59a820918f2d6a
Modified Files
--------------
src/backend/access/transam/xlog.c | 33 ++++++++-
src/backend/postmaster/datachecksum_state.c | 100 ++++++++++++++++++++++------
src/include/access/xlog.h | 2 +
3 files changed, 112 insertions(+), 23 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Daniel Gustafsson | 2026-04-30 11:46:35 | pgsql: Fix data_checksum GUC show_hook |
| Previous Message | Amit Kapila | 2026-04-30 11:11:34 | pgsql: Fix double table_close of sequence_rel in copy_sequences(). |