diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index 7b931f028e9..cfb0fcee440 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -2544,8 +2544,13 @@ ProcArrayInstallImportedXmin(TransactionId xmin, if (!sourcevxid) return false; - /* Get lock so source xact can't end while we're doing this */ - LWLockAcquire(ProcArrayLock, LW_SHARED); + /* + * Take the lock in exclusive mode to ensure that installing xmin is + * atomic with our check that the source transaction is still running. + * (Using shared mode risks a concurrent VACUUM whose ComputeXidHorizons() + * call fails to observe the xmin in either the source proc or our own.) + */ + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); /* * Find the PGPROC entry of the source transaction. (This could use