Skip to content

Commit d1a2fa3

Browse files
author
Amit Kapila
committed
Fix the initialization of atomic variable introduced by the
group clearing mechanism. Commit 0e141c0 introduced initialization of atomic variable in InitProcess which means that it's not safe to look at it for backends that aren't currently in use. Fix that by initializing the same during postmaster startup. Reported-by: Andres Freund Author: Amit Kapila Backpatch-through: 9.6 Discussion:https://postgr.es/m/20181027104138.qmbbelopvy7cw2qv@alap3.anarazel.de
1 parent 5574a01 commit d1a2fa3

File tree

1 file changed

+7
-1
lines changed
  • src/backend/storage/lmgr

1 file changed

+7
-1
lines changed

src/backend/storage/lmgr/proc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ InitProcGlobal(void)
266266

267267
/* Initialize lockGroupMembers list. */
268268
dlist_init(&procs[i].lockGroupMembers);
269+
270+
/*
271+
* Initialize the atomic variable, otherwise, it won't be safe to
272+
* access it for backends that aren't currently in use.
273+
*/
274+
pg_atomic_init_u32(&(procs[i].procArrayGroupNext), INVALID_PGPROCNO);
269275
}
270276

271277
/*
@@ -399,7 +405,7 @@ InitProcess(void)
399405
/* Initialize fields for group XID clearing. */
400406
MyProc->procArrayGroupMember = false;
401407
MyProc->procArrayGroupMemberXid = InvalidTransactionId;
402-
pg_atomic_init_u32(&MyProc->procArrayGroupNext, INVALID_PGPROCNO);
408+
Assert(pg_atomic_read_u32(&MyProc->procArrayGroupNext) == INVALID_PGPROCNO);
403409

404410
/* Check that group locking fields are in a proper initial state. */
405411
Assert(MyProc->lockGroupLeader == NULL);

0 commit comments

Comments
 (0)