Skip to content

Backport: Add _retry_server_directed_only mode for Retry-After header compliance#757

Open
sd-db wants to merge 6 commits intorelease/v4.1.5from
sd-db/PECOBLR-1863/retry-server-directed-only-v4.1.5
Open

Backport: Add _retry_server_directed_only mode for Retry-After header compliance#757
sd-db wants to merge 6 commits intorelease/v4.1.5from
sd-db/PECOBLR-1863/retry-server-directed-only-v4.1.5

Conversation

@sd-db
Copy link
Collaborator

@sd-db sd-db commented Mar 19, 2026

Summary

Backport of #756 to release/v4.1.5 for patch release.

  • Adds opt-in _respect_server_retry_after_header connection parameter that restricts retries to only occur when the server includes a Retry-After header in the response
  • Prevents duplicate side effects for non-idempotent ExecuteStatement operations where the server has not explicitly signaled that retry is safe
  • Threads the parameter through ClientContext, all three DatabricksRetryPolicy construction sites (Thrift, SEA, UnifiedHttpClient), and the retry policy's should_retry/is_retry methods
  • Default behavior (retry without requiring the header) is unchanged

Test plan

  • 8 new unit tests covering server-directed-only mode in tests/unit/test_retry.py
  • Full unit test suite for retry passes (poetry run python -m pytest tests/unit/test_retry.py)

sd-db added 4 commits March 19, 2026 16:11
When enabled, the connector only retries on 429/503 if the server includes
a Retry-After header in the response. This prevents duplicate side effects
for non-idempotent ExecuteStatement operations where the server has not
explicitly signaled that retry is safe.

The new opt-in parameter `_retry_server_directed_only` threads through
ClientContext, all three DatabricksRetryPolicy construction sites (Thrift,
SEA, UnifiedHttpClient), and the retry policy's should_retry/is_retry
methods. Default behavior (retry without requiring the header) is unchanged.

Signed-off-by: Shubham Dhal <shubham.dhal@databricks.com>
Inline kwargs.get() at the single point of use in ThriftDatabricksClient
and SeaHttpClient instead of storing as dead instance state.

Signed-off-by: Shubham Dhal <shubham.dhal@databricks.com>
- Rename server_directed_only to respect_server_retry_after_header
  throughout for clarity
- Store _respect_server_retry_after_header as instance variable in
  Thrift/SEA backends to match existing kwargs extraction pattern
- Replace duplicate test fixture with _make_retry_policy(**overrides)
  helper for flexible policy construction in tests

Signed-off-by: Shubham Dhal <shubham.dhal@databricks.com>
Signed-off-by: Shubham Dhal <shubham.dhal@databricks.com>
- Update actions/checkout@v2 → v4 and actions/setup-python@v2 → v5 in run-unit-tests-with-arrow job
- Pin Poetry version to 2.2.1 across all workflow files
- Reduce long-running query test min duration from 3 to 2 minutes

Co-authored-by: Isaac
@github-actions
Copy link

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

@github-actions
Copy link

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

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