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

Commitd1b9ee4

Browse files
committed
Fix bug in the GiST vacuum's 2nd stage.
We mustn't assume that the IndexVacuumInfo pointer passed to bulkdelete()stage is still valid in the vacuumcleanup() stage.Per very pink buildfarm.
1 parent7df159a commitd1b9ee4

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

‎src/backend/access/gist/gistvacuum.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ typedef struct
3131
{
3232
IndexBulkDeleteResultstats;/* must be first */
3333

34-
IndexVacuumInfo*info;
35-
3634
/*
3735
* These are used to memorize all internal and empty leaf pages in the 1st
3836
* vacuum stage. They are used in the 2nd stage, to delete all the empty
@@ -46,6 +44,7 @@ typedef struct
4644
/* Working state needed by gistbulkdelete */
4745
typedefstruct
4846
{
47+
IndexVacuumInfo*info;
4948
GistBulkDeleteResult*stats;
5049
IndexBulkDeleteCallbackcallback;
5150
void*callback_state;
@@ -56,8 +55,9 @@ static void gistvacuumscan(IndexVacuumInfo *info, GistBulkDeleteResult *stats,
5655
IndexBulkDeleteCallbackcallback,void*callback_state);
5756
staticvoidgistvacuumpage(GistVacState*vstate,BlockNumberblkno,
5857
BlockNumberorig_blkno);
59-
staticvoidgistvacuum_delete_empty_pages(GistBulkDeleteResult*stats);
60-
staticboolgistdeletepage(GistBulkDeleteResult*stats,
58+
staticvoidgistvacuum_delete_empty_pages(IndexVacuumInfo*info,
59+
GistBulkDeleteResult*stats);
60+
staticboolgistdeletepage(IndexVacuumInfo*info,GistBulkDeleteResult*stats,
6161
Bufferbuffer,OffsetNumberdownlink,
6262
BufferleafBuffer);
6363

@@ -121,7 +121,7 @@ gistvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
121121
* If we saw any empty pages, try to unlink them from the tree so that
122122
* they can be reused.
123123
*/
124-
gistvacuum_delete_empty_pages(gist_stats);
124+
gistvacuum_delete_empty_pages(info,gist_stats);
125125

126126
/* we don't need the internal and empty page sets anymore */
127127
MemoryContextDelete(gist_stats->page_set_context);
@@ -183,7 +183,7 @@ gistvacuumscan(IndexVacuumInfo *info, GistBulkDeleteResult *stats,
183183
stats->empty_leaf_set=intset_create();
184184

185185
/* Set up info to pass down to gistvacuumpage */
186-
stats->info=info;
186+
vstate.info=info;
187187
vstate.stats=stats;
188188
vstate.callback=callback;
189189
vstate.callback_state=callback_state;
@@ -269,7 +269,7 @@ static void
269269
gistvacuumpage(GistVacState*vstate,BlockNumberblkno,BlockNumberorig_blkno)
270270
{
271271
GistBulkDeleteResult*stats=vstate->stats;
272-
IndexVacuumInfo*info=stats->info;
272+
IndexVacuumInfo*info=vstate->info;
273273
IndexBulkDeleteCallbackcallback=vstate->callback;
274274
void*callback_state=vstate->callback_state;
275275
Relationrel=info->index;
@@ -456,9 +456,8 @@ gistvacuumpage(GistVacState *vstate, BlockNumber blkno, BlockNumber orig_blkno)
456456
* Scan all internal pages, and try to delete their empty child pages.
457457
*/
458458
staticvoid
459-
gistvacuum_delete_empty_pages(GistBulkDeleteResult*stats)
459+
gistvacuum_delete_empty_pages(IndexVacuumInfo*info,GistBulkDeleteResult*stats)
460460
{
461-
IndexVacuumInfo*info=stats->info;
462461
Relationrel=info->index;
463462
BlockNumberempty_pages_remaining;
464463
uint64blkno;
@@ -552,7 +551,9 @@ gistvacuum_delete_empty_pages(GistBulkDeleteResult *stats)
552551
gistcheckpage(rel,leafbuf);
553552

554553
LockBuffer(buffer,GIST_EXCLUSIVE);
555-
if (gistdeletepage(stats,buffer,todelete[i]-deleted,leafbuf))
554+
if (gistdeletepage(info,stats,
555+
buffer,todelete[i]-deleted,
556+
leafbuf))
556557
deleted++;
557558
LockBuffer(buffer,GIST_UNLOCK);
558559

@@ -585,7 +586,7 @@ gistvacuum_delete_empty_pages(GistBulkDeleteResult *stats)
585586
* prevented it.
586587
*/
587588
staticbool
588-
gistdeletepage(GistBulkDeleteResult*stats,
589+
gistdeletepage(IndexVacuumInfo*info,GistBulkDeleteResult*stats,
589590
BufferparentBuffer,OffsetNumberdownlink,
590591
BufferleafBuffer)
591592
{
@@ -661,10 +662,10 @@ gistdeletepage(GistBulkDeleteResult *stats,
661662
MarkBufferDirty(parentBuffer);
662663
PageIndexTupleDelete(parentPage,downlink);
663664

664-
if (RelationNeedsWAL(stats->info->index))
665+
if (RelationNeedsWAL(info->index))
665666
recptr=gistXLogPageDelete(leafBuffer,txid,parentBuffer,downlink);
666667
else
667-
recptr=gistGetFakeLSN(stats->info->index);
668+
recptr=gistGetFakeLSN(info->index);
668669
PageSetLSN(parentPage,recptr);
669670
PageSetLSN(leafPage,recptr);
670671

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp