| From: | Raja Sai pranav <rajasaipranav0(at)gmail(dot)com> |
|---|---|
| To: | allen2hsu(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19917: nbtree skip scan leaks one copy of a pass-by-reference skip array element per rescan |
| Date: | 2026-11-21 08:27:21 |
| Message-ID: | CAPHduZCr1=5T7Q3Fvj_zPnkzb2HjOcZvvktYQe7nUi8qE1u=Yw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hi,
Thanks for the detailed report. I reproduced it on master (4a26e36f87) and
REL_18_STABLE with a smaller version of your script: 100,000 rescans grow
ExecutorState by 3.2 MB with a uuid column and by 8 MB with a text(32)
column.
The attached patch frees each skip array's current element in btrescan()
and btendscan(), when the array's type is passed by reference. That covers
every place the element is allocated (set_element, increment, decrement,
the low/high copies and the parallel restore) without changing them.
btbeginscan() now sets numArrayKeys to 0, because btrescan() reads it
before setting it.
With the patch, ExecutorState stays flat in both cases. regress, isolation,
amcheck, btree_gist, pg_upgrade and recovery pass on master with assertions
enabled, and regress, isolation, amcheck and pg_upgrade on REL_18. I didn't
add a regression test, since the leak shows only in memory use.
v1 is for master; the REL_18 version is the same change.
Regards,
Sai Pranav
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-memory-leak-of-skip-array-elements-across-btr.patch | application/octet-stream | 2.8 KB |
| REL_18-v1-0001-Fix-memory-leak-of-skip-array-elements-across-btr.patch | application/octet-stream | 2.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Laurenz Albe | 2026-11-21 08:43:11 | Re: BUG #19927: PostgreSQL 16: SQL dump adds experimental/incompatible options like \restrict |
| Previous Message | Raja Sai pranav | 2026-11-21 07:28:14 | Re: BUG #19790: "cannot start a subtransaction ... inval messages" after "ALTER DOMAIN ... DROP CONSTRAINT" |