Skip to content

[ES-1717770] Fix timeout exception during fetch results - #1199

Merged
samikshya-db merged 4 commits into
databricks:mainfrom
samikshya-db:samikshya-chand_data/helloagain
Feb 5, 2026
Merged

samikshya-db merged 4 commits into
databricks:mainfrom
samikshya-db:samikshya-chand_data/helloagain

Conversation

@samikshya-db

@samikshya-db samikshya-db commented Feb 5, 2026 •

Copy link
Copy Markdown
Collaborator

Description

  • This fix was made in the PR #1135, but it did not consider the fetch result timeout. This PR fixes that.

Testing

  • unit tests

Additional Notes to the Reviewer

  • Most of the code changes are propogating errors as SQLException, but the main code change is a small one and is present in src/main/java/com/databricks/jdbc/common/util/DatabricksThriftUtil.java file

OVERRIDE_FREEZE=true

@samikshya-db samikshya-db changed the title Fix timeout exception during fetch results [ES-1717770] Fix timeout exception during fetch results Feb 5, 2026

@vikrantpuppala vikrantpuppala left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: does this only update DatabricksSQLException -> SQLException in the paths that need to propogate the SQLTimeoutException or everywhere?

@sreekanth-db sreekanth-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@samikshya-db

Copy link
Copy Markdown
Collaborator Author

Thanks for the review, @vikrantpuppala

Does this only update DatabricksSQLException -> SQLException in the paths that need to propogate the SQLTimeoutException or everywhere?

Yes, the propogation errors had me changing at most places.

@samikshya-db
samikshya-db merged commit b9f4dc1 into databricks:main Feb 5, 2026
12 of 14 checks passed
@samikshya-db
samikshya-db deleted the samikshya-chand_data/helloagain branch February 5, 2026 06:36
samikshya-db added a commit that referenced this pull request Mar 16, 2026
…e clusters (#1244)

## Description

Follow-up to #1199 ([ES-1717770]). The previous fix covered the case
where `FetchResults` returns an error status with `sqlState=57KD0`.
However, the interactive cluster path was still broken.

**Root cause:** When using interactive clusters with
`enableDirectResults=true`, the cluster can enforce its own server-side
query timeout and return `TIMEDOUT_STATE` directly in
`directResults.operationStatus` — before the client's polling loop ever
starts. Because `isErrorOperationState` did not include
`TIMEDOUT_STATE`, the driver:

1. Did not throw in `checkOperationStatusForErrors`
2. `shouldContinuePolling(TIMEDOUT_STATE)` returned false → polling loop
never started → `TimeoutHandler` never fired
3. Fell through to `executeFetchRequest` → server returned an error →
driver threw `DatabricksHttpException` instead of
`DatabricksTimeoutException`

The same gap also affects the polling path when `GetOperationStatus`
returns `TIMEDOUT_STATE` during polling.

**Fix:**
- Add `TIMEDOUT_STATE` to `isErrorOperationState`
- Throw `DatabricksTimeoutException` for `TIMEDOUT_STATE` in
`checkOperationStatusForErrors` regardless of whether `sqlState` is set
(interactive clusters do not always populate it)

## Testing

- `testTimedOutStateInDirectResultsThrowsTimeoutException` — Pavan's
exact repro: server returns `TIMEDOUT_STATE` in `directResults` before
polling starts
- `testTimedOutStateDuringPollingThrowsTimeoutException` — server
returns `TIMEDOUT_STATE` during polling

## Additional Notes

The original ES-1717770 verification test passed on both warehouse and
all-purpose cluster because `setQueryTimeout(1)` with a long-running
query caused the server to return `RUNNING_STATE` first (query still
in-flight), entering the polling loop where `TimeoutHandler` fired
correctly. Pavan's repro consistently hits the other path: the cluster's
own timeout fires first, returning `TIMEDOUT_STATE` directly, bypassing
the polling loop entirely.

[ES-1717770]:
https://databricks.atlassian.net/browse/ES-1717770?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Signed-off-by: Samikshya Chand <[email protected]>
Signed-off-by: samikshya-chand_data <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants