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

Commit1ca97af

Browse files
committed
Use TransactionXmin instead of RecentGlobalXmin in heap_abort_speculative().
There's a very low risk that RecentGlobalXmin could be far enough inthe past to be older than relfrozenxid, or even wrappedaround. Luckily the consequences of that having happened wouldn't betoo bad - the page wouldn't be pruned for a while.Avoid that risk by using TransactionXmin instead. As that's announcedvia MyPgXact->xmin, it is protected against wrapping around (see codecomments for details around relfrozenxid).Author: Andres FreundDiscussion:https://postgr.es/m/20200328213023.s4eyijhdosuc4vcj@alap3.anarazel.deBackpatch: 9.5-
1 parent250041a commit1ca97af

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6278,6 +6278,7 @@ heap_abort_speculative(Relation relation, HeapTuple tuple)
62786278
Pagepage;
62796279
BlockNumberblock;
62806280
Bufferbuffer;
6281+
TransactionIdprune_xid;
62816282

62826283
Assert(ItemPointerIsValid(tid));
62836284

@@ -6320,13 +6321,21 @@ heap_abort_speculative(Relation relation, HeapTuple tuple)
63206321
START_CRIT_SECTION();
63216322

63226323
/*
6323-
* The tuple will become DEAD immediately. Flag that this page
6324-
* immediately is a candidate for pruning by setting xmin to
6325-
* RecentGlobalXmin. That's not pretty, but it doesn't seem worth
6326-
* inventing a nicer API for this.
6324+
* The tuple will become DEAD immediately. Flag that this page is a
6325+
* candidate for pruning by setting xmin to TransactionXmin. While not
6326+
* immediately prunable, it is the oldest xid we can cheaply determine
6327+
* that's safe against wraparound / being older than the table's
6328+
* relfrozenxid. To defend against the unlikely case of a new relation
6329+
* having a newer relfrozenxid than our TransactionXmin, use relfrozenxid
6330+
* if so (vacuum can't subsequently move relfrozenxid to beyond
6331+
* TransactionXmin, so there's no race here).
63276332
*/
6328-
Assert(TransactionIdIsValid(RecentGlobalXmin));
6329-
PageSetPrunable(page,RecentGlobalXmin);
6333+
Assert(TransactionIdIsValid(TransactionXmin));
6334+
if (TransactionIdPrecedes(TransactionXmin,relation->rd_rel->relfrozenxid))
6335+
prune_xid=relation->rd_rel->relfrozenxid;
6336+
else
6337+
prune_xid=TransactionXmin;
6338+
PageSetPrunable(page,prune_xid);
63306339

63316340
/* store transaction information of xact deleting the tuple */
63326341
tp.t_data->t_infomask &= ~(HEAP_XMAX_BITS |HEAP_MOVED);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp