Repository navigation
feat(qwp): add per-query timeout to the query client - #105
Open
bluestreak01 wants to merge 16 commits into
Open
bluestreak01 wants to merge 16 commits into
bluestreak01 wants to merge 16 commits into
Conversation
Adds a query timeout to QwpQueryClient and the QuestDB facade: query_timeout_ms (connection-string default), Query.timeout(...) per handle, and an execute() overload with an explicit timeout. A timed-out query ends with the new STATUS_QUERY_TIMEOUT (QueryException.isTimeout()) on a connection that stays open and authenticated for the next query. - A server advertising the new CAP_QUERY_TIMEOUT (0x08) capability gets the remaining budget as a timeout_ms field after query_flags (QUERY_FLAG_TIMEOUT, 0x02) and ends the query itself with STATUS_QUERY_TIMEOUT (0x0E). Older servers are cancelled by the client at the deadline; the cancellation is reported as the same status. - Once the deadline passes no further result batch reaches the handler. Discarded batches are still decoded, keeping the connection-scoped SYMBOL dict in step with the server. - If the server does not end the query within the grace period (query_close_timeout_ms on the facade), the caller is released anyway and the connection drains the aborted query in the background. Only a connection that stays silent through a second grace period is closed. - The deadline spans failover: replays carry the remaining budget, the backoff and every reconnect step are bounded by it, and a reconnect it cut short is retried by the next execute() instead of leaving the client disconnected. Pool: Query.close() waits for a worker still draining a timed-out query before returning it, discards a worker whose connection failed, and a cancel issued while a submission waits behind such a drain is no longer lost. The server side (decoding timeout_ms, the breaker timeout, the status mapping and the capability advert) lands in a tandem questdb PR.
bluestreak01
marked this pull request as ready for review
October 7, 2026 13:50
A query that ended early on the client side left its remaining frames on the connection, and the next query read them as its own result. This fixes the three ways in. Handler throws on a query timeout. At the end of the grace period execute() reports the timeout through onError while the aborted query still runs on the connection. If onError threw, execute() skipped the drain that follows. FailoverProbeHandler now holds the exception, executeOnce keeps draining as it does for a handler that returns, and executeImpl rethrows the original throwable once the drain ends or the connection is given up. The facade worker reports an exception that escapes execute() as the outcome of the current submission. Rethrown after the drain, it could land after the caller, already released by the timeout, had submitted again on the same Query, and complete that newer submission with the old exception. QueryImpl now numbers submissions, and runOn() reports an escaping exception only while its own submission is current. The check and the report share doneLock with submit(). This also closes the same race, until now microseconds wide, for a handler that throws from onEnd or onExecDone. Handler throws from onBatch, or the thread is interrupted. The I/O thread now stamps every event of a query with that query's request id; connection-level events carry QueryEvent.ANY_REQUEST and still reach whichever query waits. executeOnce skips the events of other queries, so the next query no longer receives the leftovers of an abandoned one, and it handles its own deadline even while leftovers keep coming. An attempt that ends before its query's last event now cancels that query, so the leftovers stop coming. While the I/O thread still works through an abandoned query, the next query can be queued and cancelled. The I/O thread sent that CANCEL at once, ahead of the query itself, and the server drops a cancel of a query it does not know, so the cancel was lost. drainPendingCancel now sends only a cancel of the query it serves, holds one of a later query, and drops one of a query that has already ended. Interrupt before the I/O thread encodes the request. execute() returned while the I/O thread could still read the request holder, the bind buffer and the caller's SQL text, and the next execute() overwrote them: the interrupted query was never sent and the next one was sent twice, possibly mixing the two queries' SQL and binds. With leftovers of an abandoned query on the connection, the next execute() could also block forever on the single request slot, while the I/O thread waited for it to release a leftover batch. An interrupted execute() now withdraws a request the I/O thread has not picked up yet, or waits for the encoding the I/O thread has started, before it reports the interrupt. An I/O thread still not done after shutdownJoinMs gives up the connection, as on a query timeout. Behavior visible to callers: an exception from onError at the end of the grace period now surfaces when the drain ends, up to one more grace period later, which is when execute() already returns for a handler that does not throw. A handler that throws from onBatch, or an interrupt, now cancels its query, and the next query skips that query's leftovers instead of returning them. A handler that does not throw sees no change, and the per-batch path gains only one field store on the I/O thread and one comparison on the reading thread. New tests drive each path against the scripted mock server, through both QwpQueryClient and the QuestDB facade.
glasstiger
added a commit
to questdb/nodejs-questdb-client
that referenced
this pull request
Oct 8, 2026
A query timeout rejected the caller the moment it expired, then cancelled the query. A statement that completed just past the deadline had taken effect but was reported as timed out, which invites a retry that applies it twice. The Java client's per-query timeout (questdb/java-questdb-client#105) waits for the server instead, and this client now does the same: - Once the timeout expires no further batch reaches the consumer and the query is cancelled, but the outcome waits up to one grace period, cancelDrainTimeoutMs, for the server's terminal response. EXEC_DONE, and a RESULT_END after which nothing was withheld, still succeed. A CANCELLED reply, or a result that lost a batch to the timeout, rejects with QwpEgressQueryTimeoutError. A server still silent after the grace period releases the caller with the timeout, and the session gives the connection up one period later. - The timeout runs from the query() call, so waiting for SERVER_INFO, for a previous query to drain or for a reconnect counts against it. A request whose timeout expires while a reconnect holds it is released at the deadline and never sent. - On a lost connection, a query past its timeout or whose consumer has retired is settled at once instead of being replayed only to be cancelled, and the cancel drain no longer runs without a connection. A reconnect longer than cancelDrainTimeoutMs used to fail the session. - A cancel the application issued before the timeout is reported as a cancellation, a query sends at most one CANCEL, and query() waits for a released query to finish draining instead of throwing "a QWP query is already active", which it did even right after breaking out of for await. The reconnecting egress connection now tells the session when it loses its connection, lets it drop a query from the replay and withdraw a request a reconnect still holds, and reports whether a terminal response is still queued: one that arrived before the connection went still decides the outcome. The session tests cover each outcome past the deadline, both grace periods, withheld materialized batches and views, an application cancel, the single CANCEL, the clock starting at query() and the wait behind a drain. The reconnect tests cover a timeout during an outage, a connection lost during the grace period, a draining query, a replayed application cancel, a terminal queued before the loss and a withdrawn request. README.md and QWP.md describe the behaviour, and query_close_timeout_ms is documented as the grace period too. The timeout is still enforced by the client alone; sending it to the server waits for questdb/questdb#7768. BREAKING CHANGE: a timed-out query is reported when the server ends it or after cancelDrainTimeoutMs, rather than at the deadline; a statement that completes past its timeout succeeds; the timeout includes the wait before the request is sent; and query() waits for a query that is still draining instead of throwing.
… acks TestWebSocketServer.ClientHandler.close(), called from a handler callback to script "ack N frames, then drop the wire", closed the socket while the client's pipelined frames were still unread. Linux then aborts the connection with an RST and discards everything not yet transmitted, including the acks the handler had just written (byte at a time, with Nagle on, so usually still queued). The client saw ECONNRESET without the acks. That made BackgroundDrainerMidDrainCapabilityGapTest .testDeliveringBetweenTwoGapWindowsGrantsAFreshSettleBudget fail intermittently in CI: with no durable-ack progress the settle budget never reset and the drainer quarantined the slot (FAILED, attempts=20). close() also joined its own read thread for 5s while the caller held the synchronized handler's monitor, stalling every other connection. A drop from the read thread now half-closes (shutdownOutput, so the FIN queues behind every frame already written), skips the self-join, and the read thread drains the client until it hangs up before closing the socket. Closing from any other thread is unchanged. TestWebSocketServerHandlerDropTest forces the race deterministically (unread inbound bytes plus acks queued behind a full client window). On Linux it fails without the fix with "framesReceived=0 of 2: Connection reset". In a stress run the original test failed 6/90 before the fix and 0/900 after; test classes that script drops lose their 5s stalls.
TestWebSocketServerHandlerDropTest sends a hand-written WebSocket upgrade request with the example Sec-WebSocket-Key from RFC 6455 section 1.3 (base64 of "the sample nonce"). Gitleaks' generic-api-key rule reads "...Key: <high-entropy token>" as a hardcoded API key and fails the PR. Add a .gitleaks.toml that extends the default config and allowlists only that exact value. All default rules stay active, and any other value in the same header is still reported. An allowlist in config is used instead of a .gitleaksignore fingerprint because fingerprints embed the commit SHA and stop matching after a squash merge.
No test pinned five of the ways a timed-out query can end: breaking any of them in QwpQueryClient.executeOnce left every test passing. - RESULT_END after a batch was withheld from the handler must report the timeout. Without the !discardedBatch check, a cut-off result is reported as complete: against a real server, onEnd(200000) fired after only 16,384 rows had reached the handler. - RESULT_END, EXEC_DONE or a connection failure that arrives while the connection drains, after the grace period released the caller, must not reach the handler. A second terminal callback completes the pooled submission queued behind the drain with the previous query's outcome: a later statement the server rejects is reported as done, or a later query fails with the old one's timeout. - A connection failure past the deadline, within the grace period, must still report the timeout. Without that callback a pooled Completion.await() never returns. The scripted server sends no frame on a timer. The handler that falls behind holds its first batch for the whole timeout, counted from inside onBatch(): execute() fixes the deadline on entry, so the hold always ends past it. Where the phase matters, the server ends the query in reply to the client's own CANCEL. The client sends an older server that CANCEL only once the deadline has passed, and a server that enforces the timeout only once the grace period has ended, so the reply always reaches the client in the phase under test. Breaking any of the five now fails exactly one new test. The new tests passed 20 sequential runs and 16 runs under full CPU load, and the timeout test classes pass on JDK 8 and JDK 25.
A query's terminal callback releases the caller while the worker thread is still returning from the job, and the worker clears its running flag only after that return. Query.close() waited for that flag on every close, with what was left of query_close_timeout_ms, and discarded the worker if the wait gave up. With query_close_timeout_ms=0, or with the caller's interrupt flag set, the wait gives up at once. A close that landed in that window shut a healthy worker down inside close(), and the next borrow reconnected (TCP, upgrade, auth). Over 2,000 borrow/await/close cycles on a one-worker pool, that opened 2 to 15 connections where the base branch opens 1. The wait is needed in one case only: after a query timeout, the client keeps draining the aborted query once the grace period has released the caller. QwpQueryClient now flags that drain. drainingTimedOutQuery is set right before the callback that releases the caller, so a close() that sees the query finished also sees the drain, and executeOnce() clears it when the drain ends. A drain that gives up on the connection latches the terminal failure before the flag clears, so the hasTerminalFailure() check still catches a dead connection. close() now waits only while that flag is set. Any other worker goes back to the pool at once, as it did before the query timeout. The run loop already runs a job dispatched while the previous one returns, and a finished job can no longer change the lease's state. Nothing new is written per query, and the common close() path drops two System.nanoTime() calls and a lock round-trip. Query.close() now documents the drain wait and the discard of a failed connection. Two QueryCloseDrainTest cases simulated a drain with running=true alone and now mark the client draining as well. New tests: - A zero-budget close and an interrupted close return a worker that is still returning from a completed job. Both fail deterministically without the fix. - An interrupted close still discards a worker that is draining. - 2,000 borrow/await/close cycles keep one connection, with no close budget and with the interrupt set. Without the fix they opened 8 and 10 connections. The touched test classes passed 5 runs in a row, the full core suite passes, the code compiles on JDK 8, and the javadoc builds on JDK 25.
mtopolnik
pushed a commit
to questdb/c-questdb-client
that referenced
this pull request
Oct 20, 2026
* feat(qwp): add per-query timeout to the reader Wires the protocol of questdb/questdb#7768 (server, open; tandem client semantics in questdb/java-questdb-client#105) through the Rust core, the C ABI and the C++ wrapper, so a caller can give one query its own budget instead of living with the server-wide `query.timeout` (60 s by default). dbt-style transforms — CTAS, `INSERT … SELECT`, `UPDATE` — routinely run longer than that, and raising `query.timeout` server-wide also changes behaviour for PGWire and HTTP clients. Protocol, as the server PR defines it: CAP_QUERY_TIMEOUT SERVER_INFO capability bit 0x08 QUERY_FLAG_TIMEOUT query_flags bit 0x02 timeout_ms varint, right after query_flags STATUS_QUERY_TIMEOUT QUERY_ERROR status 0x0E API: - `ReaderQuery::timeout(Duration)` per query, `query_timeout_ms` in the connect string as the per-reader default (`0` = none, the default). - C: `qwp_reader_query_set_timeout_ms`. C++: `query::timeout_ms(uint64_t)` and `query::timeout(std::chrono::duration)`. - New `ErrorCode::QueryTimeout` / `line_sender_error_query_timeout` (38), mirrored into the C and C++ headers and `ClientErrorCode`. Three decisions worth calling out: - **A timeout does not silently degrade.** `reset_symbol_dict` quietly no-ops against a server without `CAP_QUERY_FLAGS`; a timeout cannot, because dropping it leaves the caller believing it has a long budget while the server kills the query at `query.timeout`. `execute()` instead fails before anything reaches the wire, naming the missing capability and pointing at the server-side knob. This is the one deliberate divergence from #105, which keeps its own deadline and enforces the timeout client-side against an older server. - **"No timeout" is the field's absence, never a zero.** The server rejects a zero or negative `timeout_ms` with `STATUS_PARSE_ERROR`, so `build()` refuses a flag bit and a value that disagree rather than letting a malformed frame leave the process. - **A sub-millisecond duration rounds up to 1 ms.** Truncating it to zero would mean "no timeout" — the opposite of the ask. Matches `QueryImpl.setTimeout` in #105. `QueryTimeout` is not failover-eligible: a timeout is the server doing what it was told, and replaying a write risks applying a statement the first attempt may already have applied. A failover replay re-sends the original budget rather than the remainder, since this client keeps no deadline of its own; documented on `ReaderQuery::timeout` and pinned by a test. Tests: 21 Rust unit tests (capability predicates and bit distinctness, status-code round-trip and wire values, encoder trailer layout alone and combined with `QUERY_FLAG_RESET_DICT`, flag/value consistency, the request_id span surviving the trailer, duration conversion, the capability-gating truth table, status mapping, failover ineligibility, connect-string parsing); 10 C++ mock-server cases (byte-exact baseline with no timeout, the field on the wire, chrono rounding and zero, connect-string default applied per query, per-query override and clear, fail-fast with no request sent for both capability shapes, connection reuse after a timeout, failover replay budget); 2 pure-C cases (the appended error code's value and distinctness, and the new symbol linking and tolerating a NULL handle from plain C). * docs(egress): note what bounds a replayed timeout * style(egress): format the replay trailer assertion * fix(egress): enforce query timeouts during failover Reject timed query replay when the replacement server lacks the required capabilities instead of silently using its default timeout. Preserve the first terminal error when manual credit grants trigger failover. Cover replay rejection, persistent credit errors, and real Rust sub-millisecond timeout conversion with regression tests. * fix(egress): validate query timeout durations Reject non-finite chrono durations before integer conversion and saturate oversized timeouts to the server's signed wire range. Exercise production flag derivation from the capability matrix, add numeric regression tests, and clarify that the failover budget limits retry eligibility rather than end-to-end query duration. * chore(ci): install numpy 2 from pip on the hetzner agents pyarrow 26 requires NumPy 2, but the hetzner fuzz jobs installed Ubuntu's python3-numpy 1.26, so every Arrow suite failed to import. Install numpy from pip alongside pyarrow and polars instead. * fix(egress): refuse unsupported query timeouts as UnsupportedServer A server without CAP_QUERY_TIMEOUT now refuses a timed query with UnsupportedServer instead of QueryTimeout, so a caller that retries a timeout with a larger budget cannot loop against a server that ignores every budget. The refusal happens before anything is written, at execute() and before a failover replay, and leaves the connection usable. A stale-plan replay whose write fails now closes the connection, and connection_reusable() reports false for a cursor ended mid-stream by a client-side error, so a pool never recycles a transport that Drop is about to tear down. The C++ chrono timeout() rejects negative durations; only zero clears the timeout. Document ROWS_AFFECTED_UNKNOWN for statements that report no row count. * Add more tests * fix(ingress): shut down the original socket before cancelling I/O in the Windows traffic gate * test(e2e): stabilize orphan drainer failover replay --------- Co-authored-by: bluestreak <bluestreak@gmail.com> Co-authored-by: Vlad Ilyushchenko <bluestreak01@users.noreply.github.com>
# Conflicts: # core/src/main/java/io/questdb/client/cutlass/qwp/client/QwpQueryClient.java # core/src/main/java/io/questdb/client/impl/QueryWorker.java
Brings in the query options from #129 (row window, row counts, statistics, error positions) alongside the per-query timeout. - QwpQueryClient keeps both APIs: execute(..., boolean, long timeoutMs) and execute(..., QwpQueryOptions) plus a new execute(..., QwpQueryOptions, long timeoutMs) overload that QueryImpl uses to send the submitted options under the timeout. - resolveQueryFlags() also drops QUERY_FLAG_TIMEOUT when the server does not advertise CAP_QUERY_TIMEOUT. - QwpEgressIoThread encodes timeout_ms ahead of skip_rows and max_rows, in ascending order of the flag bits, and stamps the request id on the pooled terminator events. - Client-detected timeout errors go through deliverClientError(), so they reach the position-aware onError overload. - The test frame parser reads timeout_ms, and a new test pins the order of timeout_ms and the row window on the wire.
A failover reconnect made for a query with a timeout bounds each endpoint step by the time the query has left. The steps count whole milliseconds and can give up to 1ms before their bound: the native connect truncates its remaining time to whole milliseconds and treats 0 as expired. A step cut to the query's last millisecond could then fail just before the deadline, isPast() was still false, and execute() reported a failed reconnect (status 6) instead of the query timeout. testTimeoutWhileFailingOverIsReportedAsTimeout failed this way on Linux CI, where a loopback connect returns EINPROGRESS. boundToConnectDeadline() now adds 1ms to the time left, so a step the deadline cuts short ends past the deadline. A new test pins that invariant without depending on connect timing.
The client treated the query timeout as a deadline the server had to meet: past it, it discarded result batches, sent its own CANCEL, and after two grace periods dropped a healthy connection and blamed the server. A server cannot always stop a query, so a slow query broke the connection, and with failover=off left the client unusable. The timeout now only travels with the query to a server that advertises CAP_QUERY_TIMEOUT, overriding its query.timeout. The client keeps no deadline of its own and waits for the server's answer however long it takes; every batch, EXEC_DONE or error the server sends reaches the handler. Failover replays send the same timeout. An older server gets no timeout and applies its own default. Removed the grace period (withQueryTimeoutGrace), the drain state and the facade's wait for it, the client-side CANCEL and timeout errors, and the deadline bound on failover reconnects. Kept the skipping of an abandoned query's leftovers, giving up on a stuck I/O thread after an interrupt, and Query.close() discarding a failed connection.
6856c34 removed the client's own query deadline: the timeout only travels with the query, and the server gets it as given. Two tests this branch added still assumed the deadline. testTimeoutGoesAheadOfTheRowWindow accepted any timeout_ms in (29_000, 30_000] as "the budget left", so a client that sent the time left instead of the timeout passed it. It now asserts the exact value for 30_000, Long.MAX_VALUE - 1 and Long.MAX_VALUE. A time left that the client counts down never comes back as Long.MAX_VALUE, so the two largest values catch that regression even when no millisecond passes before the request goes out. The javadoc that merge 61d6bed left on this test moves back onto the test it describes, testWireBitsAreDistinctAndLeaveTimeoutBitsFree. testUserCancelIsReportedAsCancel sent a 200 ms timeout to a server without CAP_QUERY_TIMEOUT and acknowledged the cancel 400 ms later, to race the cancel against the client deadline. Without the deadline the timeout never reached the wire, and nothing raced. The test now sends no timeout to a server that supports one, and the mock streams one batch, then answers the CANCEL at once: the real server acts on a CANCEL only while the query streams. Besides the CANCELLED status the test asserts the batch, the server's message, a single terminal callback, and that the same connection runs the next statement. A client that sends the timeout less 500 ms fails the first test, which the old range let pass. A client that sends a rounded-up time left fails it on Long.MAX_VALUE - 1, while every test of QwpQueryClientQueryTimeoutTest and QueryTimeoutFacadeTest passes. Reporting the cancel with another status, changing its message, or dropping the CANCEL from cancel() fails the second test.
QwpQueryClientQueryTimeoutTest and QueryTimeoutFacadeTest encoded the egress server frames (EXEC_DONE, QUERY_ERROR, RESULT_BATCH, RESULT_END) and decoded the client's QUERY_REQUEST with private copies of what the shared QwpEgressFrames helper provides, and duplicated each other's VARCHAR batch builder. Both classes predate QwpEgressFrames (client PR #129); the merge that brought it in did not move them onto it, so the egress wire layout lived in three places. Both classes now build their frames inline with QwpEgressFrames and decode requests with QwpEgressFrames.parseQueryRequest, as QwpQueryClientQueryFlagsTest does; QwpEgressFrames itself does not change. The timeout test gains ScriptedServer.takeQuery(), which decodes on the test thread and keeps the old "the trailer must end the frame" check (trailingBytes == 0). Its server thread still reads only the request id (requestIdOf), which QwpEgressFrames has no reader for. The facade's Script decodes on the server read thread, where timeoutOf ran. The mocks now send LONG batches and a RESULT_END whose final_seq is the last batch_seq, as the server does; no test reads a column, final_seq or total_rows. trailerOf's "test frames carry no binds" check goes away with trailerOf: it was the helper's own precondition, since it could not skip binds, while parseQueryRequest decodes them. QueryTimeoutFacadeTest also rewrites the javadoc of assertCloseKeepsTheConnectionOfCompletedQueries, which named QueryCloseDrainTest cases that 6856c34 deleted, to say what the 2,000 cycles guard; adds the missing blank lines between members; and drops the unused Completion import. Tests: the 16 + 8 rewritten tests pass, as do QwpQueryClientQueryFlagsTest and QwpEgressTerminatorDecodeTest, and the two classes pass 20 repeated runs. Mutations of the client fail them: the timeout value, the CAP_QUERY_TIMEOUT gating, trailing bytes after the trailer, batch delivery, the error status and message, RESET_DICT, timeout 0, the CANCEL's request id and the SQL text each fail the rewritten assertion they target; a broken withdraw fails testInterruptedQueryNotYetSentIsWithdrawn. Both files compile with javac --release 8.
This was referenced Nov 30, 2026
ideoma
added a commit
to questdb/questdb
that referenced
this pull request
Dec 1, 2026
Point java-questdb-client at the head of questdb/java-questdb-client#105, which now carries the fixed timeout tests: exact timeout assertions, a plain cancel test, and request decoding through QwpEgressFrames.
Query.abandon() discards the handle's configuration, but it kept the timeout set with Query.timeout(), so the next query still sent it. QueryImpl.abandon() now restores the client default, like resetForBorrow() does. Also add regression tests for two paths no test covered: - a cancel issued while the submission waits for the worker must still reach its query (QueryImpl.applyBinds re-applies it); - the server's STATUS_CANCELLED reply to an abandoned query must not become the next query's outcome (QwpEgressIoThread tags errors with their request id). Each test fails when its production line is removed.
QueryTimeoutExample described the removed client-side deadline. It now says the client only sends the timeout and the server enforces it.
Contributor
Review (level 3)Verdict: approve with comments. Reviewed at CriticalNone. Moderate1. No test fails if the request id is dropped from EXEC_DONE replies
Fixed (pushed in
|
No test failed when EXEC_DONE lost its request id. The new test checks that each statement after an interrupted one gets its own row count.
Contributor
[PR Coverage check]😍 pass : 170 / 180 (94.44%) file detail
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tandem: questdb/questdb#7768 (server side).
Purpose
Let users override the server's default query timeout (
query.timeout) for a single query or for a whole connection.Impact
query_timeout_msoverrides the server default for every query on the connection;Query.timeout()overrides it for one query.Queryinterface must addtimeout().How
The client sends the timeout with the query, only to servers that advertise
CAP_QUERY_TIMEOUT. The server enforces it instead ofquery.timeoutand reportsSTATUS_QUERY_TIMEOUT, whichQueryException.isTimeout()tests.When
execute()returns early because the handler threw or the caller was interrupted, the client cancels that query and drops its remaining results. A cancel that arrives before the pool starts the query is no longer lost.