diff --git a/src/test/recovery/t/009_twophase.pl b/src/test/recovery/t/009_twophase.pl index 900d181788..706fc1bc10 100644 --- a/src/test/recovery/t/009_twophase.pl +++ b/src/test/recovery/t/009_twophase.pl @@ -7,7 +7,7 @@ use warnings; use PostgresNode; use TestLib; -use Test::More tests => 24; +use Test::More tests => 26; my $psql_out = ''; my $psql_rc = ''; @@ -480,3 +480,34 @@ $cur_standby->psql( is( $psql_out, qq{27|issued to paris}, "Check expected t_009_tbl2 data on standby"); + +############################################################################### +# Check recovery of prepared transaction with DDL inside after a hard restart +# of the primary, now with archiving enabled, to test handling of .partial files. +############################################################################### + +$cur_primary->enable_archiving; +$cur_primary->restart; + +$cur_primary->psql( + 'postgres', " + BEGIN; + CREATE TABLE t_009_tbl7 (id int, msg text); + SAVEPOINT s1; + INSERT INTO t_009_tbl7 VALUES (31, 'issued to ${cur_primary_name}'); + PREPARE TRANSACTION 'xact_009_18';"); + +$cur_primary->stop('immediate'); +$cur_primary->set_standby_mode; +$cur_primary->start; + +$cur_primary->promote; + +my $logfile = slurp_file($cur_primary->logfile()); +ok( $logfile =~ + qr/recovering prepared transaction .* from shared memory/, + 'want to see that a prepared transaction was recovered'); + +# # verify that recovery and promotion finished and that the prepared transaction still exists. +$psql_rc = $cur_primary->psql('postgres', "COMMIT PREPARED 'xact_009_18'"); +is($psql_rc, '0', 'Commit prepared transaction after crash recovery');