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

Commit3ce761d

Browse files
committed
Fix memory leak in Incremental Sort rescans
The Incremental Sort had a couple issues, resulting in leaking memoryduring rescans, possibly triggering OOM. The code had a couple ofrelated flaws:1. During rescans, the sort states were reset but then also set to NULL (despite the comment saying otherwise). ExecIncrementalSort then sees NULL and initializes a new sort state, leaking the memory used by the old one.2. Initializing the sort state also automatically rebuilt the info about presorted keys, leaking the already initialized info. presorted_keys was also unnecessarily reset to NULL.Patch by James Coleman, based on patches by Laurenz Albe and Tom Lane.Backpatch to 13, where Incremental Sort was introduced.Author: James Coleman, Laurenz Albe, Tom LaneReported-by: Laurenz Albe, Zu-Ming JiangBackpatch-through: 13Discussion:https://postgr.es/m/b2bd02dff61af15e3526293e2771f874cf2a3be7.camel%40cybertec.atDiscussion:https://postgr.es/m/db03c582-086d-e7cd-d4a1-3bc722f81765%40inf.ethz.ch
1 parent537b70b commit3ce761d

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

‎src/backend/executor/nodeIncrementalSort.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,6 @@ ExecReScanIncrementalSort(IncrementalSortState *node)
11381138
node->outerNodeDone= false;
11391139
node->n_fullsort_remaining=0;
11401140
node->bound_Done=0;
1141-
node->presorted_keys=NULL;
11421141

11431142
node->execution_status=INCSORT_LOADFULLSORT;
11441143

@@ -1151,15 +1150,9 @@ ExecReScanIncrementalSort(IncrementalSortState *node)
11511150
* cause a leak.
11521151
*/
11531152
if (node->fullsort_state!=NULL)
1154-
{
11551153
tuplesort_reset(node->fullsort_state);
1156-
node->fullsort_state=NULL;
1157-
}
11581154
if (node->prefixsort_state!=NULL)
1159-
{
11601155
tuplesort_reset(node->prefixsort_state);
1161-
node->prefixsort_state=NULL;
1162-
}
11631156

11641157
/*
11651158
* If chgParam of subnode is not null, theni the plan will be re-scanned

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp