Skip to content

feat: add configurable retry parameters and improve retry logging#739

Merged
everpcpc merged 3 commits intodatabendlabs:mainfrom
everpcpc:vancouver-wthc4bbd
Jan 15, 2026
Merged

feat: add configurable retry parameters and improve retry logging#739
everpcpc merged 3 commits intodatabendlabs:mainfrom
everpcpc:vancouver-wthc4bbd

Conversation

@everpcpc
Copy link
Copy Markdown
Member

Summary

This PR adds configurable retry parameters and improves retry logging for better observability and control over retry behavior.

What changed:

  • Added two new DSN parameters: retry_count (default: 3) and retry_delay_secs (default: 10)
  • Improved retry logging with detailed reasons for each retry attempt
  • Refactored retry logic by introducing a RetryDecision struct in a new retry.rs module

Why:

  • Makes retry behavior configurable for different deployment scenarios
  • Provides better visibility into why requests are being retried (503 errors, timeouts, connection errors, token refresh)
  • Cleaner code organization with retry logic separated into its own module

Key changes:

  • core/src/client.rs: Added retry_count and retry_delay_secs fields, updated retry loops with improved logging
  • core/src/retry.rs: New module with RetryDecision helper struct
  • Both refresh_session_token() and request_helper() methods now use configurable parameters and provide detailed retry reasons

Testing notes:

  • Default behavior unchanged (3 retries, 10 second delay)
  • New parameters can be set via DSN: ?retry_count=5&retry_delay_secs=5
  • Retry logs now include reason and attempt count

everpcpc and others added 2 commits January 15, 2026 11:52
- Add retry_count and retry_delay_secs DSN parameters (default: 3 retries, 10s delay)
- Improve retry logs with detailed reasons (503, timeout, connection error, token refresh)
- Refactor retry logic with RetryDecision struct in separate retry.rs module
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@everpcpc everpcpc marked this pull request as ready for review January 15, 2026 04:11
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3aa79a9fe3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread core/src/client.rs
When retry_count=0, the expression `max_retries - 1` would underflow:
- In debug builds: panic on subtraction
- In release builds: wrap to u32::MAX, causing infinite retry loops

This fix uses saturating_sub(1) which returns 0 when max_retries=0,
allowing retry_count=0 to work correctly (no retries, fail immediately).

Fixes applied in:
- refresh_session_token: two comparisons with max_retries - 1
- query_request_helper: two comparisons with max_retries - 1

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@everpcpc everpcpc merged commit 925e9c8 into databendlabs:main Jan 15, 2026
42 checks passed
@everpcpc everpcpc deleted the vancouver-wthc4bbd branch January 15, 2026 04:59
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.

1 participant