Enable archiving in recovery TAP test 009_twophase.pl
authorMichael Paquier
Tue, 20 Jun 2023 01:25:41 +0000 (10:25 +0900)
committerMichael Paquier
Tue, 20 Jun 2023 01:25:41 +0000 (10:25 +0900)
This is a follow-up of f663b00, that has been committed to v13 and v14,
tweaking the TAP test for two-phase transactions so as it provides
coverage for the bug that has been fixed.  This change is done in its
own commit for clarity, as v15 and HEAD did not show the problematic
behavior, still missed coverage for it.

While on it, this adds a comment about the dependency of the last
partial segment rename and RecoverPreparedTransactions() at the end of
recovery, as that can be easy to miss.

Author: Michael Paquier
Reviewed-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/743b9b45a2d4013bd90b6a5cba8d6faeb717ee34[email protected]
Backpatch-through: 13

src/backend/access/transam/xlog.c
src/test/recovery/t/009_twophase.pl

index 691b9622dad5ea959a1dcd65618b1a60fe7a3d8a..59f94b05d4afdba486e9a3aaa0e25aef77fb9e5b 100644 (file)
@@ -5544,7 +5544,11 @@ StartupXLOG(void)
    TrimCLOG();
    TrimMultiXact();
 
-   /* Reload shared-memory state for prepared transactions */
+   /*
+    * Reload shared-memory state for prepared transactions.  This needs to
+    * happen before renaming the last partial segment of the old timeline as
+    * it may be possible that we have to recovery some transactions from it.
+    */
    RecoverPreparedTransactions();
 
    /* Shut down xlogreader */
index 3e25b8c4ebdd3d3b533fc8fcf8590f02525645b7..ca17a059114c418c53fb1e6f584f4fdd7bb7b00c 100644 (file)
@@ -32,7 +32,9 @@ sub configure_and_reload
 
 # Setup london node
 my $node_london = PostgreSQL::Test::Cluster->new("london");
-$node_london->init(allows_streaming => 1);
+# Archiving is used to provide coverage with the creation of .partial segments
+# done at the end of recovery and the recovery of two-phase transactions.
+$node_london->init(allows_streaming => 1, has_archiving => 1);
 $node_london->append_conf(
    'postgresql.conf', qq(
    max_prepared_transactions = 10