Commit 930175f
committed
fix(qwp): transfer slot cleanup to the worker's exit path and recover retired pool slots
When an owned manager's bounded join timed out during engine close, the
engine leaked ring + watermark mmaps and the slot flock until process
exit, the sender latched slotLockReleased=false forever, and SenderPool
retired the slot permanently (leakedSlots++) - a transiently-slow SF
filesystem op at close time (> workerJoinTimeoutMillis, default 5 s)
permanently ratcheted pool capacity down, even though the worker often
exits moments later.
- new SegmentManager.deferUntilWorkerExit(cleanup): hands an action to
the worker-loop exit block, which runs strictly after the final
service pass - the last point the worker can touch any slot path.
Registration and the exit block's workerLoopExited flip share the
manager lock, so the handoff is exactly-once: accepted while the
worker is live, rejected (caller cleans up inline) once it exited
- CursorSendEngine.close(): on an owned-manager join timeout, terminal
cleanup (ring, watermark, drained-file unlink, flock release) now
transfers to the worker's exit path instead of leaking; the quiescence
gate is unchanged - the slot stays locked until the pass provably ends
- exactly-once via a terminalCleanupClaimed CAS, deliberately not the
engine monitor: a retried close() holds the monitor while joining the
worker, and the worker cannot die until its cleanup returns -
monitor-based exclusion would stall that close() for its full join
budget. With the CAS the worker never blocks and the join returns as
soon as the pass ends
- QwpWebSocketSender.isSlotLockReleased() is now monotonic, not frozen:
it re-probes the retained engine (volatile reads only, safe under the
pool lock) and flips true once the deferred cleanup - worker exit path
or delegated I/O-thread close - releases the flock
- SenderPool re-probes retired slots (housekeeper reapIdle tick and
capacity-starved borrows just before parking) and returns a recovered
index to the free set: leakedSlots goes back down and a would-be
borrow timeout becomes an immediate creation. A persistent non-zero
leakedSlotCount() now means a genuinely wedged worker
- shared-manager engines (test-only construction) keep the old
leak-and-retry-close contract: their worker serves other rings and has
no exit to defer to; startup-recovery retirements also stay permanent
- regression: deferUntilWorkerExit contract test, owned-close handoff
test (slot reacquirable after worker exit with NO close() retry), pool
recovery via reapIdle and via capacity-starved borrow; the
SlotLockReleasedContractTest leak-path pin updated to the new
monotonic-getter contract1 parent 7cf9612 commit 930175f
8 files changed
Lines changed: 697 additions & 111 deletions
File tree
- core/src
- main/java/io/questdb/client
- cutlass/qwp/client
- sf/cursor
- impl
- test/java/io/questdb/client/test
- cutlass/qwp/client
- sf/cursor
- impl
Lines changed: 64 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
285 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
286 | 295 | | |
287 | 296 | | |
288 | 297 | | |
| |||
1190 | 1199 | | |
1191 | 1200 | | |
1192 | 1201 | | |
1193 | | - | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
1200 | | - | |
1201 | | - | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
1206 | 1209 | | |
1207 | | - | |
1208 | | - | |
1209 | | - | |
1210 | | - | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
1211 | 1229 | | |
1212 | 1230 | | |
1213 | 1231 | | |
| |||
1257 | 1275 | | |
1258 | 1276 | | |
1259 | 1277 | | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
1260 | 1282 | | |
| 1283 | + | |
1261 | 1284 | | |
1262 | 1285 | | |
1263 | 1286 | | |
| |||
1306 | 1329 | | |
1307 | 1330 | | |
1308 | 1331 | | |
1309 | | - | |
1310 | | - | |
1311 | | - | |
1312 | | - | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
1313 | 1343 | | |
1314 | 1344 | | |
1315 | | - | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
1316 | 1356 | | |
1317 | 1357 | | |
1318 | 1358 | | |
| |||
0 commit comments