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

Commita53bc13

Browse files
author
Amit Kapila
committed
Fix the initialization of atomic variables introduced by the
group clearing mechanism.Commits0e141c0 andbaaf272 introduced initialization of atomicvariables in InitProcess which means that it's not safe to look at thosefor backends that aren't currently in use. Fix that by initializing themduring postmaster startup.Reported-by: Andres FreundAuthor: Amit KapilaBackpatch-through: 9.6Discussion:https://postgr.es/m/20181027104138.qmbbelopvy7cw2qv@alap3.anarazel.de
1 parent257ef3c commita53bc13

File tree

1 file changed

+9
-2
lines changed
  • src/backend/storage/lmgr

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,13 @@ InitProcGlobal(void)
267267

268268
/* Initialize lockGroupMembers list. */
269269
dlist_init(&procs[i].lockGroupMembers);
270+
271+
/*
272+
* Initialize the atomic variables, otherwise, it won't be safe to
273+
* access them for backends that aren't currently in use.
274+
*/
275+
pg_atomic_init_u32(&(procs[i].procArrayGroupNext),INVALID_PGPROCNO);
276+
pg_atomic_init_u32(&(procs[i].clogGroupNext),INVALID_PGPROCNO);
270277
}
271278

272279
/*
@@ -401,7 +408,7 @@ InitProcess(void)
401408
/* Initialize fields for group XID clearing. */
402409
MyProc->procArrayGroupMember= false;
403410
MyProc->procArrayGroupMemberXid=InvalidTransactionId;
404-
pg_atomic_init_u32(&MyProc->procArrayGroupNext,INVALID_PGPROCNO);
411+
Assert(pg_atomic_read_u32(&MyProc->procArrayGroupNext)==INVALID_PGPROCNO);
405412

406413
/* Check that group locking fields are in a proper initial state. */
407414
Assert(MyProc->lockGroupLeader==NULL);
@@ -416,7 +423,7 @@ InitProcess(void)
416423
MyProc->clogGroupMemberXidStatus=TRANSACTION_STATUS_IN_PROGRESS;
417424
MyProc->clogGroupMemberPage=-1;
418425
MyProc->clogGroupMemberLsn=InvalidXLogRecPtr;
419-
pg_atomic_init_u32(&MyProc->clogGroupNext,INVALID_PGPROCNO);
426+
Assert(pg_atomic_read_u32(&MyProc->clogGroupNext)==INVALID_PGPROCNO);
420427

421428
/*
422429
* Acquire ownership of the PGPROC's latch, so that we can use WaitLatch

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp