Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit132cd58

Browse files
committed
Fix failure to delete spill files of aborted transactions
Logical decoding's reorderbuffer.c may spill transaction files to diskwhen transactions are large. These are supposed to be removed when theybecome "too old" by xid; but file removal requires the boundary LSNs ofthe transaction to be known. The final_lsn is only set when we see thecommit or abort record for the transaction, but nothing sets the valuefor transactions that crash, so the removal code misbehaves -- inassertion-enabled builds, it crashes by a failed assertion.To fix, modify the final_lsn of transactions that don't have a valueset, to the LSN of the very latest change in the transaction. Thiscauses the spilled files to be removed appropriately.Author: Atsushi TorikoshiReviewed-by: Kyotaro HORIGUCHI, Craig Ringer, Masahiko SawadaDiscussion:https://postgr.es/m/54e4e488-186b-a056-6628-50628e4e4ebc@lab.ntt.co.jp
1 parentea4cbf8 commit132cd58

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

‎src/backend/replication/logical/reorderbuffer.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,8 +1689,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
16891689
* Iterate through all (potential) toplevel TXNs and abort all that are
16901690
* older than what possibly can be running. Once we've found the first
16911691
* that is alive we stop, there might be some that acquired an xid earlier
1692-
* but started writing later, but it's unlikely and they willcleaned up
1693-
* in a later call toReorderBufferAbortOld().
1692+
* but started writing later, but it's unlikely and they willbe cleaned
1693+
*upin a later call tothis function.
16941694
*/
16951695
dlist_foreach_modify(it,&rb->toplevel_by_lsn)
16961696
{
@@ -1700,6 +1700,21 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
17001700

17011701
if (TransactionIdPrecedes(txn->xid,oldestRunningXid))
17021702
{
1703+
/*
1704+
* We set final_lsn on a transaction when we decode its commit or
1705+
* abort record, but we never see those records for crashed
1706+
* transactions. To ensure cleanup of these transactions, set
1707+
* final_lsn to that of their last change; this causes
1708+
* ReorderBufferRestoreCleanup to do the right thing.
1709+
*/
1710+
if (txn->serialized&&txn->final_lsn==0)
1711+
{
1712+
ReorderBufferChange*last=
1713+
dlist_tail_element(ReorderBufferChange,node,&txn->changes);
1714+
1715+
txn->final_lsn=last->lsn;
1716+
}
1717+
17031718
elog(DEBUG2,"aborting old transaction %u",txn->xid);
17041719

17051720
/* remove potential on-disk data, and deallocate this tx */

‎src/include/replication/reorderbuffer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ typedef struct ReorderBufferTXN
162162
* * plain abort record
163163
* * prepared transaction abort
164164
* * error during decoding
165+
* * for a crashed transaction, the LSN of the last change, regardless of
166+
* what it was.
165167
* ----
166168
*/
167169
XLogRecPtrfinal_lsn;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp