Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f05ed5a

Browse filesBrowse files
committed
Initialize atomic variable waitStart in PGPROC, at postmaster startup.
Commit 46d6e5f 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
1 parent efbfb64 commit f05ed5a
Copy full SHA for f05ed5a

File tree

Expand file treeCollapse file tree

2 files changed

+5
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-10
lines changed
Open diff view settings
Collapse file

‎src/backend/access/transam/twophase.c‎

Copy file name to clipboardExpand all lines: src/backend/access/transam/twophase.c
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
475475
proc->lwWaitMode = 0;
476476
proc->waitLock = NULL;
477477
proc->waitProcLock = NULL;
478+
pg_atomic_init_u64(&proc->waitStart, 0);
478479
for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
479480
SHMQueueInit(&(proc->myProcLocks[i]));
480481
/* subxid data must be filled later by GXactLoadSubxactData */
@@ -873,15 +874,8 @@ PGPROC *
873874
TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
874875
{
875876
GlobalTransaction gxact = TwoPhaseGetGXact(xid, lock_held);
876-
PGPROC *dummy = &ProcGlobal->allProcs[gxact->pgprocno];
877877

878-
/*
879-
* Initialize atomic variable in dummy proc so that GetLockStatusData()
880-
* can read it later.
881-
*/
882-
pg_atomic_init_u64(&dummy->waitStart, 0);
883-
884-
return dummy;
878+
return &ProcGlobal->allProcs[gxact->pgprocno];
885879
}
886880

887881
/************************************************************************/
Collapse file

‎src/backend/storage/lmgr/proc.c‎

Copy file name to clipboardExpand all lines: src/backend/storage/lmgr/proc.c
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ InitProcGlobal(void)
281281
*/
282282
pg_atomic_init_u32(&(procs[i].procArrayGroupNext), INVALID_PGPROCNO);
283283
pg_atomic_init_u32(&(procs[i].clogGroupNext), INVALID_PGPROCNO);
284+
pg_atomic_init_u64(&(procs[i].waitStart), 0);
284285
}
285286

286287
/*
@@ -402,7 +403,7 @@ InitProcess(void)
402403
MyProc->lwWaitMode = 0;
403404
MyProc->waitLock = NULL;
404405
MyProc->waitProcLock = NULL;
405-
pg_atomic_init_u64(&MyProc->waitStart, 0);
406+
pg_atomic_write_u64(&MyProc->waitStart, 0);
406407
#ifdef USE_ASSERT_CHECKING
407408
{
408409
int i;
@@ -581,7 +582,7 @@ InitAuxiliaryProcess(void)
581582
MyProc->lwWaitMode = 0;
582583
MyProc->waitLock = NULL;
583584
MyProc->waitProcLock = NULL;
584-
pg_atomic_init_u64(&MyProc->waitStart, 0);
585+
pg_atomic_write_u64(&MyProc->waitStart, 0);
585586
#ifdef USE_ASSERT_CHECKING
586587
{
587588
int i;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.