Fix the initialization of atomic variables introduced by the
group clearing mechanism. Commits 0e141c0fbb and baaf272ac9 introduced initialization of atomic variables in InitProcess which means that it's not safe to look at those for backends that aren't currently in use. Fix that by initializing them during postmaster startup. Reported-by: Andres Freund Author: Amit Kapila Backpatch-through: 9.6 Discussion: https://postgr.es/m/20181027104138.qmbbelopvy7cw2qv@alap3.anarazel.de
This commit is contained in:
parent
6b6c64a96d
commit
d4d9f21b64
@ -267,6 +267,13 @@ InitProcGlobal(void)
|
|||||||
|
|
||||||
/* Initialize lockGroupMembers list. */
|
/* Initialize lockGroupMembers list. */
|
||||||
dlist_init(&procs[i].lockGroupMembers);
|
dlist_init(&procs[i].lockGroupMembers);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize the atomic variables, otherwise, it won't be safe to
|
||||||
|
* access them for backends that aren't currently in use.
|
||||||
|
*/
|
||||||
|
pg_atomic_init_u32(&(procs[i].procArrayGroupNext), INVALID_PGPROCNO);
|
||||||
|
pg_atomic_init_u32(&(procs[i].clogGroupNext), INVALID_PGPROCNO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -401,7 +408,7 @@ InitProcess(void)
|
|||||||
/* Initialize fields for group XID clearing. */
|
/* Initialize fields for group XID clearing. */
|
||||||
MyProc->procArrayGroupMember = false;
|
MyProc->procArrayGroupMember = false;
|
||||||
MyProc->procArrayGroupMemberXid = InvalidTransactionId;
|
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. */
|
/* Check that group locking fields are in a proper initial state. */
|
||||||
Assert(MyProc->lockGroupLeader == NULL);
|
Assert(MyProc->lockGroupLeader == NULL);
|
||||||
@ -416,7 +423,7 @@ InitProcess(void)
|
|||||||
MyProc->clogGroupMemberXidStatus = TRANSACTION_STATUS_IN_PROGRESS;
|
MyProc->clogGroupMemberXidStatus = TRANSACTION_STATUS_IN_PROGRESS;
|
||||||
MyProc->clogGroupMemberPage = -1;
|
MyProc->clogGroupMemberPage = -1;
|
||||||
MyProc->clogGroupMemberLsn = InvalidXLogRecPtr;
|
MyProc->clogGroupMemberLsn = InvalidXLogRecPtr;
|
||||||
pg_atomic_init_u32(&MyProc->clogGroupNext, INVALID_PGPROCNO);
|
Assert(pg_atomic_read_u32(&MyProc->clogGroupNext) == INVALID_PGPROCNO);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Acquire ownership of the PGPROC's latch, so that we can use WaitLatch
|
* Acquire ownership of the PGPROC's latch, so that we can use WaitLatch
|
||||||
|
Loading…
x
Reference in New Issue
Block a user