Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf05ed5a

Browse files
committed
Initialize atomic variable waitStart in PGPROC, at postmaster startup.
Commit46d6e5f added the atomic variable "waitStart" into PGPROC struct,to store the time at which wait for lock acquisition started. Previouslythis variable was initialized every time each backend started. Instead,this commit makes postmaster initialize it at the startup, to ensure thatthe variable should be initialized before any use of it.This commit also moves the code to initialize "waitStart" variable forprepare transaction, from TwoPhaseGetDummyProc() to MarkAsPreparingGuts().Because MarkAsPreparingGuts() is more proper place to do that sinceit initializes other PGPROC variables.Author: Fujii MasaoReviewed-by: Atsushi TorikoshiDiscussion:https://postgr.es/m/1df88660-6f08-cc6e-b7e2-f85296a2bdab@oss.nttdata.com
1 parentefbfb64 commitf05ed5a

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

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

Lines 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(TransactionIdxid,boollock_held)
874875
{
875876
GlobalTransactiongxact=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-
returndummy;
878+
return&ProcGlobal->allProcs[gxact->pgprocno];
885879
}
886880

887881
/************************************************************************/

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

Lines 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
#ifdefUSE_ASSERT_CHECKING
407408
{
408409
inti;
@@ -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
#ifdefUSE_ASSERT_CHECKING
586587
{
587588
inti;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp