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

Commita455878

Browse files
committed
Rename PGPROC fields related to group XID clearing again.
Commit0e141c0 introduced a newfacility to reduce ProcArrayLock contention by clearing several XIDsfrom the ProcArray under a single lock acquisition. The namesinitially chosen were deemed not to be very good choices, so commit4aec498 renamed them. But now itseems like we still didn't get it right. A pending patch wants toadd similar infrastructure for batching CLOG updates, so the namesneed to be clear enough to allow a new set of structure members witha related purpose.Amit Kapila
1 parent4c9864b commita455878

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

‎src/backend/storage/ipc/procarray.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -497,14 +497,14 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
497497
Assert(TransactionIdIsValid(allPgXact[proc->pgprocno].xid));
498498

499499
/* Add ourselves to the list of processes needing a group XID clear. */
500-
proc->clearXid= true;
501-
proc->backendLatestXid=latestXid;
500+
proc->procArrayGroupMember= true;
501+
proc->procArrayGroupMemberXid=latestXid;
502502
while (true)
503503
{
504-
nextidx=pg_atomic_read_u32(&procglobal->firstClearXidElem);
505-
pg_atomic_write_u32(&proc->nextClearXidElem,nextidx);
504+
nextidx=pg_atomic_read_u32(&procglobal->procArrayGroupFirst);
505+
pg_atomic_write_u32(&proc->procArrayGroupNext,nextidx);
506506

507-
if (pg_atomic_compare_exchange_u32(&procglobal->firstClearXidElem,
507+
if (pg_atomic_compare_exchange_u32(&procglobal->procArrayGroupFirst,
508508
&nextidx,
509509
(uint32)proc->pgprocno))
510510
break;
@@ -523,12 +523,12 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
523523
{
524524
/* acts as a read barrier */
525525
PGSemaphoreLock(&proc->sem);
526-
if (!proc->clearXid)
526+
if (!proc->procArrayGroupMember)
527527
break;
528528
extraWaits++;
529529
}
530530

531-
Assert(pg_atomic_read_u32(&proc->nextClearXidElem)==INVALID_PGPROCNO);
531+
Assert(pg_atomic_read_u32(&proc->procArrayGroupNext)==INVALID_PGPROCNO);
532532

533533
/* Fix semaphore count for any absorbed wakeups */
534534
while (extraWaits-->0)
@@ -546,8 +546,8 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
546546
*/
547547
while (true)
548548
{
549-
nextidx=pg_atomic_read_u32(&procglobal->firstClearXidElem);
550-
if (pg_atomic_compare_exchange_u32(&procglobal->firstClearXidElem,
549+
nextidx=pg_atomic_read_u32(&procglobal->procArrayGroupFirst);
550+
if (pg_atomic_compare_exchange_u32(&procglobal->procArrayGroupFirst,
551551
&nextidx,
552552
INVALID_PGPROCNO))
553553
break;
@@ -562,10 +562,10 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
562562
PGPROC*proc=&allProcs[nextidx];
563563
PGXACT*pgxact=&allPgXact[nextidx];
564564

565-
ProcArrayEndTransactionInternal(proc,pgxact,proc->backendLatestXid);
565+
ProcArrayEndTransactionInternal(proc,pgxact,proc->procArrayGroupMemberXid);
566566

567567
/* Move to next proc in list. */
568-
nextidx=pg_atomic_read_u32(&proc->nextClearXidElem);
568+
nextidx=pg_atomic_read_u32(&proc->procArrayGroupNext);
569569
}
570570

571571
/* We're done with the lock now. */
@@ -582,13 +582,13 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
582582
{
583583
PGPROC*proc=&allProcs[wakeidx];
584584

585-
wakeidx=pg_atomic_read_u32(&proc->nextClearXidElem);
586-
pg_atomic_write_u32(&proc->nextClearXidElem,INVALID_PGPROCNO);
585+
wakeidx=pg_atomic_read_u32(&proc->procArrayGroupNext);
586+
pg_atomic_write_u32(&proc->procArrayGroupNext,INVALID_PGPROCNO);
587587

588588
/* ensure all previous writes are visible before follower continues. */
589589
pg_write_barrier();
590590

591-
proc->clearXid= false;
591+
proc->procArrayGroupMember= false;
592592

593593
if (proc!=MyProc)
594594
PGSemaphoreUnlock(&proc->sem);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ InitProcGlobal(void)
181181
ProcGlobal->startupBufferPinWaitBufId=-1;
182182
ProcGlobal->walwriterLatch=NULL;
183183
ProcGlobal->checkpointerLatch=NULL;
184-
pg_atomic_init_u32(&ProcGlobal->firstClearXidElem,INVALID_PGPROCNO);
184+
pg_atomic_init_u32(&ProcGlobal->procArrayGroupFirst,INVALID_PGPROCNO);
185185

186186
/*
187187
* Create and initialize all the PGPROC structures we'll need. There are
@@ -396,9 +396,9 @@ InitProcess(void)
396396
SHMQueueElemInit(&(MyProc->syncRepLinks));
397397

398398
/* Initialize fields for group XID clearing. */
399-
MyProc->clearXid= false;
400-
MyProc->backendLatestXid=InvalidTransactionId;
401-
pg_atomic_init_u32(&MyProc->nextClearXidElem,INVALID_PGPROCNO);
399+
MyProc->procArrayGroupMember= false;
400+
MyProc->procArrayGroupMemberXid=InvalidTransactionId;
401+
pg_atomic_init_u32(&MyProc->procArrayGroupNext,INVALID_PGPROCNO);
402402

403403
/* Check that group locking fields are in a proper initial state. */
404404
Assert(MyProc->lockGroupLeaderIdentifier==0);

‎src/include/storage/proc.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,15 @@ struct PGPROC
142142
structXidCachesubxids;/* cache for subtransaction XIDs */
143143

144144
/* Support for group XID clearing. */
145-
boolclearXid;
146-
pg_atomic_uint32nextClearXidElem;
147-
TransactionIdbackendLatestXid;
145+
/* true, if member of ProcArray group waiting for XID clear */
146+
boolprocArrayGroupMember;
147+
/* next ProcArray group member waiting for XID clear */
148+
pg_atomic_uint32procArrayGroupNext;
149+
/*
150+
* latest transaction id among the transaction's main XID and
151+
* subtransactions
152+
*/
153+
TransactionIdprocArrayGroupMemberXid;
148154

149155
/* Per-backend LWLock. Protects fields below. */
150156
LWLockbackendLock;
@@ -217,7 +223,7 @@ typedef struct PROC_HDR
217223
/* Head of list of bgworker free PGPROC structures */
218224
PGPROC*bgworkerFreeProcs;
219225
/* First pgproc waiting for group XID clear */
220-
pg_atomic_uint32firstClearXidElem;
226+
pg_atomic_uint32procArrayGroupFirst;
221227
/* WALWriter process's latch */
222228
Latch*walwriterLatch;
223229
/* Checkpointer process's latch */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp