mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-07 05:59:22 +02:00
Fix crash when reporting CREATE INDEX progress
A race condition can make us try to dereference a NULL pointer to the
PGPROC struct of a process that's already finished. That results in
crashes during REINDEX CONCURRENTLY and CREATE INDEX CONCURRENTLY.
This was introduced in ab0dfc961b
, so backpatch to pg12.
Reported by: Justin Pryzby
Reviewed-by: Michaël Paquier
Discussion: https://postgr.es/m/20191012004446.GT10470@telsasoft.com
This commit is contained in:
parent
a8e49ae0c3
commit
1cd5bc3ccf
@ -384,10 +384,12 @@ WaitForOlderSnapshots(TransactionId limitXmin, bool progress)
|
|||||||
|
|
||||||
if (VirtualTransactionIdIsValid(old_snapshots[i]))
|
if (VirtualTransactionIdIsValid(old_snapshots[i]))
|
||||||
{
|
{
|
||||||
|
/* If requested, publish who we're going to wait for. */
|
||||||
if (progress)
|
if (progress)
|
||||||
{
|
{
|
||||||
PGPROC *holder = BackendIdGetProc(old_snapshots[i].backendId);
|
PGPROC *holder = BackendIdGetProc(old_snapshots[i].backendId);
|
||||||
|
|
||||||
|
if (holder)
|
||||||
pgstat_progress_update_param(PROGRESS_WAITFOR_CURRENT_PID,
|
pgstat_progress_update_param(PROGRESS_WAITFOR_CURRENT_PID,
|
||||||
holder->pid);
|
holder->pid);
|
||||||
}
|
}
|
||||||
|
@ -900,14 +900,12 @@ WaitForLockersMultiple(List *locktags, LOCKMODE lockmode, bool progress)
|
|||||||
|
|
||||||
while (VirtualTransactionIdIsValid(*lockholders))
|
while (VirtualTransactionIdIsValid(*lockholders))
|
||||||
{
|
{
|
||||||
/*
|
/* If requested, publish who we're going to wait for. */
|
||||||
* If requested, publish who we're going to wait for. This is not
|
|
||||||
* 100% accurate if they're already gone, but we don't care.
|
|
||||||
*/
|
|
||||||
if (progress)
|
if (progress)
|
||||||
{
|
{
|
||||||
PGPROC *holder = BackendIdGetProc(lockholders->backendId);
|
PGPROC *holder = BackendIdGetProc(lockholders->backendId);
|
||||||
|
|
||||||
|
if (holder)
|
||||||
pgstat_progress_update_param(PROGRESS_WAITFOR_CURRENT_PID,
|
pgstat_progress_update_param(PROGRESS_WAITFOR_CURRENT_PID,
|
||||||
holder->pid);
|
holder->pid);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user