Update minimum recovery point on truncation during WAL replay of abort record.
authorFujii Masao
Wed, 28 Jul 2021 16:30:02 +0000 (01:30 +0900)
committerFujii Masao
Wed, 28 Jul 2021 16:31:41 +0000 (01:31 +0900)
If a file is truncated, we must update minRecoveryPoint. Once a file is
truncated, there's no going back; it would not be safe to stop recovery
at a point earlier than that anymore.

Commit 7bffc9b7bf changed xact_redo_commit() so that it updates
minRecoveryPoint on truncation, but forgot to change xact_redo_abort().

Back-patch to all supported versions.

Reported-by: [email protected]
Author: Fujii Masao
Reviewed-by: Heikki Linnakangas
Discussion: https://postgr.es/m/b029fce3-4fac-4265-968e-16f36ff4d075[email protected]

src/backend/access/transam/xact.c

index 441445927e8d719bef19acfea61fdd2342bead4c..387f80419a5f320f173a2280cd2afac75386a579 100644 (file)
@@ -5983,7 +5983,16 @@ xact_redo_abort(xl_xact_parsed_abort *parsed, TransactionId xid,
    }
 
    /* Make sure files supposed to be dropped are dropped */
-   DropRelationFiles(parsed->xnodes, parsed->nrels, true);
+   if (parsed->nrels > 0)
+   {
+       /*
+        * See comments about update of minimum recovery point on truncation,
+        * in xact_redo_commit().
+        */
+       XLogFlush(lsn);
+
+       DropRelationFiles(parsed->xnodes, parsed->nrels, true);
+   }
 }
 
 void