Skip to content

fix: add timeout to dns check#6977

Merged
SWvheerden merged 2 commits intotari-project:developmentfrom
stringhandler:st-better-pulse-service
Apr 22, 2025
Merged

fix: add timeout to dns check#6977
SWvheerden merged 2 commits intotari-project:developmentfrom
stringhandler:st-better-pulse-service

Conversation

@stringhandler
Copy link
Copy Markdown
Contributor

@stringhandler stringhandler commented Apr 22, 2025

Adds a timeout to pulse dns check and replaces skipped interval with skipped instead of delay

Summary by CodeRabbit

  • Improvements
    • Enhanced reliability of DNS and health check intervals by making missed ticks skip rather than delay.
    • Improved robustness of node health checks with timeout handling and better error logging.
    • Simplified DNS checkpoint handling for smoother operation and fewer disruptions.

@stringhandler stringhandler requested a review from a team as a code owner April 22, 2025 12:56
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 22, 2025

Walkthrough

This update simplifies the interval tick handling logic within the Tari Pulse service. It changes the tick behavior for DNS and health check intervals to skip missed ticks rather than delay them, removes logic related to tracking and skipping DNS ticks, and adds a timeout to the checkpoint fetching process. If fetching checkpoints times out, the service now logs a warning and assumes the node is not behind. Additionally, notification sending errors are now logged as warnings instead of causing a panic. No public interfaces or exported function signatures were altered.

Changes

File(s) Change Summary
base_layer/core/src/base_node/tari_pulse_service/mod.rs Simplified interval tick handling by switching to MissedTickBehavior::Skip, removed DNS tick skipping logic, added 1s timeout to checkpoint fetching, changed error handling to log warnings instead of panicking, and consolidated imports.

Poem

Skipping ticks, we hop ahead,
No more counting what we’ve missed—
With timeouts set and warnings said,
The code is lighter, bugs dismissed.
A rabbit’s leap, a simpler tune,
Our service hums a brisker rune! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this 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.

Copy link
Copy Markdown
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

🧹 Nitpick comments (1)
base_layer/core/src/base_node/tari_pulse_service/mod.rs (1)

195-206: Good implementation of timeout for DNS checkpoint fetching

Adding a 1-second timeout prevents the DNS check from hanging indefinitely when the DNS service is unresponsive. The error handling is comprehensive with appropriate fallbacks.

Consider making the timeout duration configurable through the TariPulseConfig instead of hardcoding it:

 pub struct TariPulseConfig {
     pub dns_check_interval: Duration,
     pub liveness_interval: Duration,
     pub network: Network,
+    pub dns_timeout: Duration,
 }

 impl Default for TariPulseConfig {
     fn default() -> Self {
         Self {
             dns_check_interval: Duration::from_secs(120),
             liveness_interval: Duration::from_secs(60 * 10),
             network: Network::default(),
+            dns_timeout: Duration::from_secs(1),
         }
     }
 }

Then use it in the passed_checkpoints method:

-        let dns_checkpoints = match timeout(Duration::from_secs(1), self.fetch_checkpoints()).await {
+        let dns_checkpoints = match timeout(self.config.dns_timeout, self.fetch_checkpoints()).await {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6dfff45 and bf508ef.

📒 Files selected for processing (1)
  • base_layer/core/src/base_node/tari_pulse_service/mod.rs (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: ci
🔇 Additional comments (3)
base_layer/core/src/base_node/tari_pulse_service/mod.rs (3)

44-44: Good addition of the timeout import

Adding the timeout import alongside MissedTickBehavior keeps the imports organized and focused on what's needed.


127-127: Improvement in missed tick handling

Changing from Delay to Skip for both DNS and health check intervals is a good improvement. When the system is under load and misses interval ticks, it will now skip to the next scheduled tick rather than trying to catch up with delayed ticks, which prevents work backlogs.

Also applies to: 131-131


175-178: Better error handling for notification sending

The improved error handling with inspect_err is more robust than the previous implementation. By logging a warning instead of potentially panicking when notification sending fails, the service can continue operating even when the receiver disconnects.

@SWvheerden SWvheerden merged commit 18b6193 into tari-project:development Apr 22, 2025
12 checks passed
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