forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitdc40ca6
committed
Fix query-duration memory leak with GIN rescans.
The requiredEntries / additionalEntries arrays were not freed infreeScanKeys() like other per-key stuff.It's not obvious, but startScanKey() was only ever called after the keyshave been initialized with ginNewScanKey(). That's why it doesn't need toworry about freeing existing arrays. The ginIsNewKey() test in gingetbitmapwas never true, because ginrescan free's the existing keys, and it's not OKto call gingetbitmap twice in a row without calling ginrescan in between.To make that clear, remove the unnecessary ginIsNewKey(). And just to beextra sure that nothing funny happens if there is an existing key after all,call freeScanKeys() to free it if it exists. This makes the code morestraightforward.(I'm seeing other similar leaks in testing a query that rescans an GIN indexscan, but that's a different issue. This just fixes the obvious leak withthose two arrays.)Backpatch to 9.4, where GIN fast scan was added.1 parentcb01685 commitdc40ca6
File tree
3 files changed
+20
-7
lines changed- src
- backend/access/gin
- include/access
3 files changed
+20
-7
lines changedLines changed: 7 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
560 | 560 |
| |
561 | 561 |
| |
562 | 562 |
| |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
563 | 567 |
| |
564 | 568 |
| |
565 | 569 |
| |
| |||
1763 | 1767 |
| |
1764 | 1768 |
| |
1765 | 1769 |
| |
1766 |
| - | |
1767 | 1770 |
| |
1768 | 1771 |
| |
1769 | 1772 |
| |
1770 | 1773 |
| |
1771 | 1774 |
| |
1772 | 1775 |
| |
1773 | 1776 |
| |
| 1777 | + | |
1774 | 1778 |
| |
1775 | 1779 |
| |
1776 | 1780 |
| |
1777 | 1781 |
| |
1778 | 1782 |
| |
1779 | 1783 |
| |
1780 | 1784 |
| |
1781 |
| - | |
1782 |
| - | |
| 1785 | + | |
| 1786 | + | |
1783 | 1787 |
| |
1784 | 1788 |
| |
1785 | 1789 |
| |
|
Lines changed: 12 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
163 | 163 |
| |
164 | 164 |
| |
165 | 165 |
| |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
166 | 170 |
| |
167 | 171 |
| |
168 | 172 |
| |
| |||
223 | 227 |
| |
224 | 228 |
| |
225 | 229 |
| |
226 |
| - | |
227 |
| - | |
| 230 | + | |
| 231 | + | |
228 | 232 |
| |
229 | 233 |
| |
230 | 234 |
| |
| |||
237 | 241 |
| |
238 | 242 |
| |
239 | 243 |
| |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
240 | 248 |
| |
241 | 249 |
| |
242 | 250 |
| |
| |||
416 | 424 |
| |
417 | 425 |
| |
418 | 426 |
| |
419 |
| - | |
| 427 | + | |
420 | 428 |
| |
421 | 429 |
| |
422 | 430 |
| |
| |||
434 | 442 |
| |
435 | 443 |
| |
436 | 444 |
| |
437 |
| - | |
| 445 | + | |
438 | 446 |
| |
439 | 447 |
| |
440 | 448 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
890 | 890 |
| |
891 | 891 |
| |
892 | 892 |
| |
| 893 | + | |
893 | 894 |
| |
894 | 895 |
| |
895 | 896 |
| |
|
0 commit comments
Comments
(0)