mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-28 23:57:19 +02:00
Update minimum recovery point on truncation during WAL replay of abort record.
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: mengjuan.cmj@alibaba-inc.com
Author: Fujii Masao
Reviewed-by: Heikki Linnakangas
Discussion: https://postgr.es/m/b029fce3-4fac-4265-968e-16f36ff4d075.mengjuan.cmj@alibaba-inc.com
This commit is contained in:
parent
aa1e9211ec
commit
a66b05b422
@ -5899,7 +5899,8 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
|
|||||||
* because subtransaction commit is never WAL logged.
|
* because subtransaction commit is never WAL logged.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
xact_redo_abort(xl_xact_parsed_abort *parsed, TransactionId xid)
|
xact_redo_abort(xl_xact_parsed_abort *parsed, TransactionId xid,
|
||||||
|
XLogRecPtr lsn)
|
||||||
{
|
{
|
||||||
TransactionId max_xid;
|
TransactionId max_xid;
|
||||||
|
|
||||||
@ -5949,7 +5950,16 @@ xact_redo_abort(xl_xact_parsed_abort *parsed, TransactionId xid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure files supposed to be dropped are dropped */
|
/* Make sure files supposed to be dropped are dropped */
|
||||||
|
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);
|
DropRelationFiles(parsed->xnodes, parsed->nrels, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -5989,7 +5999,7 @@ xact_redo(XLogReaderState *record)
|
|||||||
xl_xact_parsed_abort parsed;
|
xl_xact_parsed_abort parsed;
|
||||||
|
|
||||||
ParseAbortRecord(XLogRecGetInfo(record), xlrec, &parsed);
|
ParseAbortRecord(XLogRecGetInfo(record), xlrec, &parsed);
|
||||||
xact_redo_abort(&parsed, XLogRecGetXid(record));
|
xact_redo_abort(&parsed, XLogRecGetXid(record), record->EndRecPtr);
|
||||||
}
|
}
|
||||||
else if (info == XLOG_XACT_ABORT_PREPARED)
|
else if (info == XLOG_XACT_ABORT_PREPARED)
|
||||||
{
|
{
|
||||||
@ -5997,7 +6007,7 @@ xact_redo(XLogReaderState *record)
|
|||||||
xl_xact_parsed_abort parsed;
|
xl_xact_parsed_abort parsed;
|
||||||
|
|
||||||
ParseAbortRecord(XLogRecGetInfo(record), xlrec, &parsed);
|
ParseAbortRecord(XLogRecGetInfo(record), xlrec, &parsed);
|
||||||
xact_redo_abort(&parsed, parsed.twophase_xid);
|
xact_redo_abort(&parsed, parsed.twophase_xid, record->EndRecPtr);
|
||||||
|
|
||||||
/* Delete TwoPhaseState gxact entry and/or 2PC file. */
|
/* Delete TwoPhaseState gxact entry and/or 2PC file. */
|
||||||
LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
|
LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
|
||||||
|
Loading…
Reference in New Issue
Block a user