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

Commitd810720

Browse files
committed
Fix memory leaks in GIN index vacuum.
Per bug #12850 by Walter Nordmann. Backpatch to 9.4 where the leak wasintroduced.
1 parent3d0d3c0 commitd810720

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

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

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -499,27 +499,32 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
499499
elseif (GinGetNPosting(itup)>0)
500500
{
501501
intnitems;
502-
ItemPointeruncompressed;
502+
ItemPointeritems_orig;
503+
boolfree_items_orig;
504+
ItemPointeritems;
503505

504-
/*
505-
* Vacuum posting list with proper function for compressed and
506-
* uncompressed format.
507-
*/
506+
/* Get list of item pointers from the tuple. */
508507
if (GinItupIsCompressed(itup))
509-
uncompressed=ginPostingListDecode((GinPostingList*)GinGetPosting(itup),&nitems);
508+
{
509+
items_orig=ginPostingListDecode((GinPostingList*)GinGetPosting(itup),&nitems);
510+
free_items_orig= true;
511+
}
510512
else
511513
{
512-
uncompressed= (ItemPointer)GinGetPosting(itup);
514+
items_orig= (ItemPointer)GinGetPosting(itup);
513515
nitems=GinGetNPosting(itup);
516+
free_items_orig= false;
514517
}
515518

516-
uncompressed=ginVacuumItemPointers(gvs,uncompressed,nitems,
517-
&nitems);
518-
if (uncompressed)
519+
/* Remove any items from the list that need to be vacuumed. */
520+
items=ginVacuumItemPointers(gvs,items_orig,nitems,&nitems);
521+
522+
if (free_items_orig)
523+
pfree(items_orig);
524+
525+
/* If any item pointers were removed, recreate the tuple. */
526+
if (items)
519527
{
520-
/*
521-
* Some ItemPointers were deleted, recreate tuple.
522-
*/
523528
OffsetNumberattnum;
524529
Datumkey;
525530
GinNullCategorycategory;
@@ -528,7 +533,7 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
528533

529534
if (nitems>0)
530535
{
531-
plist=ginCompressPostingList(uncompressed,nitems,GinMaxItemSize,NULL);
536+
plist=ginCompressPostingList(items,nitems,GinMaxItemSize,NULL);
532537
plistsize=SizeOfGinPostingList(plist);
533538
}
534539
else
@@ -567,6 +572,7 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
567572
RelationGetRelationName(gvs->index));
568573

569574
pfree(itup);
575+
pfree(items);
570576
}
571577
}
572578
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp