Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1124c0c

Browse files
committed
Add replication_lag view
1 parent 9648113 commit 1124c0c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pg_shardman--1.0.sql

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ CREATE TABLE replicas (
4646
PRIMARY KEY (part_name,node_id)
4747
);
4848

49+
-- View for monitoring replication lag
50+
CREATE VIEW replication_lag(pubnode, subnode, lag) AS
51+
SELECT src.id AS srcnode, dst.id AS dstnode,
52+
shardman.broadcast(format('%s:SELECT pg_current_wal_lsn() - confirmed_flush_lsn FROM pg_replication_slots WHERE slot_name=''node_%s'';',
53+
src.id, dst.id))::bigint AS lag
54+
FROM shardman.nodes src, shardman.nodes dst WHERE src.id<>dst.id;
55+
4956
-- Shardman interface functions
5057

5158
-- Add a node: adjust logical replication channels in replication group and
@@ -1076,8 +1083,6 @@ BEGIN
10761083
END
10771084
$$ LANGUAGE plpgsql;
10781085

1079-
1080-
10811086
---------------------------------------------------------------------
10821087
-- Utility functions
10831088
---------------------------------------------------------------------

0 commit comments

Comments
 (0)