mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Initialize atomic variable waitStart in PGPROC, at postmaster startup.
Commit 46d6e5f567 added the atomic variable "waitStart" into PGPROC struct, to store the time at which wait for lock acquisition started. Previously this variable was initialized every time each backend started. Instead, this commit makes postmaster initialize it at the startup, to ensure that the variable should be initialized before any use of it. This commit also moves the code to initialize "waitStart" variable for prepare transaction, from TwoPhaseGetDummyProc() to MarkAsPreparingGuts(). Because MarkAsPreparingGuts() is more proper place to do that since it initializes other PGPROC variables. Author: Fujii Masao Reviewed-by: Atsushi Torikoshi Discussion: https://postgr.es/m/1df88660-6f08-cc6e-b7e2-f85296a2bdab@oss.nttdata.com
This commit is contained in:
parent
efbfb64241
commit
f05ed5a5cf
@ -475,6 +475,7 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
|
||||
proc->lwWaitMode = 0;
|
||||
proc->waitLock = NULL;
|
||||
proc->waitProcLock = NULL;
|
||||
pg_atomic_init_u64(&proc->waitStart, 0);
|
||||
for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
|
||||
SHMQueueInit(&(proc->myProcLocks[i]));
|
||||
/* subxid data must be filled later by GXactLoadSubxactData */
|
||||
@ -873,15 +874,8 @@ PGPROC *
|
||||
TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
|
||||
{
|
||||
GlobalTransaction gxact = TwoPhaseGetGXact(xid, lock_held);
|
||||
PGPROC *dummy = &ProcGlobal->allProcs[gxact->pgprocno];
|
||||
|
||||
/*
|
||||
* Initialize atomic variable in dummy proc so that GetLockStatusData()
|
||||
* can read it later.
|
||||
*/
|
||||
pg_atomic_init_u64(&dummy->waitStart, 0);
|
||||
|
||||
return dummy;
|
||||
return &ProcGlobal->allProcs[gxact->pgprocno];
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
@ -281,6 +281,7 @@ InitProcGlobal(void)
|
||||
*/
|
||||
pg_atomic_init_u32(&(procs[i].procArrayGroupNext), INVALID_PGPROCNO);
|
||||
pg_atomic_init_u32(&(procs[i].clogGroupNext), INVALID_PGPROCNO);
|
||||
pg_atomic_init_u64(&(procs[i].waitStart), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -402,7 +403,7 @@ InitProcess(void)
|
||||
MyProc->lwWaitMode = 0;
|
||||
MyProc->waitLock = NULL;
|
||||
MyProc->waitProcLock = NULL;
|
||||
pg_atomic_init_u64(&MyProc->waitStart, 0);
|
||||
pg_atomic_write_u64(&MyProc->waitStart, 0);
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
{
|
||||
int i;
|
||||
@ -581,7 +582,7 @@ InitAuxiliaryProcess(void)
|
||||
MyProc->lwWaitMode = 0;
|
||||
MyProc->waitLock = NULL;
|
||||
MyProc->waitProcLock = NULL;
|
||||
pg_atomic_init_u64(&MyProc->waitStart, 0);
|
||||
pg_atomic_write_u64(&MyProc->waitStart, 0);
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
{
|
||||
int i;
|
||||
|
Loading…
x
Reference in New Issue
Block a user