fix(thrift): retry transient transport failures on GetOperationStatus/CloseOperation polls - #1643
Open
diegofanesi wants to merge 1 commit into
Open
Conversation
diegofanesi
marked this pull request as draft
August 16, 2026 11:30
Author
|
tests completed. ready to merge on my end. I run 3 parallel tests on three large warehouses for a total of almost 10000 queries launched in parallel on a 10 TB dataset. this lasted 24h and I had only 1 query failure related to a different issue. Normally I would have seen multiple queries failing under such conditions. I can conclude that the stability has been improved significantly with this patch. |
diegofanesi
marked this pull request as ready for review
August 18, 2026 05:04
…l polls Long-running queries on the Thrift client path (UseThriftClient=1) could fail with "Query has been timed out due to inactivity" under sustained concurrency. A single stale pooled connection or TCP reset on a GetOperationStatus poll abandoned the still-running server operation, and the same failure class on CloseOperation/CancelOperation could leak completed operations until the server reaped them. These idempotent RPCs now run through a bounded, jittered exponential-backoff retry that reconnects on a fresh pooled connection before surfacing the error. Statement submission is deliberately excluded from the retry path to avoid double-execution. The SEA client path is unchanged. Co-authored-by: Isaac
diegofanesi
force-pushed
the
fix/thrift-transport-poll-retry
branch
from
August 18, 2026 05:07
162bba5 to
24f70d2
Compare
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.
Summary
Fixes #1642.
Long-running queries on the Thrift client path (
UseThriftClient=1) could fail withQuery has been timed out due to inactivityunder sustained concurrency. A single transient transport-level failure (stale pooled connection, TCP reset, load-balancer idle drop) on aGetOperationStatuspoll abandoned the still-running server operation — the driver surfaced aTTransportExceptionand stopped polling, so the server kept running the query until its inactivity window elapsed and reaped it. The same failure class onCloseOperation/CancelOperationcould leak completed operations until the server reaped them too.Root cause
DatabricksHttpRetryHandler.retryRequestonly retries HTTP status-code errors (429/503) that arrive wrapped in aDatabricksRetryHandlerException. A rawIOException(stale pooled connection, connection reset) maps to status code0viagetErrorCodeFromException, whichisStatusCodeRetryablerejects — so it is never retried. The Thrift polling loop inDatabricksThriftAccessorhas no retry of its own either, so one transient poll failure permanently abandons an otherwise-healthy server operation.Change
Adds a bounded, jittered exponential-backoff retry (
withTransportRetry) inDatabricksThriftAccessorand routes the idempotent Thrift RPCs through it:GetOperationStatus— both the main execution polling loop and the metadata polling loop (also covers the Thrift heartbeat, which shares the same accessor method)CloseOperationandCancelOperationEach RPC invocation builds a fresh transport, so a retry naturally leases a new pooled connection while the broken one is discarded. This lets a still-running server operation be re-polled — or a completed one be re-closed / cancelled — instead of being abandoned after a single connection blip.
Details:
TTransportExceptionis rethrown once retries are exhausted, so existing caller-side failure handling (buildTransportFailureException, etc.) is fully preserved.TExceptions propagate on the first attempt.ExecuteStatement) is deliberately excluded from the retry path — re-sending it could double-execute the query. Only read-only / idempotent RPCs retry.Scope
UseThriftClient=1). All changes live inDatabricksThriftAccessor.IOExceptionvia the SDK's idempotent-request retry strategy (GET /api/2.0/sql/statements/*is treated as idempotent, and anIOExceptionmaps to a retriable synthetic523).Files changed
src/main/java/com/databricks/jdbc/dbclient/impl/thrift/DatabricksThriftAccessor.java— retry helper + call-site wiringNEXT_CHANGELOG.md—FixedentryTesting
spotlesscheck. Ifspotlessflags formatting, it is cosmetic and auto-fixable withmvn spotless:apply.This pull request and its description were written by Isaac.