Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9868167

Browse files
author
Amit Kapila
committed
Track statistics for spilling of changes from ReorderBuffer.
This adds the statistics about transactions spilled to disk fromReorderBuffer. Users can query the pg_stat_replication_slots view to checkthese stats and call pg_stat_reset_replication_slot to reset the stats ofa particular slot. Users can pass NULL in pg_stat_reset_replication_slotto reset stats of all the slots.This commit extends the statistics collector to track this informationabout slots.Author: Sawada Masahiko and Amit KapilaReviewed-by: Amit Kapila and Dilip KumarDiscussion:https://postgr.es/m/CA+fd4k5_pPAYRTDrO2PbtTOe0eHQpBvuqmCr8ic39uTNmR49Eg@mail.gmail.com
1 parent8d2a01a commit9868167

File tree

16 files changed

+700
-8
lines changed

16 files changed

+700
-8
lines changed

‎doc/src/sgml/monitoring.sgml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,15 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
314314
</entry>
315315
</row>
316316

317+
<row>
318+
<entry><structname>pg_stat_replication_slots</structname><indexterm><primary>pg_stat_replication_slots</primary></indexterm></entry>
319+
<entry>One row per replication slot, showing statistics about
320+
replication slot usage.
321+
See <link linkend="monitoring-pg-stat-replication-slots-view">
322+
<structname>pg_stat_replication_slots</structname></link> for details.
323+
</entry>
324+
</row>
325+
317326
<row>
318327
<entry><structname>pg_stat_wal_receiver</structname><indexterm><primary>pg_stat_wal_receiver</primary></indexterm></entry>
319328
<entry>Only one row, showing statistics about the WAL receiver from
@@ -2552,6 +2561,88 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
25522561

25532562
</sect2>
25542563

2564+
<sect2 id="monitoring-pg-stat-replication-slots-view">
2565+
<title><structname>pg_stat_replication_slots</structname></title>
2566+
2567+
<indexterm>
2568+
<primary>pg_stat_replication_slots</primary>
2569+
</indexterm>
2570+
2571+
<para>
2572+
The <structname>pg_stat_replication_slots</structname> view will contain
2573+
one row per logical replication slot, showing statistics about its usage.
2574+
</para>
2575+
2576+
<table id="pg-stat-replication-slots-view" xreflabel="pg_stat_replication_slots">
2577+
<title><structname>pg_stat_replication_slots</structname> View</title>
2578+
<tgroup cols="1">
2579+
<thead>
2580+
<row>
2581+
<entry role="catalog_table_entry"><para role="column_definition">
2582+
Column Type
2583+
</para>
2584+
<para>
2585+
Description
2586+
</para></entry>
2587+
</row>
2588+
</thead>
2589+
2590+
<tbody>
2591+
<row>
2592+
<entry role="catalog_table_entry"><para role="column_definition">
2593+
<structfield>name</structfield> <type>text</type>
2594+
</para>
2595+
<para>
2596+
A unique, cluster-wide identifier for the replication slot
2597+
</para></entry>
2598+
</row>
2599+
2600+
<row>
2601+
<entry role="catalog_table_entry"><para role="column_definition">
2602+
<structfield>spill_txns</structfield> <type>bigint</type>
2603+
</para>
2604+
<para>
2605+
Number of transactions spilled to disk after the memory used by
2606+
logical decoding exceeds <literal>logical_decoding_work_mem</literal>. The
2607+
counter gets incremented both for toplevel transactions and
2608+
subtransactions.
2609+
</para></entry>
2610+
</row>
2611+
2612+
<row>
2613+
<entry role="catalog_table_entry"><para role="column_definition">
2614+
<structfield>spill_count</structfield> <type>bigint</type>
2615+
</para>
2616+
<para>
2617+
Number of times transactions were spilled to disk. Transactions
2618+
may get spilled repeatedly, and this counter gets incremented on every
2619+
such invocation.
2620+
</para></entry>
2621+
</row>
2622+
2623+
<row>
2624+
<entry role="catalog_table_entry"><para role="column_definition">
2625+
<structfield>spill_bytes</structfield> <type>bigint</type>
2626+
</para>
2627+
<para>
2628+
Amount of decoded transaction data spilled to disk.
2629+
</para></entry>
2630+
</row>
2631+
2632+
<row>
2633+
<entry role="catalog_table_entry"><para role="column_definition">
2634+
<structfield>stats_reset</structfield> <type>timestamp with time zone</type>
2635+
</para>
2636+
<para>
2637+
Time at which these statistics were last reset
2638+
</para></entry>
2639+
</row>
2640+
</tbody>
2641+
</tgroup>
2642+
</table>
2643+
2644+
</sect2>
2645+
25552646
<sect2 id="monitoring-pg-stat-wal-receiver-view">
25562647
<title><structname>pg_stat_wal_receiver</structname></title>
25572648

@@ -4802,6 +4893,27 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
48024893
can be granted EXECUTE to run the function.
48034894
</para></entry>
48044895
</row>
4896+
4897+
<row>
4898+
<entry role="func_table_entry"><para role="func_signature">
4899+
<indexterm>
4900+
<primary>pg_stat_reset_replication_slot</primary>
4901+
</indexterm>
4902+
<function>pg_stat_reset_replication_slot</function> ( <type>text</type> )
4903+
<returnvalue>void</returnvalue>
4904+
</para>
4905+
<para>
4906+
Resets statistics to zero for a single replication slot, or for all
4907+
replication slots in the cluster. The argument can be either the name
4908+
of the slot to reset the stats or NULL. If the argument is NULL, all
4909+
counters shown in the <structname>pg_stat_replication_slots</structname>
4910+
view for all replication slots are reset.
4911+
</para>
4912+
<para>
4913+
This function is restricted to superusers by default, but other users
4914+
can be granted EXECUTE to run the function.
4915+
</para></entry>
4916+
</row>
48054917
</tbody>
48064918
</tgroup>
48074919
</table>

‎src/backend/catalog/system_views.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,15 @@ CREATE VIEW pg_stat_replication AS
796796
JOIN pg_stat_get_wal_senders()AS WON (S.pid=W.pid)
797797
LEFT JOIN pg_authidAS UON (S.usesysid=U.oid);
798798

799+
CREATEVIEWpg_stat_replication_slotsAS
800+
SELECT
801+
s.name,
802+
s.spill_txns,
803+
s.spill_count,
804+
s.spill_bytes,
805+
s.stats_reset
806+
FROM pg_stat_get_replication_slots()AS s;
807+
799808
CREATEVIEWpg_stat_slruAS
800809
SELECT
801810
s.name,
@@ -1453,6 +1462,7 @@ REVOKE EXECUTE ON FUNCTION pg_stat_reset_shared(text) FROM public;
14531462
REVOKE EXECUTEON FUNCTION pg_stat_reset_slru(text)FROM public;
14541463
REVOKE EXECUTEON FUNCTION pg_stat_reset_single_table_counters(oid)FROM public;
14551464
REVOKE EXECUTEON FUNCTION pg_stat_reset_single_function_counters(oid)FROM public;
1465+
REVOKE EXECUTEON FUNCTION pg_stat_reset_replication_slot(text)FROM public;
14561466

14571467
REVOKE EXECUTEON FUNCTION lo_import(text)FROM public;
14581468
REVOKE EXECUTEON FUNCTION lo_import(text,oid)FROM public;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp