First off, thanks for the quick reaction and reviews, I appreciate it. On Wed, 2023-06-21 at 14:14 +0900, Michael Paquier wrote: > But that won't connect work as the segment requested is now a partial > one in the primary's pg_wal, still the standby wants it.
I think since 009_twophase.pl doesn't use archiving so far, it's not a good idea to enable it generally, for all those tests. It changes too much of the behaviour. > I think that it is better > for now to just undo has_archiving in has_archiving, and tackle the > coverage with a separate test, perhaps only for HEAD. I see you've already undone it. Attached is a patch for 009_twophase.pl to just try this corner case at the very end, so as not to influence other existing tests in suite. When I run this on REL_14_8 I get the error again, sort of as a sanity check... Kind regards Julian
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');