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

Commit26d2c5d

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 parentf4abd02 commit26d2c5d

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
@@ -432,27 +432,32 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
432432
elseif (GinGetNPosting(itup)>0)
433433
{
434434
intnitems;
435-
ItemPointeruncompressed;
435+
ItemPointeritems_orig;
436+
boolfree_items_orig;
437+
ItemPointeritems;
436438

437-
/*
438-
* Vacuum posting list with proper function for compressed and
439-
* uncompressed format.
440-
*/
439+
/* Get list of item pointers from the tuple. */
441440
if (GinItupIsCompressed(itup))
442-
uncompressed=ginPostingListDecode((GinPostingList*)GinGetPosting(itup),&nitems);
441+
{
442+
items_orig=ginPostingListDecode((GinPostingList*)GinGetPosting(itup),&nitems);
443+
free_items_orig= true;
444+
}
443445
else
444446
{
445-
uncompressed= (ItemPointer)GinGetPosting(itup);
447+
items_orig= (ItemPointer)GinGetPosting(itup);
446448
nitems=GinGetNPosting(itup);
449+
free_items_orig= false;
447450
}
448451

449-
uncompressed=ginVacuumItemPointers(gvs,uncompressed,nitems,
450-
&nitems);
451-
if (uncompressed)
452+
/* Remove any items from the list that need to be vacuumed. */
453+
items=ginVacuumItemPointers(gvs,items_orig,nitems,&nitems);
454+
455+
if (free_items_orig)
456+
pfree(items_orig);
457+
458+
/* If any item pointers were removed, recreate the tuple. */
459+
if (items)
452460
{
453-
/*
454-
* Some ItemPointers were deleted, recreate tuple.
455-
*/
456461
OffsetNumberattnum;
457462
Datumkey;
458463
GinNullCategorycategory;
@@ -461,7 +466,7 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
461466

462467
if (nitems>0)
463468
{
464-
plist=ginCompressPostingList(uncompressed,nitems,GinMaxItemSize,NULL);
469+
plist=ginCompressPostingList(items,nitems,GinMaxItemSize,NULL);
465470
plistsize=SizeOfGinPostingList(plist);
466471
}
467472
else
@@ -500,6 +505,7 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
500505
RelationGetRelationName(gvs->index));
501506

502507
pfree(itup);
508+
pfree(items);
503509
}
504510
}
505511
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp