Commit b2af201
Fix SEA result expiry error handling — preserve server error message (#1302)
## Summary
When query results expire after the retention period, the SEA server
returns HTTP 404 with a descriptive `NOT_FOUND: The result of the
statement <id> was not found.` message. The SDK client throws
`DatabricksError` (extends `RuntimeException`) which was not caught by
`getResultChunks`/`getResultChunksData` — they only caught
`IOException`.
This caused three problems:
1. **Server error message lost**: `DatabricksError` escaped uncaught,
and the `ChunkDownloadTask` finally block created a new exception
without chaining the original cause — customer sees `"Download failed
for chunk index N"` with no indication of why
2. **Download tasks hang indefinitely**: In `ChunkLinkDownloadService`,
the uncaught `RuntimeException` left link futures unresolved, blocking
download tasks forever on `future.get()`
3. **Inconsistent with other methods**: `createSession` already catches
`DatabricksError` properly — `getResultChunks`/`getResultChunksData`
should follow the same pattern
## Changes
- **`DatabricksSdkClient.java`**: Add `catch (DatabricksError e)` in
`getResultChunks()` and `getResultChunksData()`, wrapping into
`DatabricksSQLException` with HTTP status code and server message
preserved
- **`ChunkLinkDownloadService.java`**: Widen catch from `SQLException`
to `Exception` so `DatabricksError` completes link futures exceptionally
instead of leaving them unresolved
- **`ChunkDownloadTask.java`**: Chain `uncaughtException` as cause in
the finally block so the original error propagates to the caller
- **`ChunkLinkDownloadServiceTest.java`**: Fix `testHandleExpiredLinks`
to mock subsequent chunks needed by batch continuation
## What customers see after this fix
- **Before**: `SQLException: "Download failed for chunk index N"` (no
server message, potential hang)
- **After**: `SQLException: "Error fetching result chunks for statement
[id] chunk [N] (HTTP 404): NOT_FOUND: The result of the statement <id>
was not found."` (with full cause chain)
## Test plan
- [x] Full jdbc-core suite: 3170 tests pass, 0 failures
- [x] `ChunkLinkDownloadServiceTest` — 8 tests pass (including fixed
`testHandleExpiredLinks`)
This pull request was AI-assisted by Isaac.
---------
Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 7592f65 commit b2af201
6 files changed
Lines changed: 99 additions & 3 deletions
File tree
- src
- main/java/com/databricks/jdbc
- api/impl/arrow
- dbclient/impl/sqlexec
- test/java/com/databricks/jdbc
- api/impl/arrow
- dbclient/impl/sqlexec
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
289 | | - | |
290 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
291 | 294 | | |
292 | 295 | | |
293 | 296 | | |
| |||
299 | 302 | | |
300 | 303 | | |
301 | 304 | | |
302 | | - | |
| 305 | + | |
303 | 306 | | |
304 | 307 | | |
305 | 308 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
491 | 498 | | |
492 | 499 | | |
493 | 500 | | |
| |||
541 | 548 | | |
542 | 549 | | |
543 | 550 | | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
544 | 558 | | |
545 | 559 | | |
546 | 560 | | |
| |||
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
130 | 153 | | |
131 | 154 | | |
132 | 155 | | |
| |||
167 | 190 | | |
168 | 191 | | |
169 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
170 | 205 | | |
171 | 206 | | |
172 | 207 | | |
| |||
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1103 | 1103 | | |
1104 | 1104 | | |
1105 | 1105 | | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
1106 | 1148 | | |
0 commit comments