Skip to content

Commit fc69509

Browse files
author
Amit Kapila
committed
Fix tests for replication slots stats.
Some of the tests were not considering that the slot's spill stats could be received by the stats collector after we have reset the stats. Remove those tests and don't check total bytes decoded and sent to output plugin in the spilled stats test as we can send the spilled stats to the stats collector before actually sending the changes to output plugin. Reported-by: Tom Lane as per buildfarm Author: Vignesh C, Sawada Masahiko Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/20210319185247.ldebgpdaxsowiflw@alap3.anarazel.de
1 parent b35f827 commit fc69509

File tree

2 files changed

+5
-53
lines changed

2 files changed

+5
-53
lines changed

contrib/test_decoding/expected/stats.out

+4-42
Original file line numberDiff line numberDiff line change
@@ -111,48 +111,10 @@ SELECT wait_for_decode_stats(false, true);
111111

112112
(1 row)
113113

114-
SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count, total_txns > 0 AS total_txns, total_bytes > 0 AS total_bytes FROM pg_stat_replication_slots;
115-
slot_name | spill_txns | spill_count | total_txns | total_bytes
116-
-----------------------+------------+-------------+------------+-------------
117-
regression_slot_stats | t | t | t | t
118-
(1 row)
119-
120-
-- reset the slot stats, and wait for stats collector to reset
121-
SELECT pg_stat_reset_replication_slot('regression_slot_stats');
122-
pg_stat_reset_replication_slot
123-
--------------------------------
124-
125-
(1 row)
126-
127-
SELECT wait_for_decode_stats(true, true);
128-
wait_for_decode_stats
129-
-----------------------
130-
131-
(1 row)
132-
133-
SELECT slot_name, spill_txns, spill_count, total_txns, total_bytes FROM pg_stat_replication_slots;
134-
slot_name | spill_txns | spill_count | total_txns | total_bytes
135-
-----------------------+------------+-------------+------------+-------------
136-
regression_slot_stats | 0 | 0 | 0 | 0
137-
(1 row)
138-
139-
-- decode and check stats again.
140-
SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot_stats', NULL, NULL, 'skip-empty-xacts', '1');
141-
count
142-
-------
143-
5002
144-
(1 row)
145-
146-
SELECT wait_for_decode_stats(false, true);
147-
wait_for_decode_stats
148-
-----------------------
149-
150-
(1 row)
151-
152-
SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count, total_txns > 0 AS total_txns, total_bytes > 0 AS total_bytes FROM pg_stat_replication_slots;
153-
slot_name | spill_txns | spill_count | total_txns | total_bytes
154-
-----------------------+------------+-------------+------------+-------------
155-
regression_slot_stats | t | t | t | t
114+
SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
115+
slot_name | spill_txns | spill_count
116+
-----------------------+------------+-------------
117+
regression_slot_stats | t | t
156118
(1 row)
157119

158120
-- Ensure stats can be repeatedly accessed using the same stats snapshot. See

contrib/test_decoding/sql/stats.sql

+1-11
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,7 @@ SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot_stats', NULL,
7373
-- exact stats count as that can vary if any background transaction (say by
7474
-- autovacuum) happens in parallel to the main transaction.
7575
SELECT wait_for_decode_stats(false, true);
76-
SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count, total_txns > 0 AS total_txns, total_bytes > 0 AS total_bytes FROM pg_stat_replication_slots;
77-
78-
-- reset the slot stats, and wait for stats collector to reset
79-
SELECT pg_stat_reset_replication_slot('regression_slot_stats');
80-
SELECT wait_for_decode_stats(true, true);
81-
SELECT slot_name, spill_txns, spill_count, total_txns, total_bytes FROM pg_stat_replication_slots;
82-
83-
-- decode and check stats again.
84-
SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot_stats', NULL, NULL, 'skip-empty-xacts', '1');
85-
SELECT wait_for_decode_stats(false, true);
86-
SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count, total_txns > 0 AS total_txns, total_bytes > 0 AS total_bytes FROM pg_stat_replication_slots;
76+
SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
8777

8878
-- Ensure stats can be repeatedly accessed using the same stats snapshot. See
8979
-- https://postgr.es/m/20210317230447.c7uc4g3vbs4wi32i%40alap3.anarazel.de

0 commit comments

Comments
 (0)