Rename SLRU elements in view pg_stat_slru

The new names are intended to match those in an upcoming patch that adds
a few GUCs to configure the SLRU buffer sizes.

Backwards compatibility concern: this changes the accepted names for
function pg_stat_slru_rest().  Since this function recognizes "any other
string" as a request to reset the entry for "other", this means that
calling it with the old names would silently reset "other" instead of
doing nothing or throwing an error.

Reviewed-by: Andrey M. Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/202402261616.dlriae7b6emv@alvherre.pgsql
This commit is contained in:
Alvaro Herrera 2024-02-28 09:39:52 +01:00
parent 48920476b4
commit bcdfa5f2e2
No known key found for this signature in database
GPG Key ID: 1C20ACB9D5C564AE
13 changed files with 81 additions and 81 deletions

View File

@ -4853,13 +4853,13 @@ description | Waiting for a newly initialized WAL file to reach durable storage
<literal>NULL</literal> or is not specified, all the counters shown in
the <structname>pg_stat_slru</structname> view for all SLRU caches are
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>
<literal>commit_timestamp</literal>,
<literal>multixact_member</literal>,
<literal>multixact_offset</literal>,
<literal>notify</literal>,
<literal>serializable</literal>,
<literal>subtransaction</literal>, or
<literal>transaction</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

View File

@ -706,7 +706,7 @@ void
CLOGShmemInit(void)
{
XactCtl->PagePrecedes = CLOGPagePrecedes;
SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
SimpleLruInit(XactCtl, "transaction", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
SYNC_HANDLER_CLOG, false);
SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);

View File

