-
Notifications
You must be signed in to change notification settings - Fork 19
fix poller not restarting after indexer mode changes #230
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 poller not restarting after indexer mode changes #230
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
""" WalkthroughThe Poller struct now includes a Changes
Sequence Diagram(s)sequenceDiagram
participant MainLoop
participant Poller
participant Storage
MainLoop->>Poller: Change work mode (e.g., to backfill)
Poller->>Poller: Acquire write lock, update currentWorkMode
Poller->>Storage: Query last block number (if switching to backfill)
Storage-->>Poller: Return last block number
Poller->>Poller: Update lastPolledBlock under mutex
loop Polling Goroutine
Poller->>Poller: Acquire read lock, check currentWorkMode
alt currentWorkMode != Backfill
Poller->>Poller: Skip polling iteration
else currentWorkMode == Backfill
Poller->>Poller: Perform polling
end
end
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code Graph Analysis (1)internal/orchestrator/poller.go (3)
🔇 Additional comments (5)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/orchestrator/poller.go (1)
32-33
: Consider initializingcurrentWorkMode
with a default value.The
currentWorkMode
field will default to an empty string. For better clarity and to avoid potential issues, consider explicitly initializing it to a default mode (e.g.,WorkModeLive
) in the constructor functions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/orchestrator/poller.go
(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/orchestrator/poller.go (1)
internal/orchestrator/work_mode_monitor.go (3)
WorkMode
(15-15)WorkModeBackfill
(21-21)WorkModeLive
(20-20)
🔇 Additional comments (1)
internal/orchestrator/poller.go (1)
123-130
: Work mode check implementation looks good.The read lock is properly acquired and released, and the logic correctly skips polling when not in backfill mode. This implementation efficiently prevents unnecessary polling in live mode.
adad370
to
8d99b2f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/orchestrator/poller.go
(3 hunks)
🔇 Additional comments (2)
internal/orchestrator/poller.go (2)
32-33
: LGTM! Well-structured additions for thread-safe work mode management.The new fields properly implement the requirements for dynamic mode switching with appropriate synchronization.
123-129
: LGTM! Proper implementation of conditional polling based on work mode.The logic correctly prevents polling outside of backfill mode while maintaining thread safety with appropriate read lock usage.
8d99b2f
to
bc7b24e
Compare
TL;DR
Enhanced the Poller component to support dynamic work mode switching between backfill and live modes without requiring a restart.
What changed?
currentWorkMode
field andworkModeMutex
to the Poller struct to track and safely access the current work modelastPolledBlock
when switching from live to backfill modeHow to test?
lastPolledBlock
is updated correctly when switching from live to backfillWhy make this change?
This change improves the system's flexibility by allowing dynamic switching between work modes without restarting the poller process. This is particularly useful for systems that need to alternate between catching up on historical data (backfill) and processing new blocks in real-time (live mode).
Summary by CodeRabbit
New Features
Bug Fixes