Commit 5da14938 authored by Tom Lane's avatar Tom Lane

Rename SLRU structures and associated LWLocks.

Originally, the names assigned to SLRUs had no purpose other than
being shmem lookup keys, so not a lot of thought went into them.
As of v13, though, we're exposing them in the pg_stat_slru view and
the pg_stat_reset_slru function, so it seems advisable to take a bit
more care.  Rename them to names based on the associated on-disk
storage directories (which fortunately we *did* think about, to some
extent; since those are also visible to DBAs, consistency seems like
a good thing).  Also rename the associated LWLocks, since those names
are likewise user-exposed now as wait event names.

For the most part I only touched symbols used in the respective modules'
SimpleLruInit() calls, not the names of other related objects.  This
renaming could have been taken further, and maybe someday we will do so.
But for now it seems undesirable to change the names of any globally
visible functions or structs, so some inconsistency is unavoidable.

(But I *did* terminate "oldserxid" with prejudice, as I found that
name both unreadable and not descriptive of the SLRU's contents.)

Table 27.12 needs re-alphabetization now, but I'll leave that till
after the other LWLock renamings I have in mind.

Discussion: https://postgr.es/m/28683.1589405363@sss.pgh.pa.us
parent 756abe2b
...@@ -1754,12 +1754,13 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser ...@@ -1754,12 +1754,13 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<entry>Waiting to manage space allocation in shared memory.</entry> <entry>Waiting to manage space allocation in shared memory.</entry>
</row> </row>
<row> <row>
<entry><literal>AsyncCtlLock</literal></entry> <entry><literal>NotifySLRULock</literal></entry>
<entry>Waiting to read or update shared notification state.</entry> <entry>Waiting to access the <command>NOTIFY</command> message SLRU
cache.</entry>
</row> </row>
<row> <row>
<entry><literal>AsyncQueueLock</literal></entry> <entry><literal>NotifyQueueLock</literal></entry>
<entry>Waiting to read or update notification messages.</entry> <entry>Waiting to read or update <command>NOTIFY</command> messages.</entry>
</row> </row>
<row> <row>
<entry><literal>AutoFileLock</literal></entry> <entry><literal>AutoFileLock</literal></entry>
...@@ -1785,13 +1786,13 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser ...@@ -1785,13 +1786,13 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
B-tree index.</entry> B-tree index.</entry>
</row> </row>
<row> <row>
<entry><literal>CLogControlLock</literal></entry> <entry><literal>XactSLRULock</literal></entry>
<entry>Waiting to read or update transaction status.</entry> <entry>Waiting to access the transaction status SLRU cache.</entry>
</row> </row>
<row> <row>
<entry><literal>CLogTruncationLock</literal></entry> <entry><literal>XactTruncationLock</literal></entry>
<entry>Waiting to execute <function>pg_xact_status</function> or update <entry>Waiting to execute <function>pg_xact_status</function> or update
the oldest transaction id available to it.</entry> the oldest transaction ID available to it.</entry>
</row> </row>
<row> <row>
<entry><literal>CheckpointLock</literal></entry> <entry><literal>CheckpointLock</literal></entry>
...@@ -1802,8 +1803,8 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser ...@@ -1802,8 +1803,8 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<entry>Waiting to manage fsync requests.</entry> <entry>Waiting to manage fsync requests.</entry>
</row> </row>
<row> <row>
<entry><literal>CommitTsControlLock</literal></entry> <entry><literal>CommitTsSLRULock</literal></entry>
<entry>Waiting to read or update transaction commit timestamps.</entry> <entry>Waiting to access the commit timestamp SLRU cache.</entry>
</row> </row>
<row> <row>
<entry><literal>CommitTsLock</literal></entry> <entry><literal>CommitTsLock</literal></entry>
...@@ -1828,12 +1829,12 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser ...@@ -1828,12 +1829,12 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<entry>Waiting to read or update shared multixact state.</entry> <entry>Waiting to read or update shared multixact state.</entry>
</row> </row>
<row> <row>
<entry><literal>MultiXactMemberControlLock</literal></entry> <entry><literal>MultiXactMemberSLRULock</literal></entry>
<entry>Waiting to read or update multixact member mappings.</entry> <entry>Waiting to access the multixact member SLRU cache.</entry>
</row> </row>
<row> <row>
<entry><literal>MultiXactOffsetControlLock</literal></entry> <entry><literal>MultiXactOffsetSLRULock</literal></entry>
<entry>Waiting to read or update multixact offset mappings.</entry> <entry>Waiting to access the multixact offset SLRU cache.</entry>
</row> </row>
<row> <row>
<entry><literal>MultiXactTruncationLock</literal></entry> <entry><literal>MultiXactTruncationLock</literal></entry>
...@@ -1844,9 +1845,9 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser ...@@ -1844,9 +1845,9 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<entry>Waiting to allocate or assign an OID.</entry> <entry>Waiting to allocate or assign an OID.</entry>
</row> </row>
<row> <row>
<entry><literal>OldSerXidLock</literal></entry> <entry><literal>SerialSLRULock</literal></entry>
<entry>Waiting to read or record conflicting serializable <entry>Waiting to access the serializable transaction conflict SLRU
transactions.</entry> cache.</entry>
</row> </row>
<row> <row>
<entry><literal>OldSnapshotTimeMapLock</literal></entry> <entry><literal>OldSnapshotTimeMapLock</literal></entry>
...@@ -1907,8 +1908,8 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser ...@@ -1907,8 +1908,8 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<entry>Waiting to find or allocate space in shared memory.</entry> <entry>Waiting to find or allocate space in shared memory.</entry>
</row> </row>
<row> <row>
<entry><literal>SubtransControlLock</literal></entry> <entry><literal>SubtransSLRULock</literal></entry>
<entry>Waiting to read or update sub-transaction information.</entry> <entry>Waiting to access the sub-transaction SLRU cache.</entry>
</row> </row>
<row> <row>
<entry><literal>SyncRepLock</literal></entry> <entry><literal>SyncRepLock</literal></entry>
...@@ -1941,8 +1942,9 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser ...@@ -1941,8 +1942,9 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<entry>Waiting to allocate or assign a transaction id.</entry> <entry>Waiting to allocate or assign a transaction id.</entry>
</row> </row>
<row> <row>
<entry><literal>async</literal></entry> <entry><literal>NotifyBuffer</literal></entry>
<entry>Waiting for I/O on an async (notify) buffer.</entry> <entry>Waiting for I/O on a <command>NOTIFY</command> message SLRU
buffer.</entry>
</row> </row>
<row> <row>
<entry><literal>buffer_content</literal></entry> <entry><literal>buffer_content</literal></entry>
...@@ -1958,12 +1960,12 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser ...@@ -1958,12 +1960,12 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
pool.</entry> pool.</entry>
</row> </row>
<row> <row>
<entry><literal>clog</literal></entry> <entry><literal>XactBuffer</literal></entry>
<entry>Waiting for I/O on a clog (transaction status) buffer.</entry> <entry>Waiting for I/O on a transaction status SLRU buffer.</entry>
</row> </row>
<row> <row>
<entry><literal>commit_timestamp</literal></entry> <entry><literal>CommitTsBuffer</literal></entry>
<entry>Waiting for I/O on commit timestamp buffer.</entry> <entry>Waiting for I/O on a commit timestamp SLRU buffer.</entry>
</row> </row>
<row> <row>
<entry><literal>lock_manager</literal></entry> <entry><literal>lock_manager</literal></entry>
...@@ -1971,16 +1973,17 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser ...@@ -1971,16 +1973,17 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
join or exit a locking group (used by parallel query).</entry> join or exit a locking group (used by parallel query).</entry>
</row> </row>
<row> <row>
<entry><literal>multixact_member</literal></entry> <entry><literal>MultiXactMember</literal></entry>
<entry>Waiting for I/O on a multixact_member buffer.</entry> <entry>Waiting for I/O on a multixact member SLRU buffer.</entry>
</row> </row>
<row> <row>
<entry><literal>multixact_offset</literal></entry> <entry><literal>MultiXactOffsetBuffer</literal></entry>
<entry>Waiting for I/O on a multixact offset buffer.</entry> <entry>Waiting for I/O on a multixact offset SLRU buffer.</entry>
</row> </row>
<row> <row>
<entry><literal>oldserxid</literal></entry> <entry><literal>SerialBuffer</literal></entry>
<entry>Waiting for I/O on an oldserxid buffer.</entry> <entry>Waiting for I/O on a serializable transaction conflict SLRU
buffer.</entry>
</row> </row>
<row> <row>
<entry><literal>parallel_append</literal></entry> <entry><literal>parallel_append</literal></entry>
...@@ -2018,8 +2021,8 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser ...@@ -2018,8 +2021,8 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
in a parallel query.</entry> in a parallel query.</entry>
</row> </row>
<row> <row>
<entry><literal>subtrans</literal></entry> <entry><literal>SubtransBuffer</literal></entry>
<entry>Waiting for I/O on a subtransaction buffer.</entry> <entry>Waiting for I/O on a sub-transaction SLRU buffer.</entry>
</row> </row>
<row> <row>
<entry><literal>tbm</literal></entry> <entry><literal>tbm</literal></entry>
...@@ -4190,7 +4193,13 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i ...@@ -4190,7 +4193,13 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
</tgroup> </tgroup>
</table> </table>
<indexterm>
<primary>SLRU</primary>
</indexterm>
<para> <para>
<productname>PostgreSQL</productname> accesses certain on-disk information
via <firstterm>SLRU</firstterm> (simple least-recently-used) caches.
The <structname>pg_stat_slru</structname> view will contain The <structname>pg_stat_slru</structname> view will contain
one row for each tracked SLRU cache, showing statistics about access one row for each tracked SLRU cache, showing statistics about access
to cached pages. to cached pages.
...@@ -4484,11 +4493,15 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i ...@@ -4484,11 +4493,15 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
Resets statistics to zero for a single SLRU cache, or for all SLRUs in Resets statistics to zero for a single SLRU cache, or for all SLRUs in
the cluster. If the argument is NULL, all counters shown in the cluster. If the argument is NULL, all counters shown in
the <structname>pg_stat_slru</structname> view for all SLRU caches are the <structname>pg_stat_slru</structname> view for all SLRU caches are
reset. The argument can be one of <literal>async</literal>, reset. The argument can be one of
<literal>clog</literal>, <literal>commit_timestamp</literal>, <literal>CommitTs</literal>,
<literal>multixact_offset</literal>, <literal>MultiXactMember</literal>,
<literal>multixact_member</literal>, <literal>oldserxid</literal>, or <literal>MultiXactOffset</literal>,
<literal>subtrans</literal> to reset the counters for only that entry. <literal>Notify</literal>,
<literal>Serial</literal>,
<literal>Subtrans</literal>, or
<literal>Xact</literal>
to reset the counters for only that entry.
If the argument is <literal>other</literal> (or indeed, any If the argument is <literal>other</literal> (or indeed, any
unrecognized name), then the counters for all other SLRU caches, such unrecognized name), then the counters for all other SLRU caches, such
as extension-defined caches, are reset. as extension-defined caches, are reset.
......
This diff is collapsed.
...@@ -235,7 +235,7 @@ SetXidCommitTsInPage(TransactionId xid, int nsubxids, ...@@ -235,7 +235,7 @@ SetXidCommitTsInPage(TransactionId xid, int nsubxids,
int slotno; int slotno;
int i; int i;
LWLockAcquire(CommitTsControlLock, LW_EXCLUSIVE); LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
slotno = SimpleLruReadPage(CommitTsCtl, pageno, true, xid); slotno = SimpleLruReadPage(CommitTsCtl, pageno, true, xid);
...@@ -245,13 +245,13 @@ SetXidCommitTsInPage(TransactionId xid, int nsubxids, ...@@ -245,13 +245,13 @@ SetXidCommitTsInPage(TransactionId xid, int nsubxids,
CommitTsCtl->shared->page_dirty[slotno] = true; CommitTsCtl->shared->page_dirty[slotno] = true;
LWLockRelease(CommitTsControlLock); LWLockRelease(CommitTsSLRULock);
} }
/* /*
* Sets the commit timestamp of a single transaction. * Sets the commit timestamp of a single transaction.
* *
* Must be called with CommitTsControlLock held * Must be called with CommitTsSLRULock held
*/ */
static void static void
TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts, TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
...@@ -352,7 +352,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts, ...@@ -352,7 +352,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
if (nodeid) if (nodeid)
*nodeid = entry.nodeid; *nodeid = entry.nodeid;
LWLockRelease(CommitTsControlLock); LWLockRelease(CommitTsSLRULock);
return *ts != 0; return *ts != 0;
} }
...@@ -492,9 +492,9 @@ CommitTsShmemInit(void) ...@@ -492,9 +492,9 @@ CommitTsShmemInit(void)
bool found; bool found;
CommitTsCtl->PagePrecedes = CommitTsPagePrecedes; CommitTsCtl->PagePrecedes = CommitTsPagePrecedes;
SimpleLruInit(CommitTsCtl, "commit_timestamp", CommitTsShmemBuffers(), 0, SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
CommitTsControlLock, "pg_commit_ts", CommitTsSLRULock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFERS); LWTRANCHE_COMMITTS_BUFFER);
commitTsShared = ShmemInitStruct("CommitTs shared", commitTsShared = ShmemInitStruct("CommitTs shared",
sizeof(CommitTimestampShared), sizeof(CommitTimestampShared),
...@@ -649,9 +649,9 @@ ActivateCommitTs(void) ...@@ -649,9 +649,9 @@ ActivateCommitTs(void)
/* /*
* Re-Initialize our idea of the latest page number. * Re-Initialize our idea of the latest page number.
*/ */
LWLockAcquire(CommitTsControlLock, LW_EXCLUSIVE); LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
CommitTsCtl->shared->latest_page_number = pageno; CommitTsCtl->shared->latest_page_number = pageno;
LWLockRelease(CommitTsControlLock); LWLockRelease(CommitTsSLRULock);
/* /*
* If CommitTs is enabled, but it wasn't in the previous server run, we * If CommitTs is enabled, but it wasn't in the previous server run, we
...@@ -679,11 +679,11 @@ ActivateCommitTs(void) ...@@ -679,11 +679,11 @@ ActivateCommitTs(void)
{ {
int slotno; int slotno;
LWLockAcquire(CommitTsControlLock, LW_EXCLUSIVE); LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
slotno = ZeroCommitTsPage(pageno, false); slotno = ZeroCommitTsPage(pageno, false);
SimpleLruWritePage(CommitTsCtl, slotno); SimpleLruWritePage(CommitTsCtl, slotno);
Assert(!CommitTsCtl->shared->page_dirty[slotno]); Assert(!CommitTsCtl->shared->page_dirty[slotno]);
LWLockRelease(CommitTsControlLock); LWLockRelease(CommitTsSLRULock);
} }
/* Change the activation status in shared memory. */ /* Change the activation status in shared memory. */
...@@ -732,9 +732,9 @@ DeactivateCommitTs(void) ...@@ -732,9 +732,9 @@ DeactivateCommitTs(void)
* be overwritten anyway when we wrap around, but it seems better to be * be overwritten anyway when we wrap around, but it seems better to be
* tidy.) * tidy.)
*/ */
LWLockAcquire(CommitTsControlLock, LW_EXCLUSIVE); LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
(void) SlruScanDirectory(CommitTsCtl, SlruScanDirCbDeleteAll, NULL); (void) SlruScanDirectory(CommitTsCtl, SlruScanDirCbDeleteAll, NULL);
LWLockRelease(CommitTsControlLock); LWLockRelease(CommitTsSLRULock);
} }
/* /*
...@@ -804,12 +804,12 @@ ExtendCommitTs(TransactionId newestXact) ...@@ -804,12 +804,12 @@ ExtendCommitTs(TransactionId newestXact)
pageno = TransactionIdToCTsPage(newestXact); pageno = TransactionIdToCTsPage(newestXact);
LWLockAcquire(CommitTsControlLock, LW_EXCLUSIVE); LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
/* Zero the page and make an XLOG entry about it */ /* Zero the page and make an XLOG entry about it */
ZeroCommitTsPage(pageno, !InRecovery); ZeroCommitTsPage(pageno, !InRecovery);
LWLockRelease(CommitTsControlLock); LWLockRelease(CommitTsSLRULock);
} }
/* /*
...@@ -974,13 +974,13 @@ commit_ts_redo(XLogReaderState *record) ...@@ -974,13 +974,13 @@ commit_ts_redo(XLogReaderState *record)
memcpy(&pageno, XLogRecGetData(record), sizeof(int)); memcpy(&pageno, XLogRecGetData(record), sizeof(int));
LWLockAcquire(CommitTsControlLock, LW_EXCLUSIVE); LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
slotno = ZeroCommitTsPage(pageno, false); slotno = ZeroCommitTsPage(pageno, false);
SimpleLruWritePage(CommitTsCtl, slotno); SimpleLruWritePage(CommitTsCtl, slotno);
Assert(!CommitTsCtl->shared->page_dirty[slotno]); Assert(!CommitTsCtl->shared->page_dirty[slotno]);
LWLockRelease(CommitTsControlLock); LWLockRelease(CommitTsSLRULock);
} }
else if (info == COMMIT_TS_TRUNCATE) else if (info == COMMIT_TS_TRUNCATE)
{ {
......
...@@ -192,8 +192,8 @@ static SlruCtlData MultiXactMemberCtlData; ...@@ -192,8 +192,8 @@ static SlruCtlData MultiXactMemberCtlData;
/* /*
* MultiXact state shared across all backends. All this state is protected * MultiXact state shared across all backends. All this state is protected
* by MultiXactGenLock. (We also use MultiXactOffsetControlLock and * by MultiXactGenLock. (We also use MultiXactOffsetSLRULock and
* MultiXactMemberControlLock to guard accesses to the two sets of SLRU * MultiXactMemberSLRULock to guard accesses to the two sets of SLRU
* buffers. For concurrency's sake, we avoid holding more than one of these * buffers. For concurrency's sake, we avoid holding more than one of these
* locks at a time.) * locks at a time.)
*/ */
...@@ -850,7 +850,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, ...@@ -850,7 +850,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
MultiXactOffset *offptr; MultiXactOffset *offptr;
int i; int i;
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
pageno = MultiXactIdToOffsetPage(multi); pageno = MultiXactIdToOffsetPage(multi);
entryno = MultiXactIdToOffsetEntry(multi); entryno = MultiXactIdToOffsetEntry(multi);
...@@ -871,9 +871,9 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, ...@@ -871,9 +871,9 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
MultiXactOffsetCtl->shared->page_dirty[slotno] = true; MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
/* Exchange our lock */ /* Exchange our lock */
LWLockRelease(MultiXactOffsetControlLock); LWLockRelease(MultiXactOffsetSLRULock);
LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
prev_pageno = -1; prev_pageno = -1;
...@@ -915,7 +915,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, ...@@ -915,7 +915,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
MultiXactMemberCtl->shared->page_dirty[slotno] = true; MultiXactMemberCtl->shared->page_dirty[slotno] = true;
} }
LWLockRelease(MultiXactMemberControlLock); LWLockRelease(MultiXactMemberSLRULock);
} }
/* /*
...@@ -1321,7 +1321,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members, ...@@ -1321,7 +1321,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
* time on every multixact creation. * time on every multixact creation.
*/ */
retry: retry:
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
pageno = MultiXactIdToOffsetPage(multi); pageno = MultiXactIdToOffsetPage(multi);
entryno = MultiXactIdToOffsetEntry(multi); entryno = MultiXactIdToOffsetEntry(multi);
...@@ -1367,7 +1367,7 @@ retry: ...@@ -1367,7 +1367,7 @@ retry:
if (nextMXOffset == 0) if (nextMXOffset == 0)
{ {
/* Corner case 2: next multixact is still being filled in */ /* Corner case 2: next multixact is still being filled in */
LWLockRelease(MultiXactOffsetControlLock); LWLockRelease(MultiXactOffsetSLRULock);
CHECK_FOR_INTERRUPTS(); CHECK_FOR_INTERRUPTS();
pg_usleep(1000L); pg_usleep(1000L);
goto retry; goto retry;
...@@ -1376,13 +1376,13 @@ retry: ...@@ -1376,13 +1376,13 @@ retry:
length = nextMXOffset - offset; length = nextMXOffset - offset;
} }
LWLockRelease(MultiXactOffsetControlLock); LWLockRelease(MultiXactOffsetSLRULock);
ptr = (MultiXactMember *) palloc(length * sizeof(MultiXactMember)); ptr = (MultiXactMember *) palloc(length * sizeof(MultiXactMember));
*members = ptr; *members = ptr;
/* Now get the members themselves. */ /* Now get the members themselves. */
LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
truelength = 0; truelength = 0;
prev_pageno = -1; prev_pageno = -1;
...@@ -1422,7 +1422,7 @@ retry: ...@@ -1422,7 +1422,7 @@ retry:
truelength++; truelength++;
} }
LWLockRelease(MultiXactMemberControlLock); LWLockRelease(MultiXactMemberSLRULock);
/* /*
* Copy the result into the local cache. * Copy the result into the local cache.
...@@ -1812,8 +1812,8 @@ MultiXactShmemSize(void) ...@@ -1812,8 +1812,8 @@ MultiXactShmemSize(void)
mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot)) mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
size = SHARED_MULTIXACT_STATE_SIZE; size = SHARED_MULTIXACT_STATE_SIZE;
size = add_size(size, SimpleLruShmemSize(NUM_MXACTOFFSET_BUFFERS, 0)); size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
size = add_size(size, SimpleLruShmemSize(NUM_MXACTMEMBER_BUFFERS, 0)); size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
return size; return size;
} }
...@@ -1829,13 +1829,13 @@ MultiXactShmemInit(void) ...@@ -1829,13 +1829,13 @@ MultiXactShmemInit(void)
MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes; MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
SimpleLruInit(MultiXactOffsetCtl, SimpleLruInit(MultiXactOffsetCtl,
"multixact_offset", NUM_MXACTOFFSET_BUFFERS, 0, "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
MultiXactOffsetControlLock, "pg_multixact/offsets", MultiXactOffsetSLRULock, "pg_multixact/offsets",
LWTRANCHE_MXACTOFFSET_BUFFERS); LWTRANCHE_MULTIXACTOFFSET_BUFFER);
SimpleLruInit(MultiXactMemberCtl, SimpleLruInit(MultiXactMemberCtl,
"multixact_member", NUM_MXACTMEMBER_BUFFERS, 0, "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
MultiXactMemberControlLock, "pg_multixact/members", MultiXactMemberSLRULock, "pg_multixact/members",
LWTRANCHE_MXACTMEMBER_BUFFERS); LWTRANCHE_MULTIXACTMEMBER_BUFFER);
/* Initialize our shared state struct */ /* Initialize our shared state struct */
MultiXactState = ShmemInitStruct("Shared MultiXact State", MultiXactState = ShmemInitStruct("Shared MultiXact State",
...@@ -1869,7 +1869,7 @@ BootStrapMultiXact(void) ...@@ -1869,7 +1869,7 @@ BootStrapMultiXact(void)
{ {
int slotno; int slotno;
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
/* Create and zero the first page of the offsets log */ /* Create and zero the first page of the offsets log */
slotno = ZeroMultiXactOffsetPage(0, false); slotno = ZeroMultiXactOffsetPage(0, false);
...@@ -1878,9 +1878,9 @@ BootStrapMultiXact(void) ...@@ -1878,9 +1878,9 @@ BootStrapMultiXact(void)
SimpleLruWritePage(MultiXactOffsetCtl, slotno); SimpleLruWritePage(MultiXactOffsetCtl, slotno);
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]); Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
LWLockRelease(MultiXactOffsetControlLock); LWLockRelease(MultiXactOffsetSLRULock);
LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
/* Create and zero the first page of the members log */ /* Create and zero the first page of the members log */
slotno = ZeroMultiXactMemberPage(0, false); slotno = ZeroMultiXactMemberPage(0, false);
...@@ -1889,7 +1889,7 @@ BootStrapMultiXact(void) ...@@ -1889,7 +1889,7 @@ BootStrapMultiXact(void)
SimpleLruWritePage(MultiXactMemberCtl, slotno); SimpleLruWritePage(MultiXactMemberCtl, slotno);
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]); Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
LWLockRelease(MultiXactMemberControlLock); LWLockRelease(MultiXactMemberSLRULock);
} }
/* /*
...@@ -1952,7 +1952,7 @@ MaybeExtendOffsetSlru(void) ...@@ -1952,7 +1952,7 @@ MaybeExtendOffsetSlru(void)
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact); pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
if (!SimpleLruDoesPhysicalPageExist(MultiXactOffsetCtl, pageno)) if (!SimpleLruDoesPhysicalPageExist(MultiXactOffsetCtl, pageno))
{ {
...@@ -1967,7 +1967,7 @@ MaybeExtendOffsetSlru(void) ...@@ -1967,7 +1967,7 @@ MaybeExtendOffsetSlru(void)
SimpleLruWritePage(MultiXactOffsetCtl, slotno); SimpleLruWritePage(MultiXactOffsetCtl, slotno);
} }
LWLockRelease(MultiXactOffsetControlLock); LWLockRelease(MultiXactOffsetSLRULock);
} }
/* /*
...@@ -2020,7 +2020,7 @@ TrimMultiXact(void) ...@@ -2020,7 +2020,7 @@ TrimMultiXact(void)
LWLockRelease(MultiXactGenLock); LWLockRelease(MultiXactGenLock);
/* Clean up offsets state */ /* Clean up offsets state */
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
/* /*
* (Re-)Initialize our idea of the latest page number for offsets. * (Re-)Initialize our idea of the latest page number for offsets.
...@@ -2051,10 +2051,10 @@ TrimMultiXact(void) ...@@ -2051,10 +2051,10 @@ TrimMultiXact(void)
MultiXactOffsetCtl->shared->page_dirty[slotno] = true; MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
} }
LWLockRelease(MultiXactOffsetControlLock); LWLockRelease(MultiXactOffsetSLRULock);
/* And the same for members */ /* And the same for members */
LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
/* /*
* (Re-)Initialize our idea of the latest page number for members. * (Re-)Initialize our idea of the latest page number for members.
...@@ -2089,7 +2089,7 @@ TrimMultiXact(void) ...@@ -2089,7 +2089,7 @@ TrimMultiXact(void)
MultiXactMemberCtl->shared->page_dirty[slotno] = true; MultiXactMemberCtl->shared->page_dirty[slotno] = true;
} }
LWLockRelease(MultiXactMemberControlLock); LWLockRelease(MultiXactMemberSLRULock);
/* signal that we're officially up */ /* signal that we're officially up */
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
...@@ -2402,12 +2402,12 @@ ExtendMultiXactOffset(MultiXactId multi) ...@@ -2402,12 +2402,12 @@ ExtendMultiXactOffset(MultiXactId multi)
pageno = MultiXactIdToOffsetPage(multi); pageno = MultiXactIdToOffsetPage(multi);
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
/* Zero the page and make an XLOG entry about it */ /* Zero the page and make an XLOG entry about it */
ZeroMultiXactOffsetPage(pageno, true); ZeroMultiXactOffsetPage(pageno, true);
LWLockRelease(MultiXactOffsetControlLock); LWLockRelease(MultiXactOffsetSLRULock);
} }
/* /*
...@@ -2443,12 +2443,12 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers) ...@@ -2443,12 +2443,12 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
pageno = MXOffsetToMemberPage(offset); pageno = MXOffsetToMemberPage(offset);
LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
/* Zero the page and make an XLOG entry about it */ /* Zero the page and make an XLOG entry about it */
ZeroMultiXactMemberPage(pageno, true); ZeroMultiXactMemberPage(pageno, true);
LWLockRelease(MultiXactMemberControlLock); LWLockRelease(MultiXactMemberSLRULock);
} }
/* /*
...@@ -2749,7 +2749,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result) ...@@ -2749,7 +2749,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno]; offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
offptr += entryno; offptr += entryno;
offset = *offptr; offset = *offptr;
LWLockRelease(MultiXactOffsetControlLock); LWLockRelease(MultiXactOffsetSLRULock);
*result = offset; *result = offset;
return true; return true;
...@@ -3230,13 +3230,13 @@ multixact_redo(XLogReaderState *record) ...@@ -3230,13 +3230,13 @@ multixact_redo(XLogReaderState *record)
memcpy(&pageno, XLogRecGetData(record), sizeof(int)); memcpy(&pageno, XLogRecGetData(record), sizeof(int));
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
slotno = ZeroMultiXactOffsetPage(pageno, false); slotno = ZeroMultiXactOffsetPage(pageno, false);
SimpleLruWritePage(MultiXactOffsetCtl, slotno); SimpleLruWritePage(MultiXactOffsetCtl, slotno);
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]); Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
LWLockRelease(MultiXactOffsetControlLock); LWLockRelease(MultiXactOffsetSLRULock);
} }
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE) else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{ {
...@@ -3245,13 +3245,13 @@ multixact_redo(XLogReaderState *record) ...@@ -3245,13 +3245,13 @@ multixact_redo(XLogReaderState *record)
memcpy(&pageno, XLogRecGetData(record), sizeof(int)); memcpy(&pageno, XLogRecGetData(record), sizeof(int));
LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE); LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
slotno = ZeroMultiXactMemberPage(pageno, false); slotno = ZeroMultiXactMemberPage(pageno, false);
SimpleLruWritePage(MultiXactMemberCtl, slotno); SimpleLruWritePage(MultiXactMemberCtl, slotno);
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]); Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
LWLockRelease(MultiXactMemberControlLock); LWLockRelease(MultiXactMemberSLRULock);
} }
else if (info == XLOG_MULTIXACT_CREATE_ID) else if (info == XLOG_MULTIXACT_CREATE_ID)
{ {
......
...@@ -160,6 +160,17 @@ SimpleLruShmemSize(int nslots, int nlsns) ...@@ -160,6 +160,17 @@ SimpleLruShmemSize(int nslots, int nlsns)
return BUFFERALIGN(sz) + BLCKSZ * nslots; return BUFFERALIGN(sz) + BLCKSZ * nslots;
} }
/*
* Initialize, or attach to, a simple LRU cache in shared memory.
*
* ctl: address of local (unshared) control structure.
* name: name of SLRU. (This is user-visible, pick with care!)
* nslots: number of page slots to use.
* nlsns: number of LSN groups per page (set to zero if not relevant).
* ctllock: LWLock to use to control access to the shared control structure.
* subdir: PGDATA-relative subdirectory that will contain the files.
* tranche_id: LWLock tranche ID to use for the SLRU's per-buffer LWLocks.
*/
void void
SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns, SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id) LWLock *ctllock, const char *subdir, int tranche_id)
......
...@@ -81,7 +81,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent) ...@@ -81,7 +81,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
Assert(TransactionIdIsValid(parent)); Assert(TransactionIdIsValid(parent));
Assert(TransactionIdFollows(xid, parent)); Assert(TransactionIdFollows(xid, parent));
LWLockAcquire(SubtransControlLock, LW_EXCLUSIVE); LWLockAcquire(SubtransSLRULock, LW_EXCLUSIVE);
slotno = SimpleLruReadPage(SubTransCtl, pageno, true, xid); slotno = SimpleLruReadPage(SubTransCtl, pageno, true, xid);
ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno]; ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno];
...@@ -99,7 +99,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent) ...@@ -99,7 +99,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
SubTransCtl->shared->page_dirty[slotno] = true; SubTransCtl->shared->page_dirty[slotno] = true;
} }
LWLockRelease(SubtransControlLock); LWLockRelease(SubtransSLRULock);
} }
/* /*
...@@ -129,7 +129,7 @@ SubTransGetParent(TransactionId xid) ...@@ -129,7 +129,7 @@ SubTransGetParent(TransactionId xid)
parent = *ptr; parent = *ptr;
LWLockRelease(SubtransControlLock); LWLockRelease(SubtransSLRULock);
return parent; return parent;
} }
...@@ -191,9 +191,9 @@ void ...@@ -191,9 +191,9 @@ void
SUBTRANSShmemInit(void) SUBTRANSShmemInit(void)
{ {
SubTransCtl->PagePrecedes = SubTransPagePrecedes; SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "subtrans", NUM_SUBTRANS_BUFFERS, 0, SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
SubtransControlLock, "pg_subtrans", SubtransSLRULock, "pg_subtrans",
LWTRANCHE_SUBTRANS_BUFFERS); LWTRANCHE_SUBTRANS_BUFFER);
/* Override default assumption that writes should be fsync'd */ /* Override default assumption that writes should be fsync'd */
SubTransCtl->do_fsync = false; SubTransCtl->do_fsync = false;
} }
...@@ -213,7 +213,7 @@ BootStrapSUBTRANS(void) ...@@ -213,7 +213,7 @@ BootStrapSUBTRANS(void)
{ {
int slotno; int slotno;
LWLockAcquire(SubtransControlLock, LW_EXCLUSIVE); LWLockAcquire(SubtransSLRULock, LW_EXCLUSIVE);
/* Create and zero the first page of the subtrans log */ /* Create and zero the first page of the subtrans log */
slotno = ZeroSUBTRANSPage(0); slotno = ZeroSUBTRANSPage(0);
...@@ -222,7 +222,7 @@ BootStrapSUBTRANS(void) ...@@ -222,7 +222,7 @@ BootStrapSUBTRANS(void)
SimpleLruWritePage(SubTransCtl, slotno); SimpleLruWritePage(SubTransCtl, slotno);
Assert(!SubTransCtl->shared->page_dirty[slotno]); Assert(!SubTransCtl->shared->page_dirty[slotno]);
LWLockRelease(SubtransControlLock); LWLockRelease(SubtransSLRULock);
} }
/* /*
...@@ -259,7 +259,7 @@ StartupSUBTRANS(TransactionId oldestActiveXID) ...@@ -259,7 +259,7 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
* Whenever we advance into a new page, ExtendSUBTRANS will likewise zero * Whenever we advance into a new page, ExtendSUBTRANS will likewise zero
* the new page without regard to whatever was previously on disk. * the new page without regard to whatever was previously on disk.
*/ */
LWLockAcquire(SubtransControlLock, LW_EXCLUSIVE); LWLockAcquire(SubtransSLRULock, LW_EXCLUSIVE);
startPage = TransactionIdToPage(oldestActiveXID); startPage = TransactionIdToPage(oldestActiveXID);
nextFullXid = ShmemVariableCache->nextFullXid; nextFullXid = ShmemVariableCache->nextFullXid;
...@@ -275,7 +275,7 @@ StartupSUBTRANS(TransactionId oldestActiveXID) ...@@ -275,7 +275,7 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
} }
(void) ZeroSUBTRANSPage(startPage); (void) ZeroSUBTRANSPage(startPage);
LWLockRelease(SubtransControlLock); LWLockRelease(SubtransSLRULock);
} }
/* /*
...@@ -337,12 +337,12 @@ ExtendSUBTRANS(TransactionId newestXact) ...@@ -337,12 +337,12 @@ ExtendSUBTRANS(TransactionId newestXact)
pageno = TransactionIdToPage(newestXact); pageno = TransactionIdToPage(newestXact);
LWLockAcquire(SubtransControlLock, LW_EXCLUSIVE); LWLockAcquire(SubtransSLRULock, LW_EXCLUSIVE);
/* Zero the page */ /* Zero the page */
ZeroSUBTRANSPage(pageno); ZeroSUBTRANSPage(pageno);
LWLockRelease(SubtransControlLock); LWLockRelease(SubtransSLRULock);
} }
......
...@@ -303,22 +303,22 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid) ...@@ -303,22 +303,22 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid)
/* /*
* Advance the cluster-wide value for the oldest valid clog entry. * Advance the cluster-wide value for the oldest valid clog entry.
* *
* We must acquire CLogTruncationLock to advance the oldestClogXid. It's not * We must acquire XactTruncationLock to advance the oldestClogXid. It's not
* necessary to hold the lock during the actual clog truncation, only when we * necessary to hold the lock during the actual clog truncation, only when we
* advance the limit, as code looking up arbitrary xids is required to hold * advance the limit, as code looking up arbitrary xids is required to hold
* CLogTruncationLock from when it tests oldestClogXid through to when it * XactTruncationLock from when it tests oldestClogXid through to when it
* completes the clog lookup. * completes the clog lookup.
*/ */
void void
AdvanceOldestClogXid(TransactionId oldest_datfrozenxid) AdvanceOldestClogXid(TransactionId oldest_datfrozenxid)
{ {
LWLockAcquire(CLogTruncationLock, LW_EXCLUSIVE); LWLockAcquire(XactTruncationLock, LW_EXCLUSIVE);
if (TransactionIdPrecedes(ShmemVariableCache->oldestClogXid, if (TransactionIdPrecedes(ShmemVariableCache->oldestClogXid,
oldest_datfrozenxid)) oldest_datfrozenxid))
{ {
ShmemVariableCache->oldestClogXid = oldest_datfrozenxid; ShmemVariableCache->oldestClogXid = oldest_datfrozenxid;
} }
LWLockRelease(CLogTruncationLock); LWLockRelease(XactTruncationLock);
} }
/* /*
......
This diff is collapsed.
...@@ -147,13 +147,13 @@ PgStat_MsgBgWriter BgWriterStats; ...@@ -147,13 +147,13 @@ PgStat_MsgBgWriter BgWriterStats;
* all SLRUs without an explicit entry (e.g. SLRUs in extensions). * all SLRUs without an explicit entry (e.g. SLRUs in extensions).
*/ */
static const char *const slru_names[] = { static const char *const slru_names[] = {
"async", "CommitTs",
"clog", "MultiXactMember",
"commit_timestamp", "MultiXactOffset",
"multixact_offset", "Notify",
"multixact_member", "Serial",
"oldserxid", "Subtrans",
"subtrans", "Xact",
"other" /* has to be last */ "other" /* has to be last */
}; };
......
...@@ -182,7 +182,7 @@ static const char *const excludeDirContents[] = ...@@ -182,7 +182,7 @@ static const char *const excludeDirContents[] =
/* /*
* Old contents are loaded for possible debugging but are not required for * Old contents are loaded for possible debugging but are not required for
* normal operation, see OldSerXidInit(). * normal operation, see SerialInit().
*/ */
"pg_serial", "pg_serial",
......
...@@ -124,20 +124,20 @@ extern slock_t *ShmemLock; ...@@ -124,20 +124,20 @@ extern slock_t *ShmemLock;
*/ */
static const char *const BuiltinTrancheNames[] = { static const char *const BuiltinTrancheNames[] = {
/* LWTRANCHE_CLOG_BUFFERS: */ /* LWTRANCHE_XACT_BUFFER: */
"clog", "XactBuffer",
/* LWTRANCHE_COMMITTS_BUFFERS: */ /* LWTRANCHE_COMMITTS_BUFFER: */
"commit_timestamp", "CommitTSBuffer",
/* LWTRANCHE_SUBTRANS_BUFFERS: */ /* LWTRANCHE_SUBTRANS_BUFFER: */
"subtrans", "SubtransBuffer",
/* LWTRANCHE_MXACTOFFSET_BUFFERS: */ /* LWTRANCHE_MULTIXACTOFFSET_BUFFER: */
"multixact_offset", "MultiXactOffsetBuffer",
/* LWTRANCHE_MXACTMEMBER_BUFFERS: */ /* LWTRANCHE_MULTIXACTMEMBER_BUFFER: */
"multixact_member", "MultiXactMemberBuffer",
/* LWTRANCHE_ASYNC_BUFFERS: */ /* LWTRANCHE_NOTIFY_BUFFER: */
"async", "NotifyBuffer",
/* LWTRANCHE_OLDSERXID_BUFFERS: */ /* LWTRANCHE_SERIAL_BUFFER: */
"oldserxid", "SerialBuffer",
/* LWTRANCHE_WAL_INSERT: */ /* LWTRANCHE_WAL_INSERT: */
"wal_insert", "wal_insert",
/* LWTRANCHE_BUFFER_CONTENT: */ /* LWTRANCHE_BUFFER_CONTENT: */
......
...@@ -15,11 +15,11 @@ WALBufMappingLock 7 ...@@ -15,11 +15,11 @@ WALBufMappingLock 7
WALWriteLock 8 WALWriteLock 8
ControlFileLock 9 ControlFileLock 9
CheckpointLock 10 CheckpointLock 10
CLogControlLock 11 XactSLRULock 11
SubtransControlLock 12 SubtransSLRULock 12
MultiXactGenLock 13 MultiXactGenLock 13
MultiXactOffsetControlLock 14 MultiXactOffsetSLRULock 14
MultiXactMemberControlLock 15 MultiXactMemberSLRULock 15
RelCacheInitLock 16 RelCacheInitLock 16
CheckpointerCommLock 17 CheckpointerCommLock 17
TwoPhaseStateLock 18 TwoPhaseStateLock 18
...@@ -30,22 +30,22 @@ AutovacuumLock 22 ...@@ -30,22 +30,22 @@ AutovacuumLock 22
AutovacuumScheduleLock 23 AutovacuumScheduleLock 23
SyncScanLock 24 SyncScanLock 24
RelationMappingLock 25 RelationMappingLock 25
AsyncCtlLock 26 NotifySLRULock 26
AsyncQueueLock 27 NotifyQueueLock 27
SerializableXactHashLock 28 SerializableXactHashLock 28
SerializableFinishedListLock 29 SerializableFinishedListLock 29
SerializablePredicateLockListLock 30 SerializablePredicateLockListLock 30
OldSerXidLock 31 SerialSLRULock 31
SyncRepLock 32 SyncRepLock 32
BackgroundWorkerLock 33 BackgroundWorkerLock 33
DynamicSharedMemoryControlLock 34 DynamicSharedMemoryControlLock 34
AutoFileLock 35 AutoFileLock 35
ReplicationSlotAllocationLock 36 ReplicationSlotAllocationLock 36
ReplicationSlotControlLock 37 ReplicationSlotControlLock 37
CommitTsControlLock 38 CommitTsSLRULock 38
CommitTsLock 39 CommitTsLock 39
ReplicationOriginLock 40 ReplicationOriginLock 40
MultiXactTruncationLock 41 MultiXactTruncationLock 41
OldSnapshotTimeMapLock 42 OldSnapshotTimeMapLock 42
LogicalRepWorkerLock 43 LogicalRepWorkerLock 43
CLogTruncationLock 44 XactTruncationLock 44
This diff is collapsed.
...@@ -82,7 +82,7 @@ typedef struct ...@@ -82,7 +82,7 @@ typedef struct
* to the low 32 bits of the transaction ID (i.e. the actual XID, without the * to the low 32 bits of the transaction ID (i.e. the actual XID, without the
* epoch). * epoch).
* *
* The caller must hold CLogTruncationLock since it's dealing with arbitrary * The caller must hold XactTruncationLock since it's dealing with arbitrary
* XIDs, and must continue to hold it until it's done with any clog lookups * XIDs, and must continue to hold it until it's done with any clog lookups
* relating to those XIDs. * relating to those XIDs.
*/ */
...@@ -118,13 +118,13 @@ TransactionIdInRecentPast(FullTransactionId fxid, TransactionId *extracted_xid) ...@@ -118,13 +118,13 @@ TransactionIdInRecentPast(FullTransactionId fxid, TransactionId *extracted_xid)
U64FromFullTransactionId(fxid))))); U64FromFullTransactionId(fxid)))));
/* /*
* ShmemVariableCache->oldestClogXid is protected by CLogTruncationLock, * ShmemVariableCache->oldestClogXid is protected by XactTruncationLock,
* but we don't acquire that lock here. Instead, we require the caller to * but we don't acquire that lock here. Instead, we require the caller to
* acquire it, because the caller is presumably going to look up the * acquire it, because the caller is presumably going to look up the
* returned XID. If we took and released the lock within this function, a * returned XID. If we took and released the lock within this function, a
* CLOG truncation could occur before the caller finished with the XID. * CLOG truncation could occur before the caller finished with the XID.
*/ */
Assert(LWLockHeldByMe(CLogTruncationLock)); Assert(LWLockHeldByMe(XactTruncationLock));
/* /*
* If the transaction ID has wrapped around, it's definitely too old to * If the transaction ID has wrapped around, it's definitely too old to
...@@ -672,7 +672,7 @@ pg_xact_status(PG_FUNCTION_ARGS) ...@@ -672,7 +672,7 @@ pg_xact_status(PG_FUNCTION_ARGS)
* We must protect against concurrent truncation of clog entries to avoid * We must protect against concurrent truncation of clog entries to avoid
* an I/O error on SLRU lookup. * an I/O error on SLRU lookup.
*/ */
LWLockAcquire(CLogTruncationLock, LW_SHARED); LWLockAcquire(XactTruncationLock, LW_SHARED);
if (TransactionIdInRecentPast(fxid, &xid)) if (TransactionIdInRecentPast(fxid, &xid))
{ {
Assert(TransactionIdIsValid(xid)); Assert(TransactionIdIsValid(xid));
...@@ -706,7 +706,7 @@ pg_xact_status(PG_FUNCTION_ARGS) ...@@ -706,7 +706,7 @@ pg_xact_status(PG_FUNCTION_ARGS)
{ {
status = NULL; status = NULL;
} }
LWLockRelease(CLogTruncationLock); LWLockRelease(XactTruncationLock);
if (status == NULL) if (status == NULL)
PG_RETURN_NULL(); PG_RETURN_NULL();
......
...@@ -75,7 +75,7 @@ static const char *excludeDirContents[] = ...@@ -75,7 +75,7 @@ static const char *excludeDirContents[] =
/* /*
* Old contents are loaded for possible debugging but are not required for * Old contents are loaded for possible debugging but are not required for
* normal operation, see OldSerXidInit(). * normal operation, see SerialInit().
*/ */
"pg_serial", "pg_serial",
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
#define MaxMultiXactOffset ((MultiXactOffset) 0xFFFFFFFF) #define MaxMultiXactOffset ((MultiXactOffset) 0xFFFFFFFF)
/* Number of SLRU buffers to use for multixact */ /* Number of SLRU buffers to use for multixact */
#define NUM_MXACTOFFSET_BUFFERS 8 #define NUM_MULTIXACTOFFSET_BUFFERS 8
#define NUM_MXACTMEMBER_BUFFERS 16 #define NUM_MULTIXACTMEMBER_BUFFERS 16
/* /*
* Possible multixact lock modes ("status"). The first four modes are for * Possible multixact lock modes ("status"). The first four modes are for
......
...@@ -197,7 +197,7 @@ typedef struct VariableCacheData ...@@ -197,7 +197,7 @@ typedef struct VariableCacheData
* aborted */ * aborted */
/* /*
* These fields are protected by CLogTruncationLock * These fields are protected by XactTruncationLock
*/ */
TransactionId oldestClogXid; /* oldest it's safe to look up in clog */ TransactionId oldestClogXid; /* oldest it's safe to look up in clog */
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
/* /*
* The number of SLRU page buffers we use for the notification queue. * The number of SLRU page buffers we use for the notification queue.
*/ */
#define NUM_ASYNC_BUFFERS 8 #define NUM_NOTIFY_BUFFERS 8
extern bool Trace_notify; extern bool Trace_notify;
extern volatile sig_atomic_t notifyInterruptPending; extern volatile sig_atomic_t notifyInterruptPending;
......
...@@ -195,13 +195,13 @@ extern void LWLockInitialize(LWLock *lock, int tranche_id); ...@@ -195,13 +195,13 @@ extern void LWLockInitialize(LWLock *lock, int tranche_id);
*/ */
typedef enum BuiltinTrancheIds typedef enum BuiltinTrancheIds
{ {
LWTRANCHE_CLOG_BUFFERS = NUM_INDIVIDUAL_LWLOCKS, LWTRANCHE_XACT_BUFFER = NUM_INDIVIDUAL_LWLOCKS,
LWTRANCHE_COMMITTS_BUFFERS, LWTRANCHE_COMMITTS_BUFFER,
LWTRANCHE_SUBTRANS_BUFFERS, LWTRANCHE_SUBTRANS_BUFFER,
LWTRANCHE_MXACTOFFSET_BUFFERS, LWTRANCHE_MULTIXACTOFFSET_BUFFER,
LWTRANCHE_MXACTMEMBER_BUFFERS, LWTRANCHE_MULTIXACTMEMBER_BUFFER,
LWTRANCHE_ASYNC_BUFFERS, LWTRANCHE_NOTIFY_BUFFER,
LWTRANCHE_OLDSERXID_BUFFERS, LWTRANCHE_SERIAL_BUFFER,
LWTRANCHE_WAL_INSERT, LWTRANCHE_WAL_INSERT,
LWTRANCHE_BUFFER_CONTENT, LWTRANCHE_BUFFER_CONTENT,
LWTRANCHE_BUFFER_IO_IN_PROGRESS, LWTRANCHE_BUFFER_IO_IN_PROGRESS,
......
...@@ -27,8 +27,8 @@ extern int max_predicate_locks_per_relation; ...@@ -27,8 +27,8 @@ extern int max_predicate_locks_per_relation;
extern int max_predicate_locks_per_page; extern int max_predicate_locks_per_page;
/* Number of SLRU buffers to use for predicate locking */ /* Number of SLRU buffers to use for Serial SLRU */
#define NUM_OLDSERXID_BUFFERS 16 #define NUM_SERIAL_BUFFERS 16
/* /*
* A handle used for sharing SERIALIZABLEXACT objects between the participants * A handle used for sharing SERIALIZABLEXACT objects between the participants
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment