Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello @lidezhu, 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 enhances the stability and correctness of the log coordinator's resignation process. The changes ensure that the system handles server shutdown and resignation timeouts more gracefully, preventing potential issues during critical operational phases. The modifications improve the robustness of the election mechanism by refining how resignation attempts are managed and how errors are propagated. 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
|
📝 WalkthroughWalkthroughAdds retrieval of log coordinator revision from etcd and updates campaign resignation behavior to log and return nil on resignation timeouts/failures; includes interface, client, mock, and test additions for the new revision lookup. Changes
Sequence Diagram(s)sequenceDiagram
participant Campaign as "Campaign Manager"
participant Etcd as "Etcd (OwnerCaptureInfoClient)"
participant LogCoord as "Log Coordinator Process"
Campaign->>Etcd: GetLogCoordinatorRevision(captureID)
Etcd-->>Campaign: (modRevision or error)
Campaign->>LogCoord: start campaign (include revision)
LogCoord-->>Campaign: campaign result (success/error)
Campaign->>LogCoord: resign (with 5s timeout)
alt resign timeout or failure
LogCoord-->>Campaign: timeout/error (logged, treated as nil)
else successful resign
LogCoord-->>Campaign: success
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ❌ 4❌ Failed checks (3 warnings, 1 inconclusive)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (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 fixes a bug in the log coordinator's resign logic. The changes correctly replace a generic resign call with the specific resignLogCoordinator function and address incorrect error handling and logging within it. The logic for handling resign failures during server shutdown is also improved for clarity. My review includes a suggestion to remove a redundant log message, which will make the error handling cleaner and more consistent with the existing codebase.
| log.Info("log coordinator resign failed", | ||
| zap.String("nodeID", nodeID), zap.Error(resignErr)) | ||
| return errors.Trace(resignErr) |
There was a problem hiding this comment.
This log message is redundant. The primary caller of resignLogCoordinator in campaignLogCoordinator (line 231) already logs a WARN message when this function returns an error. To avoid duplicate logs and to keep the function's responsibility focused on the resign action, it's better to remove this log.Info call and just return the error. This change would also align resignLogCoordinator with the pattern used in the resign function, which does not perform logging itself.
return errors.Trace(resignErr)There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
server/module_election.go (1)
250-259:⚠️ Potential issue | 🟡 MinorOriginal
co.Runerror is lost whenresignLogCoordinatorfails.On line 253, if
resignLogCoordinator()returns an error, that resign error is returned immediately viaerrors.Trace(resignErr), but the originalerrfromco.Run(ctx)(which triggered the resign) is never logged. Consider logging the original error before returning the resign error.Proposed fix
if err != nil && !errors.Is(err, context.Canceled) { if !errors.ErrNotOwner.Equal(err) { if resignErr := e.resignLogCoordinator(); resignErr != nil { + log.Warn("log coordinator resign failed after run error", + zap.String("nodeID", nodeID), + zap.Int64("logCoordinatorVersion", logCoordinatorVersion), + zap.Error(err)) return errors.Trace(resignErr) } }
🧹 Nitpick comments (2)
pkg/etcd/etcd.go (1)
604-620: ReusingErrOwnerNotFound/ErrNotOwnerfor a log coordinator role is semantically misleading.Lines 613 and 617 return
ErrOwnerNotFoundandErrNotOwnerrespectively, but this method checks log coordinator ownership, not the coordinator/owner role. The caller inmodule_election.go(line 251) checkserrors.ErrNotOwner.Equal(err)to decide whether to resign, so reusing these errors works functionally, but it conflates two distinct election roles in diagnostics and error messages.Consider introducing
ErrLogCoordinatorNotFoundandErrNotLogCoordinatorfor clarity, or at minimum add a comment explaining why the owner errors are intentionally reused here.pkg/etcd/etcd_test.go (1)
280-291: Missingdefer ctrl.Finish()in subtests — inconsistent with existing tests.The existing
TestCDCEtcdClientImpl_GetChangefeedInfoAndStatus(line 257) explicitly callsdefer ctrl.Finish(). Each subtest here creates agomock.Controllerbut omits the deferredFinish(). While gomock v1.5+ auto-registers cleanup, being consistent with the rest of the file avoids confusion.Add `defer ctrl.Finish()` after each `gomock.NewController` call
t.Run("get leader failed", func(t *testing.T) { ctrl := gomock.NewController(t) + defer ctrl.Finish() client := NewMockClient(ctrl)Apply similarly for the other three subtests.
What problem does this PR solve?
Issue Number: ref #2751
What is changed and how it works?
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
New Features
Tests
Chores