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

Commite48c817

Browse files
Recycle deleted nbtree pages more aggressively.
Commit61b313e made nbtree consistently pass down a heaprel to lowlevel routines like _bt_getbuf(). Although this was primarily intendedas preparation for logical decoding on standbys, it also made it easy tocorrect an old deficiency in how nbtree VACUUM determines whether or notit's now safe to recycle deleted pages.Pass the heaprel to GlobalVisTestFor() in nbtree routines that deal withrecycle safety. nbtree now makes less pessimistic assumptions aboutrecycle safety within non-catalog relations. This enhancementcomplements the recycling enhancement added by commit9dd963a.nbtree remains just as pessimistic as ever when it comes to recyclesafety within indexes on catalog relations. There is no fundamentalreason why we need to treat catalog relations differently, though. Thebehavioral inconsistency is a consequence of the way that nbtree usesnextXID values to implement what Lanin and Shasha call "the draintechnique". Note in particular that it has nothing to do with whetheror not index tuples might still be required for an older MVCC snapshot.Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>Discussion:https://postgr.es/m/CAH2-WzkaiDxCje0yPuH=3Uh2p1V_2pFGY==xfbZoZu7Ax_NB8g@mail.gmail.com
1 parenta349b86 commite48c817

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

‎src/backend/access/nbtree/nbtpage.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ _bt_getbuf(Relation rel, Relation heaprel, BlockNumber blkno, int access)
935935
returnbuf;
936936
}
937937

938-
if (BTPageIsRecyclable(page))
938+
if (BTPageIsRecyclable(page,heaprel))
939939
{
940940
/*
941941
* If we are generating WAL for Hot Standby then create a
@@ -2963,6 +2963,7 @@ void
29632963
_bt_pendingfsm_finalize(Relationrel,BTVacState*vstate)
29642964
{
29652965
IndexBulkDeleteResult*stats=vstate->stats;
2966+
Relationheaprel=vstate->info->heaprel;
29662967

29672968
Assert(stats->pages_newly_deleted >=vstate->npendingpages);
29682969

@@ -2995,7 +2996,7 @@ _bt_pendingfsm_finalize(Relation rel, BTVacState *vstate)
29952996
* essential; GlobalVisCheckRemovableFullXid() will not reliably recognize
29962997
* that it is now safe to recycle newly deleted pages without this step.
29972998
*/
2998-
GetOldestNonRemovableTransactionId(NULL);
2999+
GetOldestNonRemovableTransactionId(heaprel);
29993000

30003001
for (inti=0;i<vstate->npendingpages;i++)
30013002
{
@@ -3010,7 +3011,7 @@ _bt_pendingfsm_finalize(Relation rel, BTVacState *vstate)
30103011
* must be non-recyclable too, since _bt_pendingfsm_add() adds pages
30113012
* to the array in safexid order.
30123013
*/
3013-
if (!GlobalVisCheckRemovableFullXid(NULL,safexid))
3014+
if (!GlobalVisCheckRemovableFullXid(heaprel,safexid))
30143015
break;
30153016

30163017
RecordFreeIndexPage(rel,target);

‎src/backend/access/nbtree/nbtree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ btvacuumpage(BTVacState *vstate, BlockNumber scanblkno)
10391039
IndexBulkDeleteCallbackcallback=vstate->callback;
10401040
void*callback_state=vstate->callback_state;
10411041
Relationrel=info->index;
1042+
Relationheaprel=info->heaprel;
10421043
boolattempt_pagedel;
10431044
BlockNumberblkno,
10441045
backtrack_to;
@@ -1124,7 +1125,7 @@ btvacuumpage(BTVacState *vstate, BlockNumber scanblkno)
11241125
}
11251126
}
11261127

1127-
if (!opaque||BTPageIsRecyclable(page))
1128+
if (!opaque||BTPageIsRecyclable(page,heaprel))
11281129
{
11291130
/* Okay to recycle this page (which could be leaf or internal) */
11301131
RecordFreeIndexPage(rel,blkno);

‎src/include/access/nbtree.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ BTPageGetDeleteXid(Page page)
288288
* well need special handling for new pages anyway.
289289
*/
290290
staticinlinebool
291-
BTPageIsRecyclable(Pagepage)
291+
BTPageIsRecyclable(Pagepage,Relationheaprel)
292292
{
293293
BTPageOpaqueopaque;
294294

@@ -307,12 +307,8 @@ BTPageIsRecyclable(Page page)
307307
* For that check if the deletion XID could still be visible to
308308
* anyone. If not, then no scan that's still in progress could have
309309
* seen its downlink, and we can recycle it.
310-
*
311-
* XXX: If we had the heap relation we could be more aggressive about
312-
* recycling deleted pages in non-catalog relations. For now we just
313-
* pass NULL. That is at least simple and consistent.
314310
*/
315-
returnGlobalVisCheckRemovableFullXid(NULL,BTPageGetDeleteXid(page));
311+
returnGlobalVisCheckRemovableFullXid(heaprel,BTPageGetDeleteXid(page));
316312
}
317313

318314
return false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp