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

Commitdc943ad

Browse files
committed
Allow autoanalyze to add pages deleted from pending list to FSM
Commite956808 introduces adding pagesto FSM for ordinary insert, but autoanalyze was able just cleanuppending list without adding to FSM.Also fix double call of IndexFreeSpaceMapVacuum() during ginvacuumcleanup()Report from Fujii MasaoPatch by meReview by Jeff Janes
1 parent262e56b commitdc943ad

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

‎src/backend/access/gin/ginfast.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector)
434434
END_CRIT_SECTION();
435435

436436
if (needCleanup)
437-
ginInsertCleanup(ginstate, false,NULL);
437+
ginInsertCleanup(ginstate, false,true,NULL);
438438
}
439439

440440
/*
@@ -505,7 +505,7 @@ ginHeapTupleFastCollect(GinState *ginstate,
505505
*/
506506
staticbool
507507
shiftList(Relationindex,Buffermetabuffer,BlockNumbernewHead,
508-
IndexBulkDeleteResult*stats)
508+
boolfill_fsm,IndexBulkDeleteResult*stats)
509509
{
510510
Pagemetapage;
511511
GinMetaPageData*metadata;
@@ -613,7 +613,7 @@ shiftList(Relation index, Buffer metabuffer, BlockNumber newHead,
613613

614614
END_CRIT_SECTION();
615615

616-
for (i=0;i<data.ndeleted;i++)
616+
for (i=0;fill_fsm&&i<data.ndeleted;i++)
617617
RecordFreeIndexPage(index,freespace[i]);
618618

619619
}while (blknoToDelete!=newHead);
@@ -732,13 +732,19 @@ processPendingPage(BuildAccumulator *accum, KeyArray *ka,
732732
* action of removing a page from the pending list really needs exclusive
733733
* lock.
734734
*
735-
* vac_delay indicates that ginInsertCleanup is called from vacuum process,
736-
* so call vacuum_delay_point() periodically.
735+
* vac_delay indicates that ginInsertCleanup should call
736+
* vacuum_delay_point() periodically.
737+
*
738+
* fill_fsm indicates that ginInsertCleanup should add deleted pages
739+
* to FSM otherwise caller is responsible to put deleted pages into
740+
* FSM.
741+
*
737742
* If stats isn't null, we count deleted pending pages into the counts.
738743
*/
739744
void
740745
ginInsertCleanup(GinState*ginstate,
741-
boolvac_delay,IndexBulkDeleteResult*stats)
746+
boolvac_delay,boolfill_fsm,
747+
IndexBulkDeleteResult*stats)
742748
{
743749
Relationindex=ginstate->index;
744750
Buffermetabuffer,
@@ -899,7 +905,7 @@ ginInsertCleanup(GinState *ginstate,
899905
* remove read pages from pending list, at this point all
900906
* content of read pages is in regular structure
901907
*/
902-
if (shiftList(index,metabuffer,blkno,stats))
908+
if (shiftList(index,metabuffer,blkno,fill_fsm,stats))
903909
{
904910
/* another cleanup process is running concurrently */
905911
LockBuffer(metabuffer,GIN_UNLOCK);
@@ -948,7 +954,7 @@ ginInsertCleanup(GinState *ginstate,
948954
* desirable to recycle them immediately to the FreeSpace Map when
949955
* ordinary backends clean the list.
950956
*/
951-
if (fsm_vac&&!vac_delay)
957+
if (fsm_vac&&fill_fsm)
952958
IndexFreeSpaceMapVacuum(index);
953959

954960

‎src/backend/access/gin/ginvacuum.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ ginbulkdelete(PG_FUNCTION_ARGS)
544544
/* Yes, so initialize stats to zeroes */
545545
stats= (IndexBulkDeleteResult*)palloc0(sizeof(IndexBulkDeleteResult));
546546
/* and cleanup any pending inserts */
547-
ginInsertCleanup(&gvs.ginstate, true,stats);
547+
ginInsertCleanup(&gvs.ginstate, true,false,stats);
548548
}
549549

550550
/* we'll re-count the tuples each time */
@@ -659,7 +659,7 @@ ginvacuumcleanup(PG_FUNCTION_ARGS)
659659
if (IsAutoVacuumWorkerProcess())
660660
{
661661
initGinState(&ginstate,index);
662-
ginInsertCleanup(&ginstate, true,stats);
662+
ginInsertCleanup(&ginstate, true,true,stats);
663663
}
664664
PG_RETURN_POINTER(stats);
665665
}
@@ -672,7 +672,7 @@ ginvacuumcleanup(PG_FUNCTION_ARGS)
672672
{
673673
stats= (IndexBulkDeleteResult*)palloc0(sizeof(IndexBulkDeleteResult));
674674
initGinState(&ginstate,index);
675-
ginInsertCleanup(&ginstate, true,stats);
675+
ginInsertCleanup(&ginstate, true,false,stats);
676676
}
677677

678678
memset(&idxStat,0,sizeof(idxStat));

‎src/include/access/gin_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ extern void ginHeapTupleFastCollect(GinState *ginstate,
936936
OffsetNumberattnum,Datumvalue,boolisNull,
937937
ItemPointerht_ctid);
938938
externvoidginInsertCleanup(GinState*ginstate,
939-
boolvac_delay,IndexBulkDeleteResult*stats);
939+
boolvac_delay,boolfill_fsm,IndexBulkDeleteResult*stats);
940940

941941
/* ginpostinglist.c */
942942

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp