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

Appearance settings

Commit 2c8dd05

Browse filesBrowse files
committed
Make pg_stat_wal_receiver consistent with the WAL receiver's shmem info
d140f2f has renamed receivedUpto to flushedUpto, and has added writtenUpto to the WAL receiver's shared memory information, but pg_stat_wal_receiver was not consistent with that. This commit renames received_lsn to flushed_lsn, and adds a new column called written_lsn. Bump catalog version. Author: Michael Paquier Reviewed-by: Álvaro Herrera Discussion: https://postgr.es/m/20200515090817.GA212736@paquier.xyz
1 parent e78b930 commit 2c8dd05
Copy full SHA for 2c8dd05

File tree

Expand file treeCollapse file tree

6 files changed

+47
-29
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+47
-29
lines changed

‎doc/src/sgml/monitoring.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/monitoring.sgml
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,17 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
25412541

25422542
<row>
25432543
<entry role="catalog_table_entry"><para role="column_definition">
2544-
<structfield>received_lsn</structfield> <type>pg_lsn</type>
2544+
<structfield>written_lsn</structfield> <type>pg_lsn</type>
2545+
</para>
2546+
<para>
2547+
Last write-ahead log location already received and written to disk,
2548+
but not flushed. This should not be used for data integrity checks.
2549+
</para></entry>
2550+
</row>
2551+
2552+
<row>
2553+
<entry role="catalog_table_entry"><para role="column_definition">
2554+
<structfield>flushed_lsn</structfield> <type>pg_lsn</type>
25452555
</para>
25462556
<para>
25472557
Last write-ahead log location already received and flushed to

‎src/backend/catalog/system_views.sql

Copy file name to clipboardExpand all lines: src/backend/catalog/system_views.sql
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,8 @@ CREATE VIEW pg_stat_wal_receiver AS
812812
s.status,
813813
s.receive_start_lsn,
814814
s.receive_start_tli,
815-
s.received_lsn,
815+
s.written_lsn,
816+
s.flushed_lsn,
816817
s.received_tli,
817818
s.last_msg_send_time,
818819
s.last_msg_receipt_time,

‎src/backend/replication/walreceiver.c

Copy file name to clipboardExpand all lines: src/backend/replication/walreceiver.c
+27-21Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,8 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
13481348
WalRcvState state;
13491349
XLogRecPtr receive_start_lsn;
13501350
TimeLineID receive_start_tli;
1351-
XLogRecPtr received_lsn;
1351+
XLogRecPtr written_lsn;
1352+
XLogRecPtr flushed_lsn;
13521353
TimeLineID received_tli;
13531354
TimestampTz last_send_time;
13541355
TimestampTz last_receipt_time;
@@ -1366,7 +1367,8 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
13661367
state = WalRcv->walRcvState;
13671368
receive_start_lsn = WalRcv->receiveStart;
13681369
receive_start_tli = WalRcv->receiveStartTLI;
1369-
received_lsn = WalRcv->flushedUpto;
1370+
written_lsn = pg_atomic_read_u64(&WalRcv->writtenUpto);
1371+
flushed_lsn = WalRcv->flushedUpto;
13701372
received_tli = WalRcv->receivedTLI;
13711373
last_send_time = WalRcv->lastMsgSendTime;
13721374
last_receipt_time = WalRcv->lastMsgReceiptTime;
@@ -1413,43 +1415,47 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
14131415
else
14141416
values[2] = LSNGetDatum(receive_start_lsn);
14151417
values[3] = Int32GetDatum(receive_start_tli);
1416-
if (XLogRecPtrIsInvalid(received_lsn))
1418+
if (XLogRecPtrIsInvalid(written_lsn))
14171419
nulls[4] = true;
14181420
else
1419-
values[4] = LSNGetDatum(received_lsn);
1420-
values[5] = Int32GetDatum(received_tli);
1421+
values[4] = LSNGetDatum(written_lsn);
1422+
if (XLogRecPtrIsInvalid(flushed_lsn))
1423+
nulls[5] = true;
1424+
else
1425+
values[5] = LSNGetDatum(flushed_lsn);
1426+
values[6] = Int32GetDatum(received_tli);
14211427
if (last_send_time == 0)
1422-
nulls[6] = true;
1428+
nulls[7] = true;
14231429
else
1424-
values[6] = TimestampTzGetDatum(last_send_time);
1430+
values[7] = TimestampTzGetDatum(last_send_time);
14251431
if (last_receipt_time == 0)
1426-
nulls[7] = true;
1432+
nulls[8] = true;
14271433
else
1428-
values[7] = TimestampTzGetDatum(last_receipt_time);
1434+
values[8] = TimestampTzGetDatum(last_receipt_time);
14291435
if (XLogRecPtrIsInvalid(latest_end_lsn))
1430-
nulls[8] = true;
1436+
nulls[9] = true;
14311437
else
1432-
values[8] = LSNGetDatum(latest_end_lsn);
1438+
values[9] = LSNGetDatum(latest_end_lsn);
14331439
if (latest_end_time == 0)
1434-
nulls[9] = true;
1440+
nulls[10] = true;
14351441
else
1436-
values[9] = TimestampTzGetDatum(latest_end_time);
1442+
values[10] = TimestampTzGetDatum(latest_end_time);
14371443
if (*slotname == '\0')
1438-
nulls[10] = true;
1444+
nulls[11] = true;
14391445
else
1440-
values[10] = CStringGetTextDatum(slotname);
1446+
values[11] = CStringGetTextDatum(slotname);
14411447
if (*sender_host == '\0')
1442-
nulls[11] = true;
1448+
nulls[12] = true;
14431449
else
1444-
values[11] = CStringGetTextDatum(sender_host);
1450+
values[12] = CStringGetTextDatum(sender_host);
14451451
if (sender_port == 0)
1446-
nulls[12] = true;
1452+
nulls[13] = true;
14471453
else
1448-
values[12] = Int32GetDatum(sender_port);
1454+
values[13] = Int32GetDatum(sender_port);
14491455
if (*conninfo == '\0')
1450-
nulls[13] = true;
1456+
nulls[14] = true;
14511457
else
1452-
values[13] = CStringGetTextDatum(conninfo);
1458+
values[14] = CStringGetTextDatum(conninfo);
14531459
}
14541460

