diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index cb6e1e3e5b..3f80c82288 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -268,6 +268,12 @@ InitProcGlobal(void) /* Initialize lockGroupMembers list. */ dlist_init(&procs[i].lockGroupMembers); + + /* + * Initialize the atomic variable, otherwise, it won't be safe to + * access it for backends that aren't currently in use. + */ + pg_atomic_init_u32(&(procs[i].procArrayGroupNext), INVALID_PGPROCNO); } /* @@ -401,7 +407,7 @@ InitProcess(void) /* Initialize fields for group XID clearing. */ MyProc->procArrayGroupMember = false; MyProc->procArrayGroupMemberXid = InvalidTransactionId; - pg_atomic_init_u32(&MyProc->procArrayGroupNext, INVALID_PGPROCNO); + Assert(pg_atomic_read_u32(&MyProc->procArrayGroupNext) == INVALID_PGPROCNO); /* Check that group locking fields are in a proper initial state. */ Assert(MyProc->lockGroupLeader == NULL);