mirror of
https://github.com/postgres/postgres.git
synced 2025-06-22 02:52:08 +03: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:
@ -384,12 +384,14 @@ WaitForOlderSnapshots(TransactionId limitXmin, bool progress)
|
||||
|
||||
if (VirtualTransactionIdIsValid(old_snapshots[i]))
|
||||
{
|
||||
/* If requested, publish who we're going to wait for. */
|
||||
if (progress)
|
||||
{
|
||||
PGPROC *holder = BackendIdGetProc(old_snapshots[i].backendId);
|
||||
|
||||
pgstat_progress_update_param(PROGRESS_WAITFOR_CURRENT_PID,
|
||||
holder->pid);
|
||||
if (holder)
|
||||
pgstat_progress_update_param(PROGRESS_WAITFOR_CURRENT_PID,
|
||||
holder->pid);
|
||||
}
|
||||
VirtualXactLock(old_snapshots[i], true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user