Repository navigation
fix(retry): correct retry_max_wait < retry_min_wait instead of panicking (#214) - #233
Merged
Merged
Conversation
vikrantpuppala
temporarily deployed
to
azure-prod
August 10, 2026 11:06 — with
GitHub Actions
Inactive
vikrantpuppala
temporarily deployed
to
azure-prod
August 10, 2026 11:06 — with
GitHub Actions
Inactive
vikrantpuppala
temporarily deployed
to
azure-prod
August 10, 2026 11:06 — with
GitHub Actions
Inactive
…ing (#214) A backoff-bound tuning typo where `retry_max_wait < retry_min_wait` was dormant until the first retry, then panicked in `calculate_backoff`: `wait.clamp(min_wait, max_wait)` hits `Duration`'s `Ord::clamp`, which asserts `min <= max`. On a transient 503 this aborted the caller's task with an unhandleable panic instead of returning a `Result`. Correct the pair (raise max to min) with a warning, rather than reject or panic — a backoff bound is a tuning hint, matching the clamp-and-warn discipline `apply_client_result_overrides` already uses: - `calculate_backoff` now uses an effective ceiling `max_wait.max(min_wait)` so no config can panic it (silent on this per-retry hot path). - `build_retry_configs_for_session` emits the one-time correction `warn!` and raises max to min when building the per-session `RetryConfig`. - C-ABI `kernel_session_config_set_retry_config` now corrects-and-warns instead of rejecting `max_wait_ms < min_wait_ms` with `InvalidArgument`, aligning it with the Rust path and the reference ODBC driver. The `min_wait_ms == 0` rejection stays (a zero floor is genuinely invalid). Closes #214 This pull request and its description were written by Isaac. Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala
force-pushed
the
fix/214-retry-backoff-bound-correction
branch
from
August 10, 2026 11:20
fc942d4 to
8fccb4c
Compare
vikrantpuppala
temporarily deployed
to
azure-prod
August 10, 2026 11:21 — with
GitHub Actions
Inactive
vikrantpuppala
temporarily deployed
to
azure-prod
August 10, 2026 11:21 — with
GitHub Actions
Inactive
vikrantpuppala
temporarily deployed
to
azure-prod
August 10, 2026 11:21 — with
GitHub Actions
Inactive
vikrantpuppala
temporarily deployed
to
azure-prod
August 10, 2026 11:21 — with
GitHub Actions
Inactive
This branch was previously deployed
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 ERRORRECOV-014 (#214): a backoff-bound tuning typo where
retry_max_wait < retry_min_waitwas not corrected. The session opened fine, but the first retry panicked incalculate_backoff—wait.clamp(config.min_wait, config.max_wait)hitsDuration'sOrd::clamp, which assertsmin <= max(assertion failed: min <= max). On a transient 503 this aborted the caller's task with an unhandleable panic instead of returning aResult— strictly worse than an open-time error.Per the shared spec and the reference ODBC driver (databricks-odbc#181), the correct behavior is to correct the pair (raise max to min) with a warning, not reject or panic — a backoff bound is a tuning hint. This matches the clamp-and-warn discipline
apply_client_result_overridesalready uses forcloudfetch_max_chunks_in_memory.Changes
src/client/retry.rs—calculate_backoff: uses an effective ceilingmax_wait.max(min_wait)in both the Retry-After clamp and the exponential-backoff cap, so no config can panic it. Silent on this per-retry hot path.src/session.rs—build_retry_configs_for_session: emits the one-time correctionwarn!and raises max to min when building the per-sessionRetryConfig(the single per-session build point, so no log spam).src/c_abi/session.rs—kernel_session_config_set_retry_config: now corrects-and-warns instead of rejectingmax_wait_ms < min_wait_mswithInvalidArgument, aligning the C-ABI with the Rust path and the reference driver. Themin_wait_ms == 0rejection is kept (a zero floor is genuinely invalid, not a correctable typo).Test plan
test_calculate_backoff_max_below_min_does_not_panic(src/client/retry.rs): withmin_wait=3s, max_wait=1s, assertscalculate_backoffdoes not panic and returns>= min_waitfor both the Retry-After path and the exponential path. Confirmed it panics on the pre-fix code and passes after.set_retry_config_rejects_zero_min_corrects_bad_range(wasset_retry_config_rejects_bad_range):min_wait_ms == 0still returnsInvalidArgument;max_wait_ms(1s) < min_wait_ms(5s)now returnsSuccesswith the storedRetrySpechavingmax_wait == min_wait == 5s.cargo +stable fmt --all,cargo clippy --all-targets -- -D warnings, andcargo testall pass (748 lib tests, 0 failures).retry_wait_max_below_min_is_corrected_not_fatal): the session opens withretry_wait_min=3s / retry_wait_max=1s, then a 503+Retry-After retry succeeds without panicking. That xfail flips green once this lands.Note on the sibling finding #185 (ERRORRECOV-013)
The related transport-error-retry finding is handled separately (a comment on #185, no code change here): the kernel already retries the provably-safe
is_connect()transport failures onExecuteStatement, and the mid-flight-close scenario is an ambiguous case that would risk double-executing non-idempotent SQL — which the kernel declines by policy. This PR does not close #185.This pull request and its description were written by Isaac.