aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2022-05-22 15:09:50 -0700
committerAndres Freund <andres@anarazel.de>2022-05-22 15:25:13 -0700
commit7fdbdf204920ac279f280d0a8e96946fdaf41aef (patch)
tree746cbdb34d1706dd05fc30392e588f52af001d9d /src
parentc7461fc25558832dd347a9c8150b0f1ed85e36e8 (diff)
downloadpostgresql-7fdbdf204920ac279f280d0a8e96946fdaf41aef.tar.gz
postgresql-7fdbdf204920ac279f280d0a8e96946fdaf41aef.zip
pgstat: fix stats.spec instability on slow machines.
On slow machines the modified test could end up switching the order in which transactional stats are reported in one session and non-transactional stats in another session. As stats handling of truncate is implemented as setting live/dead rows 0, the order in which a truncate's stats changes are applied, relative to normal stats updates, matters. The handling of stats for truncate hasn't changed due to shared memory stats, this is longstanding behavior. We might want to improve truncate's stats handling in the future, but for now just change the order of forced flushed to make the test stable. Reported-By: Christoph Berg <myon@debian.org> Discussion: https://postgr.es/m/YoZf7U/WmfmFYFEx@msg.df7cb.de
Diffstat (limited to 'src')
-rw-r--r--src/test/isolation/expected/stats.out4
-rw-r--r--src/test/isolation/expected/stats_1.out6
-rw-r--r--src/test/isolation/specs/stats.spec3
3 files changed, 7 insertions, 6 deletions
diff --git a/src/test/isolation/expected/stats.out b/src/test/isolation/expected/stats.out
index 8bf6e57d0bf..61b5a710ec8 100644
--- a/src/test/isolation/expected/stats.out
+++ b/src/test/isolation/expected/stats.out
@@ -2812,7 +2812,7 @@ seq_scan|seq_tup_read|n_tup_ins|n_tup_upd|n_tup_del|n_live_tup|n_dead_tup|vacuum
(1 row)
-starting permutation: s1_table_insert s1_begin s1_table_update_k1 s1_table_update_k1 s1_table_truncate s1_table_insert_k1 s1_table_update_k1 s1_prepare_a s2_commit_prepared_a s1_ff s2_ff s1_table_stats
+starting permutation: s1_table_insert s1_begin s1_table_update_k1 s1_table_update_k1 s1_table_truncate s1_table_insert_k1 s1_table_update_k1 s1_prepare_a s1_ff s2_commit_prepared_a s2_ff s1_table_stats
pg_stat_force_next_flush
------------------------
@@ -2826,13 +2826,13 @@ step s1_table_truncate: TRUNCATE test_stat_tab;
step s1_table_insert_k1: INSERT INTO test_stat_tab(key, value) VALUES('k1', 1);
step s1_table_update_k1: UPDATE test_stat_tab SET value = value + 1 WHERE key = 'k1';
step s1_prepare_a: PREPARE TRANSACTION 'a';
-step s2_commit_prepared_a: COMMIT PREPARED 'a';
step s1_ff: SELECT pg_stat_force_next_flush();
pg_stat_force_next_flush
------------------------
(1 row)
+step s2_commit_prepared_a: COMMIT PREPARED 'a';
step s2_ff: SELECT pg_stat_force_next_flush();
pg_stat_force_next_flush
------------------------
diff --git a/src/test/isolation/expected/stats_1.out b/src/test/isolation/expected/stats_1.out
index 61fda0b5028..3854320106a 100644
--- a/src/test/isolation/expected/stats_1.out
+++ b/src/test/isolation/expected/stats_1.out
@@ -2826,7 +2826,7 @@ seq_scan|seq_tup_read|n_tup_ins|n_tup_upd|n_tup_del|n_live_tup|n_dead_tup|vacuum
(1 row)
-starting permutation: s1_table_insert s1_begin s1_table_update_k1 s1_table_update_k1 s1_table_truncate s1_table_insert_k1 s1_table_update_k1 s1_prepare_a s2_commit_prepared_a s1_ff s2_ff s1_table_stats
+starting permutation: s1_table_insert s1_begin s1_table_update_k1 s1_table_update_k1 s1_table_truncate s1_table_insert_k1 s1_table_update_k1 s1_prepare_a s1_ff s2_commit_prepared_a s2_ff s1_table_stats
pg_stat_force_next_flush
------------------------
@@ -2841,14 +2841,14 @@ step s1_table_insert_k1: INSERT INTO test_stat_tab(key, value) VALUES('k1', 1);
step s1_table_update_k1: UPDATE test_stat_tab SET value = value + 1 WHERE key = 'k1';
step s1_prepare_a: PREPARE TRANSACTION 'a';
ERROR: prepared transactions are disabled
-step s2_commit_prepared_a: COMMIT PREPARED 'a';
-ERROR: prepared transaction with identifier "a" does not exist
step s1_ff: SELECT pg_stat_force_next_flush();
pg_stat_force_next_flush
------------------------
(1 row)
+step s2_commit_prepared_a: COMMIT PREPARED 'a';
+ERROR: prepared transaction with identifier "a" does not exist
step s2_ff: SELECT pg_stat_force_next_flush();
pg_stat_force_next_flush
------------------------
diff --git a/src/test/isolation/specs/stats.spec b/src/test/isolation/specs/stats.spec
index be4ae1f4ff0..5b922d788cc 100644
--- a/src/test/isolation/specs/stats.spec
+++ b/src/test/isolation/specs/stats.spec
@@ -562,8 +562,9 @@ permutation
s1_table_insert_k1 # should be counted
s1_table_update_k1 # dito
s1_prepare_a
+ s1_ff # flush out non-transactional stats, might happen anyway
s2_commit_prepared_a
- s1_ff s2_ff
+ s2_ff
s1_table_stats
# S1 prepares, S1 aborts prepared