From fc69509131c33c298e39dd25d542374e86aa3295 Mon Sep 17 00:00:00 2001 From: Amit Kapila Date: Thu, 13 May 2021 10:14:07 +0530 Subject: [PATCH] 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 --- contrib/test_decoding/expected/stats.out | 46 +++--------------------- contrib/test_decoding/sql/stats.sql | 12 +------ 2 files changed, 5 insertions(+), 53 deletions(-) diff --git a/contrib/test_decoding/expected/stats.out b/contrib/test_decoding/expected/stats.out index 7d174ee8d28..206c0a126e5 100644 --- a/contrib/test_decoding/expected/stats.out +++ b/contrib/test_decoding/expected/stats.out @@ -111,48 +111,10 @@ SELECT wait_for_decode_stats(false, true); (1 row) -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; - slot_name | spill_txns | spill_count | total_txns | total_bytes ------------------------+------------+-------------+------------+------------- - regression_slot_stats | t | t | t | t -(1 row) - --- reset the slot stats, and wait for stats collector to reset -SELECT pg_stat_reset_replication_slot('regression_slot_stats'); - pg_stat_reset_replication_slot --------------------------------- - -(1 row) - -SELECT wait_for_decode_stats(true, true); - wait_for_decode_stats ------------------------ - -(1 row) - -SELECT slot_name, spill_txns, spill_count, total_txns, total_bytes FROM pg_stat_replication_slots; - slot_name | spill_txns | spill_count | total_txns | total_bytes ------------------------+------------+-------------+------------+------------- - regression_slot_stats | 0 | 0 | 0 | 0 -(1 row) - --- decode and check stats again. -SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot_stats', NULL, NULL, 'skip-empty-xacts', '1'); - count -------- - 5002 -(1 row) - -SELECT wait_for_decode_stats(false, true); - wait_for_decode_stats ------------------------ - -(1 row) - -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; - slot_name | spill_txns | spill_count | total_txns | total_bytes ------------------------+------------+-------------+------------+------------- - regression_slot_stats | t | t | t | t +SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots; + slot_name | spill_txns | spill_count +-----------------------+------------+------------- + regression_slot_stats | t | t (1 row) -- Ensure stats can be repeatedly accessed using the same stats snapshot. See diff --git a/contrib/test_decoding/sql/stats.sql b/contrib/test_decoding/sql/stats.sql index 263568b00ce..67462ca27f7 100644 --- a/contrib/test_decoding/sql/stats.sql +++ b/contrib/test_decoding/sql/stats.sql @@ -73,17 +73,7 @@ SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot_stats', NULL, -- exact stats count as that can vary if any background transaction (say by -- autovacuum) happens in parallel to the main transaction. SELECT wait_for_decode_stats(false, true); -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; - --- reset the slot stats, and wait for stats collector to reset -SELECT pg_stat_reset_replication_slot('regression_slot_stats'); -SELECT wait_for_decode_stats(true, true); -SELECT slot_name, spill_txns, spill_count, total_txns, total_bytes FROM pg_stat_replication_slots; - --- decode and check stats again. -SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot_stats', NULL, NULL, 'skip-empty-xacts', '1'); -SELECT wait_for_decode_stats(false, true); -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; +SELECT slot_name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots; -- Ensure stats can be repeatedly accessed using the same stats snapshot. See -- https://postgr.es/m/20210317230447.c7uc4g3vbs4wi32i%40alap3.anarazel.de