Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sdk): opposite retry trigger #2265

Merged
merged 1 commit into from
Oct 22, 2024
Merged

Conversation

shumkov
Copy link
Member

@shumkov shumkov commented Oct 22, 2024

DAPI Client is supposed to retry in case of errors that originated by a node but not by a user. For example, we should retry if the node is unavailable but not retry if the user broadcasted a state transition with an invalid structure.

Issue being fixed or feature implemented

The logic described above was reverted mistakenly.

What was done?

  • Fixed can_retry calls to retry in case of node issues but not user.

How Has This Been Tested?

None

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Enhanced error handling logic for improved retry capabilities in DapiClient.
    • Simplified retry logic for gRPC status codes, clarifying which codes are non-retryable.
  • Bug Fixes

    • Adjusted error handling to prevent incorrect address banning based on retryable errors.
  • Documentation

    • Updated comments for clarity regarding error handling logic changes.

Copy link
Contributor

coderabbitai bot commented Oct 22, 2024

Walkthrough

The pull request modifies error handling logic in the DapiClient implementation, specifically within the execute method of the DapiRequestExecutor trait. The conditional check for retryable errors has been updated, allowing address banning only for non-retryable errors. Additionally, the CanRetry implementation for dapi_grpc::tonic::Status has been altered to clarify which status codes are non-retryable. Tracing logs have been adjusted to align with these changes, and minor comment improvements have been made for clarity.

Changes

File Path Change Summary
packages/rs-dapi-client/src/dapi_client.rs Modified error handling in execute method to check for retryable errors before banning address. Adjusted tracing logs and comments for clarity.
packages/rs-dapi-client/src/transport/grpc.rs Updated CanRetry implementation to clarify non-retryable status codes. Maintained existing structure and functionality of TransportClient implementations.

Possibly related PRs

  • feat(sdk)!: detect stale nodes #2254: The changes in this PR modify the error handling logic in the DapiClient implementation, specifically updating the can_retry method, which directly relates to the changes made in the main PR regarding error handling and retry logic in the execute method of the DapiRequestExecutor trait.

Suggested reviewers

  • QuantumExplorer

Poem

In the code where errors dwell,
A rabbit hops with tales to tell.
Retry or ban, a choice to make,
With clearer paths, no room for mistake.
Hooray for changes, let’s all cheer,
For smoother hops throughout the year! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@shumkov shumkov added this to the 1.4.2 milestone Oct 22, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
packages/rs-dapi-client/src/transport/grpc.rs (1)

Line range hint 125-136: Approve changes with a suggestion for improved readability

The modification to the can_retry method correctly implements the retry logic for gRPC status codes. This change aligns with the PR title "fix(sdk): opposite retry trigger" and should resolve any issues related to incorrect retry behavior.

To improve readability, consider grouping related status codes and adding a brief comment explaining the rationale for each group. For example:

matches!(
    code,
    // Transient errors that may resolve on retry
    Ok | Cancelled | Unknown | DeadlineExceeded | ResourceExhausted |
    // Server-side issues that might be temporary
    Aborted | Internal | Unavailable |
    // Data integrity issues that might be resolved by retrying
    DataLoss
)

This grouping and commenting can make the code more maintainable and easier to understand for future developers.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a2034fd and b5c01bc.

📒 Files selected for processing (2)
  • packages/rs-dapi-client/src/dapi_client.rs (1 hunks)
  • packages/rs-dapi-client/src/transport/grpc.rs (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
packages/rs-dapi-client/src/dapi_client.rs (1)

Line range hint 236-248: Clarify the intention behind inverting the retry condition

The error handling logic has been significantly altered:

  1. Previously, addresses were banned for non-retryable errors.
  2. Now, addresses are banned for retryable errors.

This change raises some concerns:

  • Banning addresses for retryable errors might unnecessarily reduce the available address pool.
  • Non-retryable errors no longer trigger address banning, potentially keeping problematic addresses in the pool.

While this change aligns with the PR title mentioning "opposite retry trigger", it's unclear if this is the intended behavior. Could you please clarify:

  1. Is this inversion intentional?
  2. What's the rationale behind banning addresses for retryable errors?
  3. How do we handle persistently problematic addresses if we don't ban them for non-retryable errors?

To help verify the impact of this change, please run the following script:

This will help us understand if this change is consistent with error handling in other parts of the codebase.

@shumkov shumkov self-assigned this Oct 22, 2024
@shumkov shumkov requested a review from lklimek October 22, 2024 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Verify is a node provide a fresh data
2 participants