1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

Fix abort and launcher state resets in data checksums launcher

The launcher_running flag was reset to false during shutdown, which
left a small window where a new launcher could be started when the
exit handler was still running.  Fix by only updating the running
flag in shared memory in the exit handler if our local copy is true.

Also reset the aborted state if the launch_operation changes during
shutdown to allow scenarios like "start -> abort -> start" to work
even if they reach the second start before the abort is fully done.

Issues found by Noah and Robert using AI assisted review with Claude.
Backpatch to v19 where the online checksums feature was introduced.

Reported-by: Noah Misch <noah@leadboat.com>
Reported-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/E15AC050-C4B5-488D-BB2D-3C7AC9F89EA8@yesql.se
Backpatch-through: 19
This commit is contained in:
Daniel Gustafsson
2026-09-14 15:33:15 +02:00
parent 9a45131b7c
commit cffb4d8bd6

View File

@@ -1156,8 +1156,9 @@ launcher_exit(int code, Datum arg)
SetDataChecksumsOff();
LWLockAcquire(DataChecksumsWorkerLock, LW_EXCLUSIVE);
if (launcher_running)
DataChecksumState->launcher_running = false;
launcher_running = false;
DataChecksumState->launcher_running = false;
LWLockRelease(DataChecksumsWorkerLock);
}
@@ -1388,6 +1389,13 @@ done:
operation = DataChecksumState->launch_operation;
DataChecksumState->cost_delay = DataChecksumState->launch_cost_delay;
DataChecksumState->cost_limit = DataChecksumState->launch_cost_limit;
/*
* If the user started, but aborted processing, and then changed their
* mind again before we had time to exit we need to clear the abort
* flag.
*/
abort_requested = false;
LWLockRelease(DataChecksumsWorkerLock);
goto again;
}