14551461
/* Returns the record as Datum */

‎src/include/catalog/catversion.h

Copy file name to clipboardExpand all lines: src/include/catalog/catversion.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 202005121
56+
#define CATALOG_VERSION_NO 202005171
5757

5858
#endif

‎src/include/catalog/pg_proc.dat

Copy file name to clipboardExpand all lines: src/include/catalog/pg_proc.dat
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5244,9 +5244,9 @@
52445244
{ oid => '3317', descr => 'statistics: information about WAL receiver',
52455245
proname => 'pg_stat_get_wal_receiver', proisstrict => 'f', provolatile => 's',
52465246
proparallel => 'r', prorettype => 'record', proargtypes => '',
5247-
proallargtypes => '{int4,text,pg_lsn,int4,pg_lsn,int4,timestamptz,timestamptz,pg_lsn,timestamptz,text,text,int4,text}',
5248-
proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
5249-
proargnames => '{pid,status,receive_start_lsn,receive_start_tli,received_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
5247+
proallargtypes => '{int4,text,pg_lsn,int4,pg_lsn,pg_lsn,int4,timestamptz,timestamptz,pg_lsn,timestamptz,text,text,int4,text}',
5248+
proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
5249+
proargnames => '{pid,status,receive_start_lsn,receive_start_tli,written_lsn,flushed_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
52505250
prosrc => 'pg_stat_get_wal_receiver' },
52515251
{ oid => '6118', descr => 'statistics: information about subscription',
52525252
proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',

‎src/test/regress/expected/rules.out

Copy file name to clipboardExpand all lines: src/test/regress/expected/rules.out
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,7 +2124,8 @@ pg_stat_wal_receiver| SELECT s.pid,
21242124
s.status,
21252125
s.receive_start_lsn,
21262126
s.receive_start_tli,
2127-
s.received_lsn,
2127+
s.written_lsn,
2128+
s.flushed_lsn,
21282129
s.received_tli,
21292130
s.last_msg_send_time,
21302131
s.last_msg_receipt_time,
@@ -2134,7 +2135,7 @@ pg_stat_wal_receiver| SELECT s.pid,
21342135
s.sender_host,
21352136
s.sender_port,
21362137
s.conninfo
2137-
FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, received_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time, slot_name, sender_host, sender_port, conninfo)
2138+
FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, written_lsn, flushed_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time, slot_name, sender_host, sender_port, conninfo)
21382139
WHERE (s.pid IS NOT NULL);
21392140
pg_stat_xact_all_tables| SELECT c.oid AS relid,
21402141
n.nspname AS schemaname,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.