Repository navigation
fix(*): merge operator inconsistent after maintainer move #3769
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
Merged
ti-chi-bot
merged 33 commits into
pingcap:master
from
wlwilliamx:fix/merge-operator-inconsistent-after-maintainer-move
Jul 29, 2026
Merged
Changes from 17 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
2686e4a
fix(scheduler): ensure span consistency for operator add, remove, mov…
wlwilliamx 7288257
fix a typo
wlwilliamx b9637e2
fix a log typo
wlwilliamx ce070cc
handle err for restoreCurrentWorkingOperators
wlwilliamx b0929db
modify a comment
wlwilliamx d8732bc
Merge remote-tracking branch 'upstream/master' into fix/dispatcher-lo…
wlwilliamx 050e13f
resolve conflicts
wlwilliamx a7be949
fix newRemoveDispatcherOperator node id
wlwilliamx c9891d8
handle return value for AddOperator and add some logs for it
wlwilliamx 8c4e099
add some logs for dispatcher manager store current working operators
wlwilliamx 75638b2
fix remove operator nil span
wlwilliamx 82637b9
Merge remote-tracking branch 'upstream/master' into fix/dispatcher-lo…
wlwilliamx 26f5a83
remove enabled split
wlwilliamx d1d8752
fix(*): ensure merge operator consistency when maintainer restart
wlwilliamx 53fb47d
Merge remote-tracking branch 'upstream/master' into fix/merge-operato…
wlwilliamx b8473b1
fix maintainer uts
wlwilliamx ba7dd6d
Merge remote-tracking branch 'upstream/master' into fix/merge-operato…
wlwilliamx 8e3b14a
add test case
wlwilliamx 927581d
Merge remote-tracking branch 'upstream/master' into fix/merge-operato…
wlwilliamx e124c26
maintainer: tolerate bootstrap overlap during merge
wlwilliamx e66468a
Merge remote-tracking branch 'upstream/master' into wl/pr-3769-resolv…
wlwilliamx d900f8d
maintainer,downstreamadapter: fix merge failover recovery
wlwilliamx f90d754
Merge remote-tracking branch 'upstream/master' into wl/pr-3769-ai-rev…
wlwilliamx 10dfb31
maintainer: skip stale merge bootstrap journals
wlwilliamx 821c0d8
maintainer: harden merge bootstrap recovery
wlwilliamx d0c1051
maintainer: harden bootstrap overlap recovery
wlwilliamx c4e7205
Merge remote-tracking branch 'upstream/master' into xwl/pr-3769-resol…
wlwilliamx 8d17152
maintainer,downstreamadapter: fix merge failover epoch
wlwilliamx 0fb1144
maintainer,downstreamadapter: simplify merge recovery code
wlwilliamx 791c9aa
maintainer: apply bootstrap formatting
wlwilliamx 0a30573
maintainer: simplify merge bootstrap tests
wlwilliamx b0ebc07
maintainer: repair coverage after restored remove
wlwilliamx f65ded0
tests: propagate CDC server to retry helpers
wlwilliamx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
downstreamadapter/dispatchermanager/dispatcher_manager_merge.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| // Copyright 2025 PingCAP, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package dispatchermanager | ||
|
|
||
| import ( | ||
| "github.com/pingcap/log" | ||
| "github.com/pingcap/ticdc/heartbeatpb" | ||
| "github.com/pingcap/ticdc/pkg/common" | ||
| "go.uber.org/zap" | ||
| ) | ||
|
|
||
| // TrackMergeOperator records an in-flight merge request so bootstrap can restore it after maintainer failover. | ||
| func (e *DispatcherManager) TrackMergeOperator(req *heartbeatpb.MergeDispatcherRequest) { | ||
| if req == nil || req.MergedDispatcherID == nil { | ||
| return | ||
| } | ||
| mergedID := common.NewDispatcherIDFromPB(req.MergedDispatcherID) | ||
| e.mergeOperatorMap.Store(mergedID.String(), cloneMergeDispatcherRequest(req)) | ||
| } | ||
|
|
||
| // RemoveMergeOperator drops the persisted merge request once the merged dispatcher has converged. | ||
| func (e *DispatcherManager) RemoveMergeOperator(mergedDispatcherID common.DispatcherID) { | ||
| e.mergeOperatorMap.Delete(mergedDispatcherID.String()) | ||
| } | ||
|
|
||
| // MaybeCleanupMergeOperator removes a persisted merge request when the merged dispatcher is already complete or gone. | ||
| func (e *DispatcherManager) MaybeCleanupMergeOperator(req *heartbeatpb.MergeDispatcherRequest) { | ||
| if req == nil || req.MergedDispatcherID == nil { | ||
| return | ||
| } | ||
| mergedID := common.NewDispatcherIDFromPB(req.MergedDispatcherID) | ||
| if common.IsRedoMode(req.Mode) { | ||
| if dispatcherItem, ok := e.redoDispatcherMap.Get(mergedID); ok { | ||
| if dispatcherItem.GetComponentStatus() == heartbeatpb.ComponentState_Working { | ||
| e.RemoveMergeOperator(mergedID) | ||
| } | ||
| return | ||
| } | ||
| } else { | ||
| if dispatcherItem, ok := e.dispatcherMap.Get(mergedID); ok { | ||
| if dispatcherItem.GetComponentStatus() == heartbeatpb.ComponentState_Working { | ||
| e.RemoveMergeOperator(mergedID) | ||
| } | ||
| return | ||
| } | ||
| } | ||
| log.Info("cleanup merge operator because merged dispatcher not found", | ||
| zap.Stringer("changefeedID", e.changefeedID), | ||
| zap.String("dispatcherID", mergedID.String()), | ||
| zap.Int64("mode", req.Mode)) | ||
| e.RemoveMergeOperator(mergedID) | ||
| } | ||
|
|
||
| // GetMergeOperators returns cloned in-flight merge requests for maintainer bootstrap. | ||
| func (e *DispatcherManager) GetMergeOperators() []*heartbeatpb.MergeDispatcherRequest { | ||
| operators := make([]*heartbeatpb.MergeDispatcherRequest, 0) | ||
| e.mergeOperatorMap.Range(func(_, value any) bool { | ||
| req, ok := value.(*heartbeatpb.MergeDispatcherRequest) | ||
| if !ok || req == nil { | ||
| return true | ||
| } | ||
| operators = append(operators, cloneMergeDispatcherRequest(req)) | ||
| return true | ||
| }) | ||
| return operators | ||
| } | ||
|
|
||
| func cloneMergeDispatcherRequest(req *heartbeatpb.MergeDispatcherRequest) *heartbeatpb.MergeDispatcherRequest { | ||
| if req == nil { | ||
| return nil | ||
| } | ||
| clone := &heartbeatpb.MergeDispatcherRequest{ | ||
| Mode: req.Mode, | ||
| } | ||
| if req.ChangefeedID != nil { | ||
| id := *req.ChangefeedID | ||
| clone.ChangefeedID = &id | ||
| } | ||
| if req.MergedDispatcherID != nil { | ||
| mergedID := *req.MergedDispatcherID | ||
| clone.MergedDispatcherID = &mergedID | ||
| } | ||
| if len(req.DispatcherIDs) > 0 { | ||
| clone.DispatcherIDs = make([]*heartbeatpb.DispatcherID, 0, len(req.DispatcherIDs)) | ||
| for _, dispatcherID := range req.DispatcherIDs { | ||
| if dispatcherID == nil { | ||
| continue | ||
| } | ||
| id := *dispatcherID | ||
| clone.DispatcherIDs = append(clone.DispatcherIDs, &id) | ||
| } | ||
| } | ||
| return clone | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.