You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
QwpQueryClient.close() hangs 5 s and leaks after onBatch throws #134
QwpQueryClient.close() hangs 5 s and leaks after onBatch throws
Repository: questdb/java-questdb-client. Found while reviewing questdb/questdb#7768 with #105 (client head 564542a, base 58e556f). Probe sources and logs: /tmp/review-pr-FxgkGl/probes/F5/.
Problem:close() hangs 5 s and leaks the I/O thread after a handler throws.
Net impact: each occurrence leaks a thread, native buffers and a connection.
Location: java-questdb-client QwpEgressIoThread.handleResultBatch L732-758 (base L674-697) and QwpQueryClient.close() L680-711.
Symptom:onBatch throws on a batch of a multi-batch result, and no further execute() runs on that client. Then close() blocks for shutdownJoinMs (5 s) and logs "close timed out ... a batch handler that never returns". It also sets wasLastCloseTimedOut() and leaves the qwp-egress-io thread parked. The batch-buffer pool and the WebSocket stay open, and so does the server side of the connection. QuestDB.close() does the same for a pooled worker whose handler threw.
Origin: pre-existing. A probe gave the same result at client base 58e556ff and at head 564542a9: a 5,000 ms close, the flag set, the I/O thread WAITING and the TCP connection still ESTABLISHED. A later execute() on the same client avoids it.
Reachability:
The handler throws, and executeOnce releases the current batch (QwpQueryClient L2324).
The I/O thread reads the next batch, publishes it, and waits without interruption on pendingRelease.take() (QwpEgressIoThread L748-755). Nobody consumes the event.
close() interrupts the thread, but the wait swallows the interrupt, and join(5 s) expires.
The leak branch then skips closePool() and webSocketClient.close().
The producer is any handler exception, such as a validation failure or an application bug, followed by close().
Suggested fix: before joining, have close() release the batches the I/O thread has published, as abandonConnection already does. Alternatively, make the release wait give up once shutdown is set.
Severity if filed standalone: Critical. The leak grows with each repeat, and close() blocks 5 s per affected client.
Activity