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