diff options
author | Robert Haas <rhaas@postgresql.org> | 2015-09-03 13:10:53 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2015-09-03 13:19:15 -0400 |
commit | 4aec49899e5782247e134f94ce1c6ee926f88e1c (patch) | |
tree | c01a098b379077cf320910e25fe46a976fc4f58e /src/include | |
parent | 1ea5ce5c5f204918b8a9fa6eaa8f3f1374aa8aec (diff) | |
download | postgresql-4aec49899e5782247e134f94ce1c6ee926f88e1c.tar.gz postgresql-4aec49899e5782247e134f94ce1c6ee926f88e1c.zip |
Assorted code review for recent ProcArrayLock patch.
Post-commit review by Andres Freund discovered a couple of concurrency
bugs in the original patch: specifically, if the leader cleared a
follower's XID before it reached PGSemaphoreLock, the semaphore would be
left in the wrong state; and if another process did PGSemaphoreUnlock
for some unrelated reason, we might resume execution before the fact
that our XID was cleared was globally visible.
Also, improve the wording of some comments, rename nextClearXidElem
to firstClearXidElem in PROC_HDR for clarity, and drop some volatile
qualifiers that aren't necessary.
Amit Kapila, reviewed and slightly revised by me.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/storage/proc.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 421bb587df5..3d680171782 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -142,7 +142,8 @@ struct PGPROC struct XidCache subxids; /* cache for subtransaction XIDs */ /* Support for group XID clearing. */ - volatile pg_atomic_uint32 nextClearXidElem; + bool clearXid; + pg_atomic_uint32 nextClearXidElem; TransactionId backendLatestXid; /* Per-backend LWLock. Protects fields below. */ @@ -207,7 +208,7 @@ typedef struct PROC_HDR /* Head of list of bgworker free PGPROC structures */ PGPROC *bgworkerFreeProcs; /* First pgproc waiting for group XID clear */ - volatile pg_atomic_uint32 nextClearXidElem; + pg_atomic_uint32 firstClearXidElem; /* WALWriter process's latch */ Latch *walwriterLatch; /* Checkpointer process's latch */ |