Commit 31066e1
committed
fix(qwp): free native path-scratch sink when engine/manager construction fails
Two constructor-throw paths leaked SegmentManager's 256-byte native
pathScratch sink (NATIVE_DIRECT_UTF8_SINK) per failed construction:
- CursorSendEngine: the delegating constructors evaluate
new SegmentManager(...) BEFORE the private ctor body runs, so a
pre-try throw (slot lock collision -- 'already in use', or empty
sfDir) orphaned the owned manager. A submit/close race in the
drainer pool leaked 1546 sinks (395,776 bytes) in a single test run;
any client retrying fromConfig against a locked slot leaks 256 bytes
per attempt. The pre-try section now closes an owned manager before
propagating, and the main catch closes it regardless of whether
start() was reached (close on an unstarted manager is safe -- no
worker to join, just frees the scratch).
- SegmentManager: the pathScratch field initializer has already
allocated by the time the ctor's validation throws fire
(segmentSizeBytes/maxTotalBytes too small). Both throws now close
the sink first.
Found by tightening the test leak-check (follow-up commits); pinned by
the existing suite going green under strict per-tag accounting.1 parent b827c55 commit 31066e1
2 files changed
Lines changed: 33 additions & 11 deletions
File tree
- core/src/main/java/io/questdb/client/cutlass/qwp/client/sf/cursor
Lines changed: 27 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
150 | 171 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | 172 | | |
158 | 173 | | |
159 | 174 | | |
| |||
168 | 183 | | |
169 | 184 | | |
170 | 185 | | |
171 | | - | |
172 | 186 | | |
173 | 187 | | |
174 | 188 | | |
| |||
277 | 291 | | |
278 | 292 | | |
279 | 293 | | |
280 | | - | |
281 | 294 | | |
282 | 295 | | |
283 | 296 | | |
| |||
288 | 301 | | |
289 | 302 | | |
290 | 303 | | |
291 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
292 | 308 | | |
293 | 309 | | |
294 | 310 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
146 | 150 | | |
| 151 | + | |
147 | 152 | | |
148 | 153 | | |
149 | 154 | | |
| 155 | + | |
150 | 156 | | |
151 | 157 | | |
152 | 158 | | |
| |||
0 commit comments