Skip to content

Adds unified retry handling for all Thrift operations using wrapTCLICall() method, bringing Thrift under the same retry framework as HTTP operations.#3

Open
nishkarsh-db wants to merge 1 commit intoUnified_Retry_3from
Unified_Retry_4
Open

Adds unified retry handling for all Thrift operations using wrapTCLICall() method, bringing Thrift under the same retry framework as HTTP operations.#3
nishkarsh-db wants to merge 1 commit intoUnified_Retry_3from
Unified_Retry_4

Conversation

@nishkarsh-db
Copy link
Copy Markdown
Owner

Changes

DatabricksThriftAccessor

  • Added ThriftCall functional interface and wrapTCLICall() method
  • Orchestrates retry logic for all Thrift operations (OpenSession, ExecuteStatement, etc.)
  • Uses same retry strategies as HTTP operations (IdempotentRetryStrategy, NonIdempotentRetryStrategy)
  • Implements exponential backoff with timeout management

DatabricksHttpTTransport

  • Added checkHHTTPResponseForRetry() to inspect HTTP responses for retryable status codes
  • Formats error messages with status code, status line, and Thrift headers
  • Maintains compatibility with existing error message format

Integration

Builds on:

  • PR 1: RequestType, RetryTimeoutManager
  • PR 2: Retry strategies
  • PR 3: HTTP client retry integration

Design Notes

  • Application-layer retry control: Moved from Apache HTTP Client's built-in retry to explicit retry orchestration
  • HttpClientType preserved: Not removed in this PR (deferred to future cleanup)
  • Consistent error handling: All operations follow same retry flow

Files Changed

  • DatabricksThriftAccessor.java - Added wrapTCLICall() and updated all Thrift operations
  • DatabricksHttpTTransport.java - Added checkHHTTPResponseForRetry() for error inspection

Test Plan

  • All existing Thrift tests pass
  • Error messages match main branch format
  • Retry logic handles transient failures properly

- Add wrapTCLICall() method and ThriftCall functional interface to DatabricksThriftAccessor
- Implement retry orchestration for all Thrift operations (OpenSession, ExecuteStatement, etc.)
- Add checkHHTTPResponseForRetry() in DatabricksHttpTTransport with proper error formatting
- Update ArrowResultChunkStatusTest mock to include executeWithRetry methods
- Ensure error messages and exception chains match master branch behavior

Thrift retry handling now uses explicit application-layer control via wrapTCLICall.
Error messages include status code, status line, and Thrift headers when present.
HttpClientType is preserved throughout all PRs (not removed).

Co-authored-by: Cursor <cursoragent@cursor.com>
}

@SuppressWarnings("rawtypes")
TBase getThriftResponse(TBase request) throws DatabricksSQLException {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can we not wrap this function simply?


TFetchResultsResp response;
try {
response = getThriftClient().FetchResults(request);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this needs to be wrapped as well

try (CloseableHttpResponse response = httpClient.execute(request)) {

ValidationUtil.checkHTTPError(response);
checkHHTTPResponseForRetry(response);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

typo

response.getFirstHeader(THRIFT_ERROR_MESSAGE_HEADER).getValue());
}

throw new DatabricksRetryHandlerException(errorMessage, statusCode, headers);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consume the response entity in checkHHTTPResponseForRetry before throwing.

// Non-retriable exception or exhausted retries for exception
String errorMsg =
String.format(
"Failed to flush data to server: %s", retryException.getCause().getMessage());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

error message should be something like: Thrift request failed after retry exhaustion

@SuppressWarnings("rawtypes")
public interface ThriftCall {
TBase call(TBase request) throws TException;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can probably just use lambdas?

return thriftCall.call(request);
} catch (TException e) {
DatabricksRetryHandlerException retryException = RetryUtils.extractRetryException(e);
if (retryException != null) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

retryException will be null for non-status code exceptions, which means DatabricksHttpException/IOException is actually never retried?

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.

2 participants