diff --git a/contrib/amcheck/t/003_cic_2pc.pl b/contrib/amcheck/t/003_cic_2pc.pl index fa1a499..9190dca 100644 --- a/contrib/amcheck/t/003_cic_2pc.pl +++ b/contrib/amcheck/t/003_cic_2pc.pl @@ -9,7 +9,7 @@ use Config; use PostgresNode; use TestLib; -use Test::More tests => 5; +use Test::More tests => 6; my ($node, $result); @@ -95,6 +95,37 @@ is($result, '0', 'bt_index_check checks index'); # +# Server restart shall not change whether prepared xact blocks CIC +# + +$node->safe_psql('postgres', q( +BEGIN; +INSERT INTO tbl VALUES(0); +PREPARE TRANSACTION 'spans_restart'; +BEGIN; +CREATE TABLE unused (); +PREPARE TRANSACTION 'persists_forever'; +)); +$node->restart; + +$reindex_in = ''; +$reindex_out = ''; +$reindex_timer = IPC::Run::timeout(180); +$reindex_h = $node->background_psql('postgres', \$reindex_in, \$reindex_out, $reindex_timer, + on_error_stop => 1); +$reindex_in .= q( +\echo start +REINDEX TABLE CONCURRENTLY tbl; +); +pump $reindex_h until $reindex_out =~ /start/ || $reindex_timer->is_expired; + +$node->safe_psql('postgres', "COMMIT PREPARED 'spans_restart'"); +$reindex_h->finish; +$result = $node->psql('postgres', q(SELECT bt_index_check('idx',true))); +is($result, '0', 'bt_index_check checks index'); + + +# # Test 2. Stress CIC+2PC with pgbench #