@ -529,7 +529,7 @@ CommitTsShmemInit(void)
bool found;
CommitTsCtl->PagePrecedes = CommitTsPagePrecedes;
SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
SimpleLruInit(CommitTsCtl, "commit_timestamp", CommitTsShmemBuffers(), 0,
CommitTsSLRULock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFER,
SYNC_HANDLER_COMMIT_TS,

View File

@ -1851,14 +1851,14 @@ MultiXactShmemInit(void)
MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
SimpleLruInit(MultiXactOffsetCtl,
"MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
"multixact_offset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
MultiXactOffsetSLRULock, "pg_multixact/offsets",
LWTRANCHE_MULTIXACTOFFSET_BUFFER,
SYNC_HANDLER_MULTIXACT_OFFSET,
false);
SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
SimpleLruInit(MultiXactMemberCtl,
"MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
"multixact_member", NUM_MULTIXACTMEMBER_BUFFERS, 0,
MultiXactMemberSLRULock, "pg_multixact/members",
LWTRANCHE_MULTIXACTMEMBER_BUFFER,
SYNC_HANDLER_MULTIXACT_MEMBER,

View File

@ -200,7 +200,7 @@ void
SUBTRANSShmemInit(void)
{
SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
SimpleLruInit(SubTransCtl, "subtransaction", NUM_SUBTRANS_BUFFERS, 0,
SubtransSLRULock, "pg_subtrans",
LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE,
false);

View File

@ -541,7 +541,7 @@ AsyncShmemInit(void)
* names are used in order to avoid wraparound.
*/
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
SimpleLruInit(NotifyCtl, "notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
SYNC_HANDLER_NONE, true);

View File

@ -812,7 +812,7 @@ SerialInit(void)
* Set up SLRU management of the pg_serial data.
*/
SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
SimpleLruInit(SerialSlruCtl, "Serial",
SimpleLruInit(SerialSlruCtl, "serializable",
NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE,
false);

View File

@ -269,13 +269,13 @@ typedef struct PgStat_KindInfo
* definitions.
*/
static const char *const slru_names[] = {
"CommitTs",
"MultiXactMember",
"MultiXactOffset",
"Notify",
"Serial",
"Subtrans",
"Xact",
"commit_timestamp",
"multixact_member",
"multixact_offset",
"notify",
"serializable",
"subtransaction",
"transaction",
"other" /* has to be last */
};

View File

@ -3039,8 +3039,8 @@ pg_stat_force_next_flush
(1 row)
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3093,8 +3093,8 @@ pg_stat_force_next_flush
(1 row)
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s2_big_notify: SELECT pg_notify('stats_test_use',
@ -3133,8 +3133,8 @@ pg_stat_force_next_flush
(1 row)
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s2_begin: BEGIN;
@ -3176,8 +3176,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_none: SET stats_fetch_consistency = 'none';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3243,8 +3243,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_cache: SET stats_fetch_consistency = 'cache';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3310,8 +3310,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_snapshot: SET stats_fetch_consistency = 'snapshot';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3377,8 +3377,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_none: SET stats_fetch_consistency = 'none';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3450,8 +3450,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_cache: SET stats_fetch_consistency = 'cache';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3523,8 +3523,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_snapshot: SET stats_fetch_consistency = 'snapshot';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3596,8 +3596,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_snapshot: SET stats_fetch_consistency = 'snapshot';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3653,8 +3653,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_snapshot: SET stats_fetch_consistency = 'snapshot';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;

View File

@ -3063,8 +3063,8 @@ pg_stat_force_next_flush
(1 row)
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3117,8 +3117,8 @@ pg_stat_force_next_flush
(1 row)
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s2_big_notify: SELECT pg_notify('stats_test_use',
@ -3157,8 +3157,8 @@ pg_stat_force_next_flush
(1 row)
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s2_begin: BEGIN;
@ -3200,8 +3200,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_none: SET stats_fetch_consistency = 'none';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3267,8 +3267,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_cache: SET stats_fetch_consistency = 'cache';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3334,8 +3334,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_snapshot: SET stats_fetch_consistency = 'snapshot';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3401,8 +3401,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_none: SET stats_fetch_consistency = 'none';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3474,8 +3474,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_cache: SET stats_fetch_consistency = 'cache';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3547,8 +3547,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_snapshot: SET stats_fetch_consistency = 'snapshot';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3620,8 +3620,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_snapshot: SET stats_fetch_consistency = 'snapshot';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;
@ -3677,8 +3677,8 @@ pg_stat_force_next_flush
step s1_fetch_consistency_snapshot: SET stats_fetch_consistency = 'snapshot';
step s1_slru_save_stats:
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
step s1_listen: LISTEN stats_test_nothing;
step s1_begin: BEGIN;

View File

@ -107,8 +107,8 @@ step s1_table_stats {
# SLRU stats steps
step s1_slru_save_stats {
INSERT INTO test_slru_stats VALUES('Notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'Notify'));
INSERT INTO test_slru_stats VALUES('notify', 'blks_zeroed',
(SELECT blks_zeroed FROM pg_stat_slru WHERE name = 'notify'));
}
step s1_listen { LISTEN stats_test_nothing; }
step s1_big_notify { SELECT pg_notify('stats_test_use',

View File

@ -866,21 +866,21 @@ WHERE pg_stat_get_backend_pid(beid) = pg_backend_pid();
-- Test that resetting stats works for reset timestamp
-----
-- Test that reset_slru with a specified SLRU works.
SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'CommitTs' \gset
SELECT stats_reset AS slru_notify_reset_ts FROM pg_stat_slru WHERE name = 'Notify' \gset
SELECT pg_stat_reset_slru('CommitTs');
SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp' \gset
SELECT stats_reset AS slru_notify_reset_ts FROM pg_stat_slru WHERE name = 'notify' \gset
SELECT pg_stat_reset_slru('commit_timestamp');
pg_stat_reset_slru
--------------------
(1 row)
SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'CommitTs';
SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'commit_timestamp';
?column?
----------
t
(1 row)
SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'CommitTs' \gset
SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp' \gset
-- Test that multiple SLRUs are reset when no specific SLRU provided to reset function
SELECT pg_stat_reset_slru();
pg_stat_reset_slru
@ -888,13 +888,13 @@ SELECT pg_stat_reset_slru();
(1 row)
SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'CommitTs';
SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'commit_timestamp';
?column?
----------
t
(1 row)
SELECT stats_reset > :'slru_notify_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'Notify';
SELECT stats_reset > :'slru_notify_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'notify';
?column?
----------
t

View File

@ -447,16 +447,16 @@ WHERE pg_stat_get_backend_pid(beid) = pg_backend_pid();
-----
-- Test that reset_slru with a specified SLRU works.
SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'CommitTs' \gset
SELECT stats_reset AS slru_notify_reset_ts FROM pg_stat_slru WHERE name = 'Notify' \gset
SELECT pg_stat_reset_slru('CommitTs');
SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'CommitTs';
SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'CommitTs' \gset
SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp' \gset
SELECT stats_reset AS slru_notify_reset_ts FROM pg_stat_slru WHERE name = 'notify' \gset
SELECT pg_stat_reset_slru('commit_timestamp');
SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'commit_timestamp';
SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp' \gset
-- Test that multiple SLRUs are reset when no specific SLRU provided to reset function
SELECT pg_stat_reset_slru();
SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'CommitTs';
SELECT stats_reset > :'slru_notify_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'Notify';
SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'commit_timestamp';
SELECT stats_reset > :'slru_notify_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'notify';
-- Test that reset_shared with archiver specified as the stats type works
SELECT stats_reset AS archiver_reset_ts FROM pg_stat_archiver \gset