summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Kapila2020-10-13 07:16:38 +0000
committerAmit Kapila2020-10-13 07:16:38 +0000
commit2050832d0d637358a376a99514071941aa93ed31 (patch)
tree04affb1927f0f7a0a7af658b31c14d0ade4e6150
parent323ae003e464cac35f86790f3708b383c18df9e2 (diff)
Fix the unstable output of tests added by commit 8fccf75834.
The test cases added by that commit were trying to test the exact number of times a particular transaction has spilled. However, that number can vary if any background transaction (say by autovacuum) happens in parallel to the main transaction. So let's not try to verify the exact count. Author: Amit Kapila Reviewed-by: Sawada Masahiko Discussion: https://postgr.es/m/CA+fd4k5_pPAYRTDrO2PbtTOe0eHQpBvuqmCr8ic39uTNmR49Eg@mail.gmail.com
-rw-r--r--contrib/test_decoding/expected/stats.out20
-rw-r--r--contrib/test_decoding/sql/stats.sql12
2 files changed, 18 insertions, 14 deletions
diff --git a/contrib/test_decoding/expected/stats.out b/contrib/test_decoding/expected/stats.out
index c4464f49dad..bfffd1ac21d 100644
--- a/contrib/test_decoding/expected/stats.out
+++ b/contrib/test_decoding/expected/stats.out
@@ -42,23 +42,25 @@ $$ LANGUAGE plpgsql;
BEGIN;
INSERT INTO stats_test SELECT 'serialize-topbig--1:'||g.i FROM generate_series(1, 5000) g(i);
COMMIT;
-SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL,NULL);
+SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'skip-empty-xacts', '1');
count
-------
- 5006
+ 5002
(1 row)
--- check stats, wait for stats collector to update.
+-- Check stats, wait for the stats collector to update. We can't test the
+-- 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);
wait_for_decode_stats
-----------------------
(1 row)
-SELECT name, spill_txns, spill_count FROM pg_stat_replication_slots;
+SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
name | spill_txns | spill_count
-----------------+------------+-------------
- regression_slot | 1 | 12
+ regression_slot | t | t
(1 row)
-- reset the slot stats, and wait for stats collector to reset
@@ -81,10 +83,10 @@ SELECT name, spill_txns, spill_count FROM pg_stat_replication_slots;
(1 row)
-- decode and check stats again.
-SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL,NULL);
+SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'skip-empty-xacts', '1');
count
-------
- 5006
+ 5002
(1 row)
SELECT wait_for_decode_stats(false);
@@ -93,10 +95,10 @@ SELECT wait_for_decode_stats(false);
(1 row)
-SELECT name, spill_txns, spill_count FROM pg_stat_replication_slots;
+SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
name | spill_txns | spill_count
-----------------+------------+-------------
- regression_slot | 1 | 12
+ regression_slot | t | t
(1 row)
DROP FUNCTION wait_for_decode_stats(bool);
diff --git a/contrib/test_decoding/sql/stats.sql b/contrib/test_decoding/sql/stats.sql
index 7d406f0b113..b95adb16fa7 100644
--- a/contrib/test_decoding/sql/stats.sql
+++ b/contrib/test_decoding/sql/stats.sql
@@ -41,11 +41,13 @@ $$ LANGUAGE plpgsql;
BEGIN;
INSERT INTO stats_test SELECT 'serialize-topbig--1:'||g.i FROM generate_series(1, 5000) g(i);
COMMIT;
-SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL,NULL);
+SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'skip-empty-xacts', '1');
--- check stats, wait for stats collector to update.
+-- Check stats, wait for the stats collector to update. We can't test the
+-- 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);
-SELECT name, spill_txns, spill_count FROM pg_stat_replication_slots;
+SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
-- reset the slot stats, and wait for stats collector to reset
SELECT pg_stat_reset_replication_slot('regression_slot');
@@ -53,9 +55,9 @@ SELECT wait_for_decode_stats(true);
SELECT name, spill_txns, spill_count FROM pg_stat_replication_slots;
-- decode and check stats again.
-SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL,NULL);
+SELECT count(*) FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'skip-empty-xacts', '1');
SELECT wait_for_decode_stats(false);
-SELECT name, spill_txns, spill_count FROM pg_stat_replication_slots;
+SELECT name, spill_txns > 0 AS spill_txns, spill_count > 0 AS spill_count FROM pg_stat_replication_slots;
DROP FUNCTION wait_for_decode_stats(bool);
DROP TABLE stats_test;