https://commitfest.postgresql.org/action/patch_view?id=1661 (apologies for not replying to the thread; I can't find it in my inbox)
Patch applies and passes make check. Code formatting looks good. The regression test partially tests this. It does not cover 2PC, nor does it test rolling back a subtransaction that contains a truncate. The latter actually doesn't work correctly. The test also adds 2.5 seconds of forced pg_sleep. I think that's both bad and unnecessary. When I removed the sleeps I still saw times of less than 0.1 seconds. Also, wait_for_trunc_test_stats() should display something if it times out; otherwise you'll have a test failure and won't have any indication why. I've attached a patch that adds logging on timeout and contains a test case that demonstrates the rollback to savepoint bug. -- Jim Nasby, Data Architect, Blue Treble Consulting Data in Trouble? Get it in Treble! http://BlueTreble.com
>From 973dbe11b796395641dd3947658508ad68aebda5 Mon Sep 17 00:00:00 2001 From: Jim Nasby <jim.na...@bluetreble.com> Date: Mon, 15 Dec 2014 18:18:40 -0600 Subject: [PATCH] Show broken rollback case Warn if stats update doesn't happen. Add test that shows broken stats counts when rolling back a subtrans with a truncate. --- src/test/regress/sql/truncate.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/regress/sql/truncate.sql b/src/test/regress/sql/truncate.sql index c912345..f5a0e7a 100644 --- a/src/test/regress/sql/truncate.sql +++ b/src/test/regress/sql/truncate.sql @@ -251,6 +251,9 @@ begin perform pg_stat_clear_snapshot(); end loop; + IF NOT updated THEN + RAISE WARNING 'stats update never happened'; + END IF; TRUNCATE prevstats; -- what a pun INSERT INTO prevstats SELECT newstats.*; @@ -311,5 +314,20 @@ COMMIT; SELECT pg_sleep(0.5); SELECT * FROM wait_for_trunc_test_stats(); +-- now to use a savepoint: this should only count 2 inserts and have 3 +-- live tuples after commit +BEGIN; +INSERT INTO trunc_stats_test DEFAULT VALUES; +INSERT INTO trunc_stats_test DEFAULT VALUES; +SAVEPOINT p1; +INSERT INTO trunc_stats_test DEFAULT VALUES; +INSERT INTO trunc_stats_test DEFAULT VALUES; +TRUNCATE trunc_stats_test; +INSERT INTO trunc_stats_test DEFAULT VALUES; +ROLLBACK TO SAVEPOINT p1; +COMMIT; + +SELECT * FROM wait_for_trunc_test_stats(); + DROP TABLE prevstats CASCADE; DROP TABLE trunc_stats_test; -- 2.1.2
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers