Skip to content

fix: add aggressive fetching behaviour for first time for subnet_info#185

Merged
shilingwang merged 4 commits intomainfrom
shiling/fix-task
Mar 20, 2026
Merged

fix: add aggressive fetching behaviour for first time for subnet_info#185
shilingwang merged 4 commits intomainfrom
shiling/fix-task

Conversation

@shilingwang
Copy link
Copy Markdown
Contributor

Summary

SubnetsInfoFetcher is a background task that periodically refreshes the NNS routing table and subnet-type snapshot. Previously it would wait for the full polling interval (default 5 min) between every attempt, even on startup when no snapshot had ever been fetched. This meant the gateway could be functionally unready for up to 5 minutes on a cold start if the first fetch failed.

This PR makes the first successful fetch aggressive: if SubnetsInfoFetcher.info is None (i.e. no snapshot has been populated yet), the run() method enters a tight retry loop with a 5-second back-off instead of returning and waiting for the normal interval. Once the first fetch succeeds the loop exits, the TaskManager interval takes over, and subsequent refreshes follow the configured --subnets-info-poll-interval as before.

Changes

src/routing/ic/subnets_info.rs
Added AGGRESSIVE_RETRY_INTERVAL constant (5 s).
Rewrote Run::run() to split into two paths:

  • Healthy path (info is Some): single fetch, returns immediately — no behavioural change.

  • Bootstrap path (info is None): retry loop with tokio::select! over the 5-second sleep and the shutdown CancellationToken, so it exits cleanly on service shutdown.

@shilingwang shilingwang requested a review from r-birkner March 20, 2026 10:08
@shilingwang shilingwang marked this pull request as ready for review March 20, 2026 10:08
@shilingwang shilingwang requested a review from a team as a code owner March 20, 2026 10:08
@shilingwang shilingwang enabled auto-merge March 20, 2026 12:53
@shilingwang shilingwang merged commit 056cd56 into main Mar 20, 2026
6 checks passed
@shilingwang shilingwang deleted the shiling/fix-task branch March 20, 2026 12:54
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