logservice: avoid dispatcher registration failure during schema store initialization#4366
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses potential issues during service initialization and resource management. It improves the robustness of event dispatcher registration by ensuring immediate cleanup upon failure and refines the retry strategy for Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds cleanup to event broker error paths to mark and unregister dispatchers on schema/register failures, extracts CreateTiStore retry decision into a helper, and ensures Pebble batch closure in the event store; corresponding tests added/updated. Changes
Sequence Diagram(s)sequenceDiagram
participant Broker as EventBroker
participant Schema as SchemaStore
participant Store as EventStore
Broker->>Schema: register schema / table
Schema--xBroker: return error
Note right of Broker: mark dispatcher.isRemoved = true
Broker->>Store: UnregisterDispatcher(changefeedID, dispatcherID)
Store-->>Broker: acknowledge unregister
Broker-->>Broker: cleanup local dispatcher state
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces two main improvements. First, it enhances the error handling in addDispatcher by ensuring that if schemaStore.RegisterTable fails, the dispatcher is correctly unregistered from the event store and marked as removed to prevent race conditions. This is a solid fix for resource cleanup and stability. Second, it refactors the retry logic in CreateTiStore to be more robust against transient context.Canceled errors, which improves the reliability of upstream initialization. The changes are well-implemented and include corresponding tests to verify the new behavior.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 3AceShowHand, tenfyzhong The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
|
/retest |
What problem does this PR solve?
Issue Number: ref #4272 close #4285
What is changed and how it works?
This pull request aims to avoid schema store registration failure like the following:
Highlights
addDispatcherfunction to ensure proper unregistration and marking of dispatchers as removed immediately upon schema store registration failure, preventing inconsistent states.CreateTiStoreRetry Logic: Refactored the retry mechanism forCreateTiStoreto differentiate between caller-initiated context cancellations (which should stop retries) and internal client cancellations (which should continue retries), improving resilience.addDispatchererror handling and the refinedCreateTiStoreretry behavior.Check List
Tests
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note
Summary by CodeRabbit
Bug Fixes
Tests