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

Commit 7fdbdf2

Browse files
committed
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
1 parent c7461fc commit 7fdbdf2

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/test/isolation/expected/stats.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -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
28122812
(1 row)
28132813

28142814

2815-
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
2815+
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
28162816
pg_stat_force_next_flush
28172817
------------------------
28182818

@@ -2826,13 +2826,13 @@ step s1_table_truncate: TRUNCATE test_stat_tab;
28262826
step s1_table_insert_k1: INSERT INTO test_stat_tab(key, value) VALUES('k1', 1);
28272827
step s1_table_update_k1: UPDATE test_stat_tab SET value = value + 1 WHERE key = 'k1';
28282828
step s1_prepare_a: PREPARE TRANSACTION 'a';
2829-
step s2_commit_prepared_a: COMMIT PREPARED 'a';
28302829
step s1_ff: SELECT pg_stat_force_next_flush();
28312830
pg_stat_force_next_flush
28322831
------------------------
28332832

28342833
(1 row)
28352834

2835+
step s2_commit_prepared_a: COMMIT PREPARED 'a';
28362836
step s2_ff: SELECT pg_stat_force_next_flush();
28372837
pg_stat_force_next_flush
28382838
------------------------

src/test/isolation/expected/stats_1.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -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
28262826
(1 row)
28272827

28282828

2829-
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
2829+
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
28302830
pg_stat_force_next_flush
28312831
------------------------
28322832

@@ -2841,14 +2841,14 @@ step s1_table_insert_k1: INSERT INTO test_stat_tab(key, value) VALUES('k1', 1);
28412841
step s1_table_update_k1: UPDATE test_stat_tab SET value = value + 1 WHERE key = 'k1';
28422842
step s1_prepare_a: PREPARE TRANSACTION 'a';
28432843
ERROR: prepared transactions are disabled
2844-
step s2_commit_prepared_a: COMMIT PREPARED 'a';
2845-
ERROR: prepared transaction with identifier "a" does not exist
28462844
step s1_ff: SELECT pg_stat_force_next_flush();
28472845
pg_stat_force_next_flush
28482846
------------------------
28492847

28502848
(1 row)
28512849

2850+
step s2_commit_prepared_a: COMMIT PREPARED 'a';
2851+
ERROR: prepared transaction with identifier "a" does not exist
28522852
step s2_ff: SELECT pg_stat_force_next_flush();
28532853
pg_stat_force_next_flush
28542854
------------------------

src/test/isolation/specs/stats.spec

+2-1
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,9 @@ permutation
562562
s1_table_insert_k1 # should be counted
563563
s1_table_update_k1 # dito
564564
s1_prepare_a
565+
s1_ff # flush out non-transactional stats, might happen anyway
565566
s2_commit_prepared_a
566-
s1_ff s2_ff
567+
s2_ff
567568
s1_table_stats
568569

569570
# S1 prepares, S1 aborts prepared

0 commit comments

Comments
 (0)