mirror of
https://github.com/postgres/postgres.git
synced 2026-07-14 20:31:00 -04:00
Avoid leaving DataChecksumState->worker_pid to an old value
It might be left to an old value if the launcher was terminated while a worker was running. launcher_exit() sends SIGTERM to the worker, but did not clear 'worker_pid'. Clear it, to be tidy. Also clear it in ProcessDatabase() before starting a new datachecksums worker, to be sure we start from a clean slate. The codepath where WaitForBackgroundWorkerStartup() returns BGWH_STOPPED but worker_result != DATACHECKSUMSWORKER_SUCCESSFUL didn't clear it, while all other codepaths did clear or set it. Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://www.postgresql.org/message-id/b283fbb9-298e-4953-9120-eefaf24fae20@iki.fi
This commit is contained in:
parent
0edbf72f76
commit
c008b7ea10
1 changed files with 2 additions and 3 deletions
|
|
@ -817,6 +817,7 @@ ProcessDatabase(DataChecksumsWorkerDatabase *db)
|
|||
|
||||
LWLockAcquire(DataChecksumsWorkerLock, LW_EXCLUSIVE);
|
||||
DataChecksumState->success = DATACHECKSUMSWORKER_FAILED;
|
||||
DataChecksumState->worker_pid = InvalidPid;
|
||||
LWLockRelease(DataChecksumsWorkerLock);
|
||||
|
||||
memset(&bgw, 0, sizeof(bgw));
|
||||
|
|
@ -856,9 +857,6 @@ ProcessDatabase(DataChecksumsWorkerDatabase *db)
|
|||
{
|
||||
LWLockRelease(DataChecksumsWorkerLock);
|
||||
pgstat_report_activity(STATE_IDLE, NULL);
|
||||
LWLockAcquire(DataChecksumsWorkerLock, LW_EXCLUSIVE);
|
||||
DataChecksumState->worker_pid = InvalidPid;
|
||||
LWLockRelease(DataChecksumsWorkerLock);
|
||||
return DataChecksumState->success;
|
||||
}
|
||||
LWLockRelease(DataChecksumsWorkerLock);
|
||||
|
|
@ -951,6 +949,7 @@ launcher_exit(int code, Datum arg)
|
|||
ereport(LOG,
|
||||
errmsg("data checksums launcher exiting while worker is still running, signalling worker"));
|
||||
kill(DataChecksumState->worker_pid, SIGTERM);
|
||||
DataChecksumState->worker_pid = InvalidPid;
|
||||
}
|
||||
LWLockRelease(DataChecksumsWorkerLock);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue