mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
Make pg_stat_wal_receiver consistent with the WAL receiver's shmem info
d140f2f3 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
This commit is contained in:
parent
e78b930945
commit
2c8dd05d6c
@ -2541,7 +2541,17 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
|||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry role="catalog_table_entry"><para role="column_definition">
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
<structfield>received_lsn</structfield> <type>pg_lsn</type>
|
<structfield>written_lsn</structfield> <type>pg_lsn</type>
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Last write-ahead log location already received and written to disk,
|
||||||
|
but not flushed. This should not be used for data integrity checks.
|
||||||
|
</para></entry>
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
|
<structfield>flushed_lsn</structfield> <type>pg_lsn</type>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Last write-ahead log location already received and flushed to
|
Last write-ahead log location already received and flushed to
|
||||||
|
@ -812,7 +812,8 @@ CREATE VIEW pg_stat_wal_receiver AS
|
|||||||
s.status,
|
s.status,
|
||||||
s.receive_start_lsn,
|
s.receive_start_lsn,
|
||||||
s.receive_start_tli,
|
s.receive_start_tli,
|
||||||
s.received_lsn,
|
s.written_lsn,
|
||||||
|
s.flushed_lsn,
|
||||||
s.received_tli,
|
s.received_tli,
|
||||||
s.last_msg_send_time,
|
s.last_msg_send_time,
|
||||||
s.last_msg_receipt_time,
|
s.last_msg_receipt_time,
|
||||||
|
@ -1348,7 +1348,8 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
|
|||||||
WalRcvState state;
|
WalRcvState state;
|
||||||
XLogRecPtr receive_start_lsn;
|
XLogRecPtr receive_start_lsn;
|
||||||
TimeLineID receive_start_tli;
|
TimeLineID receive_start_tli;
|
||||||
XLogRecPtr received_lsn;
|
XLogRecPtr written_lsn;
|
||||||
|
XLogRecPtr flushed_lsn;
|
||||||
TimeLineID received_tli;
|
TimeLineID received_tli;
|
||||||
TimestampTz last_send_time;
|
TimestampTz last_send_time;
|
||||||
TimestampTz last_receipt_time;
|
TimestampTz last_receipt_time;
|
||||||
@ -1366,7 +1367,8 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
|
|||||||
state = WalRcv->walRcvState;
|
state = WalRcv->walRcvState;
|
||||||
receive_start_lsn = WalRcv->receiveStart;
|
receive_start_lsn = WalRcv->receiveStart;
|
||||||
receive_start_tli = WalRcv->receiveStartTLI;
|
receive_start_tli = WalRcv->receiveStartTLI;
|
||||||
received_lsn = WalRcv->flushedUpto;
|
written_lsn = pg_atomic_read_u64(&WalRcv->writtenUpto);
|
||||||
|
flushed_lsn = WalRcv->flushedUpto;
|
||||||
received_tli = WalRcv->receivedTLI;
|
received_tli = WalRcv->receivedTLI;
|
||||||
last_send_time = WalRcv->lastMsgSendTime;
|
last_send_time = WalRcv->lastMsgSendTime;
|
||||||
last_receipt_time = WalRcv->lastMsgReceiptTime;
|
last_receipt_time = WalRcv->lastMsgReceiptTime;
|
||||||
@ -1413,43 +1415,47 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
|
|||||||
else
|
else
|
||||||
values[2] = LSNGetDatum(receive_start_lsn);
|
values[2] = LSNGetDatum(receive_start_lsn);
|
||||||
values[3] = Int32GetDatum(receive_start_tli);
|
values[3] = Int32GetDatum(receive_start_tli);
|
||||||
if (XLogRecPtrIsInvalid(received_lsn))
|
if (XLogRecPtrIsInvalid(written_lsn))
|
||||||
nulls[4] = true;
|
nulls[4] = true;
|
||||||
else
|
else
|
||||||
values[4] = LSNGetDatum(received_lsn);
|
values[4] = LSNGetDatum(written_lsn);
|
||||||
values[5] = Int32GetDatum(received_tli);
|
if (XLogRecPtrIsInvalid(flushed_lsn))
|
||||||
if (last_send_time == 0)
|
nulls[5] = true;
|
||||||
nulls[6] = true;
|
|
||||||
else
|
else
|
||||||
values[6] = TimestampTzGetDatum(last_send_time);
|
values[5] = LSNGetDatum(flushed_lsn);
|
||||||
if (last_receipt_time == 0)
|
values[6] = Int32GetDatum(received_tli);
|
||||||
|
if (last_send_time == 0)
|
||||||
nulls[7] = true;
|
nulls[7] = true;
|
||||||
else
|
else
|
||||||
values[7] = TimestampTzGetDatum(last_receipt_time);
|
values[7] = TimestampTzGetDatum(last_send_time);
|
||||||
if (XLogRecPtrIsInvalid(latest_end_lsn))
|
if (last_receipt_time == 0)
|
||||||
nulls[8] = true;
|
nulls[8] = true;
|
||||||
else
|
else
|
||||||
values[8] = LSNGetDatum(latest_end_lsn);
|
values[8] = TimestampTzGetDatum(last_receipt_time);
|
||||||
if (latest_end_time == 0)
|
if (XLogRecPtrIsInvalid(latest_end_lsn))
|
||||||
nulls[9] = true;
|
nulls[9] = true;
|
||||||
else
|
else
|
||||||
values[9] = TimestampTzGetDatum(latest_end_time);
|
values[9] = LSNGetDatum(latest_end_lsn);
|
||||||
if (*slotname == '\0')
|
if (latest_end_time == 0)
|
||||||
nulls[10] = true;
|
nulls[10] = true;
|
||||||
else
|
else
|
||||||
values[10] = CStringGetTextDatum(slotname);
|
values[10] = TimestampTzGetDatum(latest_end_time);
|
||||||
if (*sender_host == '\0')
|
if (*slotname == '\0')
|
||||||
nulls[11] = true;
|
nulls[11] = true;
|
||||||
else
|
else
|
||||||
values[11] = CStringGetTextDatum(sender_host);
|
values[11] = CStringGetTextDatum(slotname);
|
||||||
if (sender_port == 0)
|
if (*sender_host == '\0')
|
||||||
nulls[12] = true;
|
nulls[12] = true;
|
||||||
else
|
else
|
||||||
values[12] = Int32GetDatum(sender_port);
|
values[12] = CStringGetTextDatum(sender_host);
|
||||||
if (*conninfo == '\0')
|
if (sender_port == 0)
|
||||||
nulls[13] = true;
|
nulls[13] = true;
|
||||||
else
|
else
|
||||||
values[13] = CStringGetTextDatum(conninfo);
|
values[13] = Int32GetDatum(sender_port);
|
||||||
|
if (*conninfo == '\0')
|
||||||
|
nulls[14] = true;
|
||||||
|
else
|
||||||
|
values[14] = CStringGetTextDatum(conninfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the record as Datum */
|
/* Returns the record as Datum */
|
||||||
|
@ -53,6 +53,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* yyyymmddN */
|
/* yyyymmddN */
|
||||||
#define CATALOG_VERSION_NO 202005121
|
#define CATALOG_VERSION_NO 202005171
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -5244,9 +5244,9 @@
|
|||||||
{ oid => '3317', descr => 'statistics: information about WAL receiver',
|
{ oid => '3317', descr => 'statistics: information about WAL receiver',
|
||||||
proname => 'pg_stat_get_wal_receiver', proisstrict => 'f', provolatile => 's',
|
proname => 'pg_stat_get_wal_receiver', proisstrict => 'f', provolatile => 's',
|
||||||
proparallel => 'r', prorettype => 'record', proargtypes => '',
|
proparallel => 'r', prorettype => 'record', proargtypes => '',
|
||||||
proallargtypes => '{int4,text,pg_lsn,int4,pg_lsn,int4,timestamptz,timestamptz,pg_lsn,timestamptz,text,text,int4,text}',
|
proallargtypes => '{int4,text,pg_lsn,int4,pg_lsn,pg_lsn,int4,timestamptz,timestamptz,pg_lsn,timestamptz,text,text,int4,text}',
|
||||||
proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
|
proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
|
||||||
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}',
|
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}',
|
||||||
prosrc => 'pg_stat_get_wal_receiver' },
|
prosrc => 'pg_stat_get_wal_receiver' },
|
||||||
{ oid => '6118', descr => 'statistics: information about subscription',
|
{ oid => '6118', descr => 'statistics: information about subscription',
|
||||||
proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',
|
proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',
|
||||||
|
@ -2124,7 +2124,8 @@ pg_stat_wal_receiver| SELECT s.pid,
|
|||||||
s.status,
|
s.status,
|
||||||
s.receive_start_lsn,
|
s.receive_start_lsn,
|
||||||
s.receive_start_tli,
|
s.receive_start_tli,
|
||||||
s.received_lsn,
|
s.written_lsn,
|
||||||
|
s.flushed_lsn,
|
||||||
s.received_tli,
|
s.received_tli,
|
||||||
s.last_msg_send_time,
|
s.last_msg_send_time,
|
||||||
s.last_msg_receipt_time,
|
s.last_msg_receipt_time,
|
||||||
@ -2134,7 +2135,7 @@ pg_stat_wal_receiver| SELECT s.pid,
|
|||||||
s.sender_host,
|
s.sender_host,
|
||||||
s.sender_port,
|
s.sender_port,
|
||||||
s.conninfo
|
s.conninfo
|
||||||
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)
|
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)
|
||||||
WHERE (s.pid IS NOT NULL);
|
WHERE (s.pid IS NOT NULL);
|
||||||
pg_stat_xact_all_tables| SELECT c.oid AS relid,
|
pg_stat_xact_all_tables| SELECT c.oid AS relid,
|
||||||
n.nspname AS schemaname,
|
n.nspname AS schemaname,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user