From 2686e4aceab26bab587faae002e1a9d0940fe30a Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 18 Dec 2025 13:57:54 +0800 Subject: [PATCH 01/25] fix(scheduler): ensure span consistency for operator add, remove, move, split after maintainer restart --- .../dispatcher/basic_dispatcher.go | 10 + .../dispatcher/event_dispatcher.go | 2 + .../dispatcher/event_dispatcher_test.go | 4 + .../dispatcher/redo_dispatcher.go | 2 + .../dispatcher/redo_dispatcher_test.go | 1 + .../dispatchermanager/dispatcher_manager.go | 32 +- .../dispatcher_manager_helper.go | 6 +- .../dispatcher_manager_info.go | 15 +- .../dispatcher_manager_redo.go | 14 +- .../dispatcher_manager_test.go | 1 + downstreamadapter/dispatchermanager/helper.go | 28 +- .../dispatcher_orchestrator.go | 37 ++ heartbeatpb/heartbeat.pb.go | 450 ++++++++++++------ heartbeatpb/heartbeat.proto | 11 + maintainer/barrier_test.go | 2 +- maintainer/maintainer_controller.go | 2 +- maintainer/maintainer_controller_bootstrap.go | 74 ++- maintainer/maintainer_controller_helper.go | 2 +- maintainer/operator/operator_add.go | 8 +- maintainer/operator/operator_add_test.go | 2 +- maintainer/operator/operator_controller.go | 11 +- maintainer/operator/operator_move.go | 4 +- maintainer/operator/operator_remove.go | 29 +- maintainer/operator/operator_remove_test.go | 3 +- maintainer/operator/operator_split.go | 2 +- maintainer/replica/replication_span.go | 11 +- maintainer/replica/replication_span_test.go | 4 +- maintainer/scheduler/balance_splits.go | 3 +- maintainer/scheduler/basic.go | 3 +- 29 files changed, 587 insertions(+), 186 deletions(-) diff --git a/downstreamadapter/dispatcher/basic_dispatcher.go b/downstreamadapter/dispatcher/basic_dispatcher.go index 61783a4b39..6903bbaddd 100644 --- a/downstreamadapter/dispatcher/basic_dispatcher.go +++ b/downstreamadapter/dispatcher/basic_dispatcher.go @@ -120,6 +120,7 @@ type BasicDispatcher struct { // or just a part of the table (span). When true, the dispatcher handles the entire table; // when false, it only handles a portion of the table. isCompleteTable bool + enabledSplit bool // startTs is the timestamp that the dispatcher need to receive and flush events. startTs uint64 @@ -195,6 +196,7 @@ type BasicDispatcher struct { func NewBasicDispatcher( id common.DispatcherID, tableSpan *heartbeatpb.TableSpan, + enabledSplit bool, startTs uint64, schemaID int64, schemaIDToDispatchers *SchemaIDToDispatchers, @@ -208,6 +210,7 @@ func NewBasicDispatcher( dispatcher := &BasicDispatcher{ id: id, tableSpan: tableSpan, + enabledSplit: enabledSplit, isCompleteTable: common.IsCompleteSpan(tableSpan), startTs: startTs, skipSyncpointAtStartTs: skipSyncpointAtStartTs, @@ -820,6 +823,9 @@ func (d *BasicDispatcher) Remove() { // TryClose will return the watermark of current dispatcher, and return true when the dispatcher finished sending events to sink. // DispatcherManager will clean the dispatcher info after Remove() is called. func (d *BasicDispatcher) TryClose() (w heartbeatpb.Watermark, ok bool) { + failpoint.Inject("NotReadyToCloseDispatcher", func() { + failpoint.Return(w, false) + }) // If sink is normal(not meet error), we need to wait all the events in sink to flushed downstream successfully // If sink is not normal, we can close the dispatcher immediately. if !d.sink.IsNormal() || (d.tableProgress.Empty() && !d.duringHandleEvents.Load()) { @@ -878,3 +884,7 @@ func (d *BasicDispatcher) removeDispatcher() { zap.Stringer("dispatcherID", d.id)) } } + +func (d *BasicDispatcher) IsEnabledSplit() bool { + return d.enabledSplit +} diff --git a/downstreamadapter/dispatcher/event_dispatcher.go b/downstreamadapter/dispatcher/event_dispatcher.go index 65464b919b..b74272c14c 100644 --- a/downstreamadapter/dispatcher/event_dispatcher.go +++ b/downstreamadapter/dispatcher/event_dispatcher.go @@ -54,6 +54,7 @@ type EventDispatcher struct { func NewEventDispatcher( id common.DispatcherID, tableSpan *heartbeatpb.TableSpan, + enabledSplit bool, startTs uint64, schemaID int64, schemaIDToDispatchers *SchemaIDToDispatchers, @@ -68,6 +69,7 @@ func NewEventDispatcher( basicDispatcher := NewBasicDispatcher( id, tableSpan, + enabledSplit, startTs, schemaID, schemaIDToDispatchers, diff --git a/downstreamadapter/dispatcher/event_dispatcher_test.go b/downstreamadapter/dispatcher/event_dispatcher_test.go index ad5020ddd3..899becbbe2 100644 --- a/downstreamadapter/dispatcher/event_dispatcher_test.go +++ b/downstreamadapter/dispatcher/event_dispatcher_test.go @@ -87,6 +87,7 @@ func newDispatcherForTest(sink sink.Sink, tableSpan *heartbeatpb.TableSpan) *Eve return NewEventDispatcher( common.NewDispatcherID(), tableSpan, + false, common.Ts(0), // startTs 1, // schemaID NewSchemaIDToDispatchers(), @@ -826,6 +827,7 @@ func TestDispatcherSplittableCheck(t *testing.T) { dispatcher := NewEventDispatcher( common.NewDispatcherID(), tableSpan, + false, common.Ts(0), // startTs 1, // schemaID NewSchemaIDToDispatchers(), @@ -932,6 +934,7 @@ func TestDispatcher_SkipDMLAsStartTs_FilterCorrectly(t *testing.T) { dispatcher := NewEventDispatcher( common.NewDispatcherID(), tableSpan, + false, common.Ts(99), // startTs = 99 (ddlTs - 1) 1, // schemaID NewSchemaIDToDispatchers(), @@ -1011,6 +1014,7 @@ func TestDispatcher_SkipDMLAsStartTs_Disabled(t *testing.T) { dispatcher := NewEventDispatcher( common.NewDispatcherID(), tableSpan, + false, common.Ts(99), // startTs = 99 1, NewSchemaIDToDispatchers(), diff --git a/downstreamadapter/dispatcher/redo_dispatcher.go b/downstreamadapter/dispatcher/redo_dispatcher.go index 1c14d97002..184e15eec1 100644 --- a/downstreamadapter/dispatcher/redo_dispatcher.go +++ b/downstreamadapter/dispatcher/redo_dispatcher.go @@ -39,6 +39,7 @@ type RedoDispatcher struct { func NewRedoDispatcher( id common.DispatcherID, tableSpan *heartbeatpb.TableSpan, + endabledSplit bool, startTs uint64, schemaID int64, schemaIDToDispatchers *SchemaIDToDispatchers, @@ -49,6 +50,7 @@ func NewRedoDispatcher( basicDispatcher := NewBasicDispatcher( id, tableSpan, + endabledSplit, startTs, schemaID, schemaIDToDispatchers, diff --git a/downstreamadapter/dispatcher/redo_dispatcher_test.go b/downstreamadapter/dispatcher/redo_dispatcher_test.go index 01ab43e3a8..9e62e99fbe 100644 --- a/downstreamadapter/dispatcher/redo_dispatcher_test.go +++ b/downstreamadapter/dispatcher/redo_dispatcher_test.go @@ -53,6 +53,7 @@ func newRedoDispatcherForTest(sink sink.Sink, tableSpan *heartbeatpb.TableSpan) return NewRedoDispatcher( common.NewDispatcherID(), tableSpan, + false, common.Ts(0), // startTs 1, // schemaID NewSchemaIDToDispatchers(), diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager.go b/downstreamadapter/dispatchermanager/dispatcher_manager.go index 6e61200361..ae0a78762d 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager.go @@ -84,6 +84,9 @@ type DispatcherManager struct { dispatcherMap *DispatcherMap[*dispatcher.EventDispatcher] // redoDispatcherMap restore all the redo dispatchers in the DispatcherManager, including redo table trigger event dispatcher redoDispatcherMap *DispatcherMap[*dispatcher.RedoDispatcher] + // currentOperatorMap stores the current operators for each dispatcher + currentOperatorMap sync.Map // map[span]*dispatcher.CurrentOperator + redoCurrentOperatorMap sync.Map // map[span]*dispatcher.CurrentOperator // schemaIDToDispatchers is shared in the DispatcherManager, // it store all the infos about schemaID->Dispatchers // Dispatchers may change the schemaID when meets some special events, such as rename ddl @@ -169,15 +172,17 @@ func NewDispatcherManager( } manager := &DispatcherManager{ - dispatcherMap: newDispatcherMap[*dispatcher.EventDispatcher](), - changefeedID: changefeedID, - keyspaceID: keyspaceID, - pdClock: pdClock, - cancel: cancel, - config: cfConfig, - latestWatermark: NewWatermark(0), - schemaIDToDispatchers: dispatcher.NewSchemaIDToDispatchers(), - sinkQuota: cfConfig.MemoryQuota, + dispatcherMap: newDispatcherMap[*dispatcher.EventDispatcher](), + currentOperatorMap: sync.Map{}, + redoCurrentOperatorMap: sync.Map{}, + changefeedID: changefeedID, + keyspaceID: keyspaceID, + pdClock: pdClock, + cancel: cancel, + config: cfConfig, + latestWatermark: NewWatermark(0), + schemaIDToDispatchers: dispatcher.NewSchemaIDToDispatchers(), + sinkQuota: cfConfig.MemoryQuota, metricTableTriggerEventDispatcherCount: metrics.TableTriggerEventDispatcherGauge.WithLabelValues(changefeedID.Keyspace(), changefeedID.Name(), "eventDispatcher"), metricEventDispatcherCount: metrics.EventDispatcherGauge.WithLabelValues(changefeedID.Keyspace(), changefeedID.Name(), "eventDispatcher"), @@ -383,7 +388,7 @@ func (e *DispatcherManager) newEventDispatchers(infos map[common.DispatcherID]di start := time.Now() currentPdTs := e.pdClock.CurrentTS() - dispatcherIds, tableIds, startTsList, tableSpans, schemaIds := prepareCreateDispatcher(infos, e.dispatcherMap) + dispatcherIds, tableIds, startTsList, tableSpans, schemaIds, enabledSplits := prepareCreateDispatcher(infos, e.dispatcherMap) if len(dispatcherIds) == 0 { return nil } @@ -422,6 +427,7 @@ func (e *DispatcherManager) newEventDispatchers(infos map[common.DispatcherID]di d := dispatcher.NewEventDispatcher( id, tableSpans[idx], + enabledSplits[idx], uint64(newStartTsList[idx]), schemaIds[idx], e.schemaIDToDispatchers, @@ -765,6 +771,7 @@ func (e *DispatcherManager) mergeEventDispatcher(dispatcherIDs []common.Dispatch mergedDispatcher := dispatcher.NewEventDispatcher( mergedDispatcherID, mergedSpan, + true, // enabledSplit fakeStartTs, // real startTs will be calculated later. schemaID, e.schemaIDToDispatchers, @@ -871,8 +878,13 @@ func (e *DispatcherManager) close(removeChangefeed bool) { // cleanEventDispatcher is called when the event dispatcher is removed successfully. func (e *DispatcherManager) cleanEventDispatcher(id common.DispatcherID, schemaID int64) { + var spanStr string + if d, ok := e.dispatcherMap.m.Load(id); ok { + spanStr = d.(*dispatcher.EventDispatcher).GetTableSpan().String() + } e.dispatcherMap.Delete(id) e.schemaIDToDispatchers.Delete(schemaID, id) + e.currentOperatorMap.Delete(spanStr) if e.tableTriggerEventDispatcher != nil && e.tableTriggerEventDispatcher.GetId() == id { e.tableTriggerEventDispatcher = nil e.metricTableTriggerEventDispatcherCount.Dec() diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_helper.go b/downstreamadapter/dispatchermanager/dispatcher_manager_helper.go index 5f1a449905..a466ccdba7 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_helper.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_helper.go @@ -72,13 +72,14 @@ func getDispatcherStatus(id common.DispatcherID, dispatcherItem dispatcher.Dispa } func prepareCreateDispatcher[T dispatcher.Dispatcher](infos map[common.DispatcherID]dispatcherCreateInfo, dispatcherMap *DispatcherMap[T]) ( - []common.DispatcherID, []int64, []int64, []*heartbeatpb.TableSpan, []int64, + []common.DispatcherID, []int64, []int64, []*heartbeatpb.TableSpan, []int64, []bool, ) { dispatcherIds := make([]common.DispatcherID, 0, len(infos)) tableIds := make([]int64, 0, len(infos)) startTsList := make([]int64, 0, len(infos)) tableSpans := make([]*heartbeatpb.TableSpan, 0, len(infos)) schemaIds := make([]int64, 0, len(infos)) + enabledSplits := make([]bool, 0, len(infos)) for _, info := range infos { id := info.Id if _, ok := dispatcherMap.Get(id); ok { @@ -89,8 +90,9 @@ func prepareCreateDispatcher[T dispatcher.Dispatcher](infos map[common.Dispatche startTsList = append(startTsList, int64(info.StartTs)) tableSpans = append(tableSpans, info.TableSpan) schemaIds = append(schemaIds, info.SchemaID) + enabledSplits = append(enabledSplits, info.EnabledSplit) } - return dispatcherIds, tableIds, startTsList, tableSpans, schemaIds + return dispatcherIds, tableIds, startTsList, tableSpans, schemaIds, enabledSplits } func prepareMergeDispatcher[T dispatcher.Dispatcher](changefeedID common.ChangeFeedID, diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_info.go b/downstreamadapter/dispatchermanager/dispatcher_manager_info.go index 59323164cb..aea79d5031 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_info.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_info.go @@ -14,6 +14,8 @@ package dispatchermanager import ( + "sync" + "github.com/pingcap/ticdc/downstreamadapter/dispatcher" "github.com/pingcap/ticdc/heartbeatpb" "github.com/pingcap/ticdc/pkg/common" @@ -23,10 +25,11 @@ import ( // event_dispatcher_mananger_info.go is used to store the basic info and function of the event dispatcher manager type dispatcherCreateInfo struct { - Id common.DispatcherID - TableSpan *heartbeatpb.TableSpan - StartTs uint64 - SchemaID int64 + Id common.DispatcherID + TableSpan *heartbeatpb.TableSpan + StartTs uint64 + SchemaID int64 + EnabledSplit bool } type cleanMap struct { @@ -77,3 +80,7 @@ func (e *DispatcherManager) GetAllDispatchers(schemaID int64) []common.Dispatche } return dispatcherIDs } + +func (e *DispatcherManager) GetCurrentOperatorMap() *sync.Map { + return &e.currentOperatorMap +} diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go b/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go index 0ba4d234ea..36ace77885 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go @@ -15,6 +15,7 @@ package dispatchermanager import ( "context" + "sync" "time" "github.com/pingcap/log" @@ -109,7 +110,7 @@ func (e *DispatcherManager) NewRedoTableTriggerEventDispatcher(id *heartbeatpb.D func (e *DispatcherManager) newRedoDispatchers(infos map[common.DispatcherID]dispatcherCreateInfo, removeDDLTs bool) error { start := time.Now() - dispatcherIds, tableIds, startTsList, tableSpans, schemaIds := prepareCreateDispatcher(infos, e.redoDispatcherMap) + dispatcherIds, tableIds, startTsList, tableSpans, schemaIds, enabledSplits := prepareCreateDispatcher(infos, e.redoDispatcherMap) if len(dispatcherIds) == 0 { return nil } @@ -131,6 +132,7 @@ func (e *DispatcherManager) newRedoDispatchers(infos map[common.DispatcherID]dis rd := dispatcher.NewRedoDispatcher( id, tableSpans[idx], + enabledSplits[idx], uint64(newStartTsList[idx]), schemaIds[idx], e.redoSchemaIDToDispatchers, @@ -193,6 +195,7 @@ func (e *DispatcherManager) mergeRedoDispatcher(dispatcherIDs []common.Dispatche mergedDispatcher := dispatcher.NewRedoDispatcher( mergedDispatcherID, mergedSpan, + true, fakeStartTs, // real startTs will be calculated later. schemaID, e.redoSchemaIDToDispatchers, @@ -211,8 +214,13 @@ func (e *DispatcherManager) mergeRedoDispatcher(dispatcherIDs []common.Dispatche } func (e *DispatcherManager) cleanRedoDispatcher(id common.DispatcherID, schemaID int64) { + var spanStr string + if d, ok := e.redoDispatcherMap.m.Load(id); ok { + spanStr = d.(*dispatcher.RedoDispatcher).GetTableSpan().String() + } e.redoDispatcherMap.Delete(id) e.redoSchemaIDToDispatchers.Delete(schemaID, id) + e.redoCurrentOperatorMap.Delete(spanStr) if e.redoTableTriggerEventDispatcher != nil && e.redoTableTriggerEventDispatcher.GetId() == id { e.redoTableTriggerEventDispatcher = nil e.metricRedoTableTriggerEventDispatcherCount.Dec() @@ -269,3 +277,7 @@ func (e *DispatcherManager) GetAllRedoDispatchers(schemaID int64) []common.Dispa } return dispatcherIDs } + +func (e *DispatcherManager) GetRedoCurrentOperatorMap() *sync.Map { + return &e.redoCurrentOperatorMap +} diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go index 61684288f5..7e5a010d48 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go @@ -62,6 +62,7 @@ func createTestDispatcher(t *testing.T, manager *DispatcherManager, id common.Di d := dispatcher.NewEventDispatcher( id, span, + false, 0, 0, dispatcher.NewSchemaIDToDispatchers(), diff --git a/downstreamadapter/dispatchermanager/helper.go b/downstreamadapter/dispatchermanager/helper.go index da4333c3e6..d74aa8b087 100644 --- a/downstreamadapter/dispatchermanager/helper.go +++ b/downstreamadapter/dispatchermanager/helper.go @@ -196,19 +196,31 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher log.Warn("scheduleDispatcherRequest is nil, skip") continue } + // If there is already an operator for the span, skip this request. + _, exists := dispatcherManager.currentOperatorMap.Load(req.Config.Span.String()) + if exists { + continue + } + _, redoExists := dispatcherManager.redoCurrentOperatorMap.Load(req.Config.Span.String()) + if redoExists { + continue + } config := req.Config dispatcherID := common.NewDispatcherIDFromPB(config.DispatcherID) switch req.ScheduleAction { case heartbeatpb.ScheduleAction_Create: info := dispatcherCreateInfo{ - Id: dispatcherID, - TableSpan: config.Span, - StartTs: config.StartTs, - SchemaID: config.SchemaID, + Id: dispatcherID, + TableSpan: config.Span, + StartTs: config.StartTs, + SchemaID: config.SchemaID, + EnabledSplit: config.EnabledSplit, } if common.IsRedoMode(config.Mode) { + dispatcherManager.redoCurrentOperatorMap.Store(req.Config.Span.String(), req) redoInfos[dispatcherID] = info } else { + dispatcherManager.currentOperatorMap.Store(req.Config.Span.String(), req) infos[dispatcherID] = info } case heartbeatpb.ScheduleAction_Remove: @@ -216,8 +228,10 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher log.Error("invalid remove dispatcher request count in one batch", zap.Int("count", len(reqs))) } if common.IsRedoMode(config.Mode) { + dispatcherManager.redoCurrentOperatorMap.Store(req.Config.Span.String(), req) removeDispatcher(dispatcherManager, dispatcherID, dispatcherManager.redoDispatcherMap, dispatcherManager.redoSink.SinkType()) } else { + dispatcherManager.currentOperatorMap.Store(req.Config.Span.String(), req) removeDispatcher(dispatcherManager, dispatcherID, dispatcherManager.dispatcherMap, dispatcherManager.sink.SinkType()) } } @@ -228,12 +242,18 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher if err != nil { dispatcherManager.handleError(context.Background(), err) } + for _, info := range redoInfos { + dispatcherManager.redoCurrentOperatorMap.Delete(info.TableSpan.String()) + } } if len(infos) > 0 { err := dispatcherManager.newEventDispatchers(infos, false) if err != nil { dispatcherManager.handleError(context.Background(), err) } + for _, info := range infos { + dispatcherManager.currentOperatorMap.Delete(info.TableSpan.String()) + } } return false } diff --git a/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go b/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go index b2ecd4f56f..99f1ea6c0f 100644 --- a/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go +++ b/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go @@ -373,6 +373,25 @@ func createBootstrapResponse( Mode: d.GetMode(), }) }) + manager.GetRedoCurrentOperatorMap().Range(func(key, value any) bool { + req := value.(*heartbeatpb.ScheduleDispatcherRequest) + d, ok := manager.GetRedoDispatcherMap().Get(common.NewDispatcherIDFromPB(req.Config.DispatcherID)) + if !ok { + log.Error("Redo dispatcher not found, this should not happen", + zap.String("changefeed", changefeedID.String()), + zap.String("dispatcherID", req.Config.DispatcherID.String()), + ) + } + req.Config.EnabledSplit = d.IsEnabledSplit() + + response.Operators = append(response.Operators, &heartbeatpb.ScheduleDispatcherRequest{ + ChangefeedID: req.ChangefeedID, + Config: req.Config, + ScheduleAction: req.ScheduleAction, + OperatorType: req.OperatorType, + }) + return true + }) } manager.GetDispatcherMap().ForEach(func(id common.DispatcherID, d *dispatcher.EventDispatcher) { response.Spans = append(response.Spans, &heartbeatpb.BootstrapTableSpan{ @@ -385,6 +404,24 @@ func createBootstrapResponse( Mode: d.GetMode(), }) }) + manager.GetCurrentOperatorMap().Range(func(key, value any) bool { + req := value.(*heartbeatpb.ScheduleDispatcherRequest) + d, ok := manager.GetDispatcherMap().Get(common.NewDispatcherIDFromPB(req.Config.DispatcherID)) + if !ok { + log.Error("Redo dispatcher not found, this should not happen", + zap.String("changefeed", changefeedID.String()), + zap.String("dispatcherID", req.Config.DispatcherID.String()), + ) + } + req.Config.EnabledSplit = d.IsEnabledSplit() + response.Operators = append(response.Operators, &heartbeatpb.ScheduleDispatcherRequest{ + ChangefeedID: req.ChangefeedID, + Config: req.Config, + ScheduleAction: req.ScheduleAction, + OperatorType: req.OperatorType, + }) + return true + }) return response } diff --git a/heartbeatpb/heartbeat.pb.go b/heartbeatpb/heartbeat.pb.go index 321405d004..d49e26ba57 100644 --- a/heartbeatpb/heartbeat.pb.go +++ b/heartbeatpb/heartbeat.pb.go @@ -73,6 +73,40 @@ func (ScheduleAction) EnumDescriptor() ([]byte, []int) { return fileDescriptor_6d584080fdadb670, []int{1} } +type OperatorType int32 + +const ( + OperatorType_O_Add OperatorType = 0 + OperatorType_O_Remove OperatorType = 1 + OperatorType_O_Move OperatorType = 2 + OperatorType_O_Split OperatorType = 3 + OperatorType_O_Merge OperatorType = 4 +) + +var OperatorType_name = map[int32]string{ + 0: "O_Add", + 1: "O_Remove", + 2: "O_Move", + 3: "O_Split", + 4: "O_Merge", +} + +var OperatorType_value = map[string]int32{ + "O_Add": 0, + "O_Remove": 1, + "O_Move": 2, + "O_Split": 3, + "O_Merge": 4, +} + +func (x OperatorType) String() string { + return proto.EnumName(OperatorType_name, int32(x)) +} + +func (OperatorType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_6d584080fdadb670, []int{2} +} + type BlockStage int32 const ( @@ -101,7 +135,7 @@ func (x BlockStage) String() string { } func (BlockStage) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_6d584080fdadb670, []int{2} + return fileDescriptor_6d584080fdadb670, []int{3} } type InfluenceType int32 @@ -129,7 +163,7 @@ func (x InfluenceType) String() string { } func (InfluenceType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_6d584080fdadb670, []int{3} + return fileDescriptor_6d584080fdadb670, []int{4} } type ComponentState int32 @@ -169,7 +203,7 @@ func (x ComponentState) String() string { } func (ComponentState) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_6d584080fdadb670, []int{4} + return fileDescriptor_6d584080fdadb670, []int{5} } type TableSpan struct { @@ -813,6 +847,7 @@ type DispatcherConfig struct { DispatcherID *DispatcherID `protobuf:"bytes,3,opt,name=dispatcherID,proto3" json:"dispatcherID,omitempty"` SchemaID int64 `protobuf:"varint,4,opt,name=schemaID,proto3" json:"schemaID,omitempty"` Mode int64 `protobuf:"varint,5,opt,name=mode,proto3" json:"mode,omitempty"` + EnabledSplit bool `protobuf:"varint,6,opt,name=enabledSplit,proto3" json:"enabledSplit,omitempty"` } func (m *DispatcherConfig) Reset() { *m = DispatcherConfig{} } @@ -883,10 +918,18 @@ func (m *DispatcherConfig) GetMode() int64 { return 0 } +func (m *DispatcherConfig) GetEnabledSplit() bool { + if m != nil { + return m.EnabledSplit + } + return false +} + type ScheduleDispatcherRequest struct { ChangefeedID *ChangefeedID `protobuf:"bytes,1,opt,name=changefeedID,proto3" json:"changefeedID,omitempty"` Config *DispatcherConfig `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` ScheduleAction ScheduleAction `protobuf:"varint,3,opt,name=scheduleAction,proto3,enum=heartbeatpb.ScheduleAction" json:"scheduleAction,omitempty"` + OperatorType OperatorType `protobuf:"varint,4,opt,name=operatorType,proto3,enum=heartbeatpb.OperatorType" json:"operatorType,omitempty"` } func (m *ScheduleDispatcherRequest) Reset() { *m = ScheduleDispatcherRequest{} } @@ -943,6 +986,13 @@ func (m *ScheduleDispatcherRequest) GetScheduleAction() ScheduleAction { return ScheduleAction_Create } +func (m *ScheduleDispatcherRequest) GetOperatorType() OperatorType { + if m != nil { + return m.OperatorType + } + return OperatorType_O_Add +} + type MergeDispatcherRequest struct { ChangefeedID *ChangefeedID `protobuf:"bytes,1,opt,name=changefeedID,proto3" json:"changefeedID,omitempty"` DispatcherIDs []*DispatcherID `protobuf:"bytes,2,rep,name=dispatcherIDs,proto3" json:"dispatcherIDs,omitempty"` @@ -1483,7 +1533,8 @@ type MaintainerBootstrapResponse struct { // // For nodes without a table trigger event dispatcher: // - checkpoint_ts is set to 0 - CheckpointTs uint64 `protobuf:"varint,4,opt,name=checkpoint_ts,json=checkpointTs,proto3" json:"checkpoint_ts,omitempty"` + CheckpointTs uint64 `protobuf:"varint,4,opt,name=checkpoint_ts,json=checkpointTs,proto3" json:"checkpoint_ts,omitempty"` + Operators []*ScheduleDispatcherRequest `protobuf:"bytes,5,rep,name=operators,proto3" json:"operators,omitempty"` } func (m *MaintainerBootstrapResponse) Reset() { *m = MaintainerBootstrapResponse{} } @@ -1547,6 +1598,13 @@ func (m *MaintainerBootstrapResponse) GetCheckpointTs() uint64 { return 0 } +func (m *MaintainerBootstrapResponse) GetOperators() []*ScheduleDispatcherRequest { + if m != nil { + return m.Operators + } + return nil +} + type MaintainerPostBootstrapRequest struct { ChangefeedID *ChangefeedID `protobuf:"bytes,1,opt,name=changefeedID,proto3" json:"changefeedID,omitempty"` TableTriggerEventDispatcherId *DispatcherID `protobuf:"bytes,2,opt,name=table_trigger_event_dispatcher_id,json=tableTriggerEventDispatcherId,proto3" json:"table_trigger_event_dispatcher_id,omitempty"` @@ -2741,6 +2799,7 @@ func (m *LogCoordinatorResolvedTsResponse) GetResolvedTs() uint64 { func init() { proto.RegisterEnum("heartbeatpb.Action", Action_name, Action_value) proto.RegisterEnum("heartbeatpb.ScheduleAction", ScheduleAction_name, ScheduleAction_value) + proto.RegisterEnum("heartbeatpb.OperatorType", OperatorType_name, OperatorType_value) proto.RegisterEnum("heartbeatpb.BlockStage", BlockStage_name, BlockStage_value) proto.RegisterEnum("heartbeatpb.InfluenceType", InfluenceType_name, InfluenceType_value) proto.RegisterEnum("heartbeatpb.ComponentState", ComponentState_name, ComponentState_value) @@ -2789,138 +2848,143 @@ func init() { func init() { proto.RegisterFile("heartbeatpb/heartbeat.proto", fileDescriptor_6d584080fdadb670) } var fileDescriptor_6d584080fdadb670 = []byte{ - // 2084 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x19, 0x4d, 0x6f, 0x1c, 0x49, - 0xd5, 0xdd, 0x3d, 0x9f, 0x6f, 0x3c, 0x76, 0xa7, 0xb2, 0x71, 0x26, 0xb1, 0xe3, 0x38, 0xcd, 0x87, - 0x8c, 0x17, 0x1c, 0xc5, 0xbb, 0x11, 0x1f, 0x5a, 0x08, 0xf6, 0x4c, 0xd8, 0x1d, 0x99, 0x78, 0xad, - 0x1a, 0xa3, 0xf0, 0x71, 0x18, 0xda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xb7, 0x53, 0x08, 0x38, - 0x83, 0x8e, 0x3e, 0x84, 0xfa, 0x99, 0x19, 0x92, 0x60, 0x64, 0x06, 0xa7, 0x5c, 0xd0, 0xc6, 0xce, - 0x4a, 0x86, 0xf6, 0xb9, 0xdc, 0xc5, 0x09, 0x22, 0xfa, 0x08, 0x9a, 0x01, 0xb1, 0xbd, 0x78, 0x8f, - 0x5f, 0x64, 0x3a, 0x65, 0x16, 0x19, 0x7d, 0x0b, 0x6a, 0x34, 0x34, 0xc3, 0x31, 0x25, 0xb4, 0x55, - 0xda, 0xd0, 0x36, 0x1b, 0x3b, 0x6b, 0x19, 0xc2, 0x58, 0xbf, 0x3d, 0x8e, 0x85, 0x63, 0x6c, 0xb4, - 0x09, 0xcb, 0x96, 0x37, 0xf2, 0xc9, 0x90, 0x84, 0x24, 0xda, 0x6c, 0x95, 0x37, 0x94, 0xcd, 0x1a, - 0xce, 0x2f, 0xa3, 0xf7, 0x41, 0x23, 0x41, 0xd0, 0xaa, 0x14, 0x68, 0x03, 0x8f, 0x5d, 0xd7, 0x71, - 0x07, 0x4f, 0x83, 0xc0, 0x0b, 0x30, 0xc3, 0x32, 0x7e, 0xa3, 0x40, 0x3d, 0x11, 0xcf, 0x60, 0x1a, - 0x25, 0xd6, 0xa9, 0xef, 0x39, 0x6e, 0x78, 0x44, 0xb9, 0x46, 0x4b, 0x38, 0xb3, 0xc6, 0x4c, 0x15, - 0x10, 0xea, 0x0d, 0x5f, 0x11, 0xfb, 0x88, 0x72, 0xbd, 0x95, 0x70, 0x6a, 0x05, 0xe9, 0xa0, 0x51, - 0xf2, 0x92, 0xab, 0xa5, 0x84, 0xd9, 0x27, 0xe3, 0x3a, 0x34, 0x69, 0xd8, 0x3b, 0x77, 0x2d, 0x4e, - 0x53, 0x8a, 0xb8, 0xa6, 0xd7, 0x8c, 0x5f, 0x80, 0xde, 0x71, 0xa8, 0x6f, 0x86, 0xd6, 0x09, 0x09, - 0x76, 0xad, 0xd0, 0xf1, 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9, 0xa6, 0xf1, 0x27, 0x05, 0x6e, - 0xa4, 0x92, 0x0e, 0xf5, 0x3d, 0x97, 0x92, 0xeb, 0x66, 0x9d, 0x67, 0x80, 0xec, 0x9c, 0x76, 0x88, - 0xb4, 0xe6, 0x34, 0xd9, 0x45, 0x32, 0x28, 0x20, 0x44, 0x08, 0x4a, 0x23, 0xcf, 0x26, 0xc2, 0xa4, - 0xfc, 0xdb, 0x78, 0x0d, 0x37, 0xdb, 0xa9, 0x88, 0x7d, 0x46, 0x28, 0x35, 0x07, 0xd7, 0x16, 0x3c, - 0x9f, 0x1b, 0xd4, 0xc9, 0xdc, 0x60, 0x7c, 0xa6, 0x40, 0x03, 0x13, 0xdb, 0x9b, 0xd3, 0x91, 0xb3, - 0x52, 0x4d, 0x5e, 0x24, 0xad, 0x40, 0xa4, 0xac, 0x3b, 0xb6, 0x3d, 0xf7, 0x85, 0x33, 0x40, 0x5b, - 0x50, 0xa2, 0xbe, 0xe9, 0x0a, 0x79, 0x56, 0x8a, 0x53, 0x30, 0xe6, 0x38, 0xac, 0xd0, 0x51, 0x56, - 0xbe, 0x62, 0x09, 0x24, 0xc8, 0x6e, 0x67, 0xa7, 0xc2, 0x41, 0x38, 0xd3, 0x05, 0xf1, 0x92, 0x41, - 0x67, 0x11, 0x49, 0x65, 0x44, 0x96, 0xa2, 0x88, 0x94, 0x70, 0x6c, 0xd6, 0x72, 0xca, 0xac, 0x5f, - 0x28, 0x70, 0x87, 0x85, 0xac, 0x3d, 0x1e, 0xa6, 0x22, 0x6e, 0x4e, 0xc5, 0xf0, 0x31, 0x54, 0x2c, - 0xae, 0x9b, 0x19, 0x61, 0x14, 0x29, 0x10, 0x0b, 0x64, 0xd4, 0x86, 0x25, 0x2a, 0x44, 0x8a, 0x02, - 0x8c, 0x2b, 0x61, 0x69, 0x67, 0x35, 0x43, 0xde, 0xcb, 0xa0, 0xe0, 0x1c, 0x89, 0xf1, 0x5f, 0x05, - 0x56, 0x9e, 0x91, 0x60, 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d4, - 0x71, 0x85, 0xff, 0xe4, 0xfc, 0xe0, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd2, 0x79, 0xcd, 0x26, - 0x03, 0x1d, 0x00, 0x00, + // 2173 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x19, 0x4b, 0x6c, 0x1c, 0x49, + 0xd5, 0xdd, 0x3d, 0xdf, 0x37, 0x1e, 0xa7, 0x53, 0xd9, 0x38, 0x93, 0xd8, 0x71, 0x9c, 0x06, 0x56, + 0xc6, 0x0b, 0x8e, 0xe2, 0xdd, 0x88, 0x8f, 0x16, 0x82, 0x3d, 0x13, 0x76, 0x47, 0xc6, 0x1f, 0x95, + 0x8d, 0xc2, 0xe7, 0x30, 0xb4, 0xbb, 0x2b, 0xe3, 0x96, 0x67, 0xba, 0x3b, 0x5d, 0xed, 0x38, 0x8e, + 0x84, 0x10, 0x42, 0xdc, 0x38, 0xec, 0x85, 0x03, 0x47, 0xce, 0x48, 0x88, 0x0b, 0x47, 0x24, 0x6e, + 0x20, 0x71, 0xd9, 0x13, 0xe2, 0x88, 0x92, 0x23, 0x17, 0xc4, 0x85, 0x2b, 0xaa, 0xea, 0xaa, 0xfe, + 0x8f, 0x3f, 0xf2, 0x88, 0x5b, 0xbf, 0xaa, 0xf7, 0x5e, 0xbd, 0x7a, 0xff, 0x7a, 0x0d, 0x0b, 0x47, + 0xc4, 0x0c, 0xc2, 0x43, 0x62, 0x86, 0xfe, 0xe1, 0xa3, 0xf8, 0x7b, 0xcd, 0x0f, 0xbc, 0xd0, 0x43, + 0xad, 0xd4, 0xa6, 0x71, 0x06, 0xcd, 0x03, 0xf3, 0x70, 0x44, 0xf6, 0x7d, 0xd3, 0x45, 0x1d, 0xa8, + 0x73, 0xa0, 0xdf, 0xeb, 0x28, 0xcb, 0xca, 0x8a, 0x86, 0x25, 0x88, 0xee, 0x41, 0x63, 0x3f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, + 0x9a, 0x6c, 0x63, 0x90, 0x4b, 0x7d, 0xdb, 0xf8, 0x8d, 0x02, 0x77, 0x30, 0x19, 0x7b, 0xaf, 0xc8, + 0xb5, 0x2e, 0xd4, 0x81, 0xba, 0x65, 0x52, 0xcb, 0xb4, 0x89, 0x68, 0xf8, 0x24, 0xc8, 0x76, 0x02, + 0xce, 0xdf, 0x16, 0xfd, 0xa4, 0x04, 0xf3, 0xb2, 0x55, 0x0a, 0xb2, 0xfd, 0x5e, 0x83, 0x7b, 0x89, + 0x54, 0x05, 0xeb, 0x5f, 0x33, 0x94, 0x26, 0xd9, 0xe0, 0x2e, 0x77, 0x8d, 0x20, 0xa5, 0xfe, 0xb8, + 0x90, 0x59, 0xf0, 0x30, 0x64, 0x45, 0x64, 0x10, 0x06, 0xce, 0x70, 0x48, 0x82, 0x01, 0x79, 0x45, + 0xdc, 0x70, 0x90, 0xe4, 0x29, 0x79, 0x8f, 0x73, 0x33, 0xd2, 0x7d, 0xce, 0xe3, 0x20, 0x62, 0xf1, + 0x8c, 0x71, 0x48, 0xf7, 0x85, 0xe5, 0xe6, 0xad, 0x96, 0x9b, 0x77, 0x04, 0xef, 0xb3, 0x77, 0xd3, + 0xe0, 0x62, 0xa9, 0x6a, 0x17, 0x49, 0xf5, 0x90, 0x31, 0x3a, 0x38, 0x57, 0xb2, 0x9c, 0xc1, 0xea, + 0x05, 0x83, 0xfd, 0x4e, 0x85, 0x85, 0x52, 0x83, 0x4d, 0xa7, 0x25, 0x7c, 0x02, 0x55, 0xd6, 0x69, + 0xc8, 0xd2, 0xf1, 0x20, 0x43, 0x17, 0x9f, 0x96, 0xf4, 0x25, 0x11, 0xb6, 0x4c, 0x5e, 0xda, 0x65, + 0xde, 0x79, 0x97, 0x4b, 0x87, 0x3d, 0x68, 0xca, 0xaa, 0x49, 0x45, 0x52, 0x7c, 0xbf, 0xb4, 0x48, + 0x17, 0xaa, 0x28, 0x4e, 0x08, 0x59, 0xad, 0x5d, 0x4a, 0x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, 0x00, 0x00, } func (m *TableSpan) Marshal() (dAtA []byte, err error) { @@ -3466,6 +3530,16 @@ func (m *DispatcherConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.EnabledSplit { + i-- + if m.EnabledSplit { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } if m.Mode != 0 { i = encodeVarintHeartbeat(dAtA, i, uint64(m.Mode)) i-- @@ -3528,6 +3602,11 @@ func (m *ScheduleDispatcherRequest) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l + if m.OperatorType != 0 { + i = encodeVarintHeartbeat(dAtA, i, uint64(m.OperatorType)) + i-- + dAtA[i] = 0x20 + } if m.ScheduleAction != 0 { i = encodeVarintHeartbeat(dAtA, i, uint64(m.ScheduleAction)) i-- @@ -4037,6 +4116,20 @@ func (m *MaintainerBootstrapResponse) MarshalToSizedBuffer(dAtA []byte) (int, er _ = i var l int _ = l + if len(m.Operators) > 0 { + for iNdEx := len(m.Operators) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Operators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintHeartbeat(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } if m.CheckpointTs != 0 { i = encodeVarintHeartbeat(dAtA, i, uint64(m.CheckpointTs)) i-- @@ -5310,6 +5403,9 @@ func (m *DispatcherConfig) Size() (n int) { if m.Mode != 0 { n += 1 + sovHeartbeat(uint64(m.Mode)) } + if m.EnabledSplit { + n += 2 + } return n } @@ -5330,6 +5426,9 @@ func (m *ScheduleDispatcherRequest) Size() (n int) { if m.ScheduleAction != 0 { n += 1 + sovHeartbeat(uint64(m.ScheduleAction)) } + if m.OperatorType != 0 { + n += 1 + sovHeartbeat(uint64(m.OperatorType)) + } return n } @@ -5541,6 +5640,12 @@ func (m *MaintainerBootstrapResponse) Size() (n int) { if m.CheckpointTs != 0 { n += 1 + sovHeartbeat(uint64(m.CheckpointTs)) } + if len(m.Operators) > 0 { + for _, e := range m.Operators { + l = e.Size() + n += 1 + l + sovHeartbeat(uint64(l)) + } + } return n } @@ -7524,6 +7629,26 @@ func (m *DispatcherConfig) Unmarshal(dAtA []byte) error { break } } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EnabledSplit", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeartbeat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.EnabledSplit = bool(v != 0) default: iNdEx = preIndex skippy, err := skipHeartbeat(dAtA[iNdEx:]) @@ -7665,6 +7790,25 @@ func (m *ScheduleDispatcherRequest) Unmarshal(dAtA []byte) error { break } } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorType", wireType) + } + m.OperatorType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeartbeat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OperatorType |= OperatorType(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipHeartbeat(dAtA[iNdEx:]) @@ -9054,6 +9198,40 @@ func (m *MaintainerBootstrapResponse) Unmarshal(dAtA []byte) error { break } } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operators", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeartbeat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthHeartbeat + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthHeartbeat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Operators = append(m.Operators, &ScheduleDispatcherRequest{}) + if err := m.Operators[len(m.Operators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipHeartbeat(dAtA[iNdEx:]) diff --git a/heartbeatpb/heartbeat.proto b/heartbeatpb/heartbeat.proto index da0061acdb..90d1b632af 100644 --- a/heartbeatpb/heartbeat.proto +++ b/heartbeatpb/heartbeat.proto @@ -80,18 +80,28 @@ enum ScheduleAction { Remove = 1; } +enum OperatorType { + O_Add = 0; + O_Remove = 1; + O_Move = 2; + O_Split = 3; + O_Merge = 4; +} + message DispatcherConfig { TableSpan span = 1; uint64 startTs = 2; DispatcherID dispatcherID = 3; int64 schemaID = 4; int64 mode = 5; + bool enabledSplit = 6; } message ScheduleDispatcherRequest { ChangefeedID changefeedID = 1; DispatcherConfig config = 2; ScheduleAction scheduleAction = 3; + OperatorType operatorType = 4; } message MergeDispatcherRequest { @@ -161,6 +171,7 @@ message MaintainerBootstrapResponse { // For nodes without a table trigger event dispatcher: // - checkpoint_ts is set to 0 uint64 checkpoint_ts = 4; + repeated ScheduleDispatcherRequest operators = 5; } message MaintainerPostBootstrapRequest { diff --git a/maintainer/barrier_test.go b/maintainer/barrier_test.go index 0311f89e09..2c136b317c 100644 --- a/maintainer/barrier_test.go +++ b/maintainer/barrier_test.go @@ -928,7 +928,7 @@ func TestUpdateCheckpointTs(t *testing.T) { require.Equal(t, resp.DispatcherStatuses[1].Action.Action, heartbeatpb.Action_Write) require.False(t, resp.DispatcherStatuses[1].Action.IsSyncPoint) // the checkpoint ts is updated - scheduleMsg := ddlSpan.NewAddDispatcherMessage("node1") + scheduleMsg := ddlSpan.NewAddDispatcherMessage("node1", heartbeatpb.OperatorType_O_Add) require.Equal(t, uint64(9), scheduleMsg.Message[0].(*heartbeatpb.ScheduleDispatcherRequest).Config.StartTs, false) require.NotEqual(t, uint64(0), scheduleMsg.Message[0].(*heartbeatpb.ScheduleDispatcherRequest).Config.StartTs, false) } diff --git a/maintainer/maintainer_controller.go b/maintainer/maintainer_controller.go index 6c3ec9c2b7..752667e6b5 100644 --- a/maintainer/maintainer_controller.go +++ b/maintainer/maintainer_controller.go @@ -156,7 +156,7 @@ func (c *Controller) HandleStatus(from node.ID, statusList []*heartbeatpb.TableS zap.Any("status", status), zap.String("dispatcherID", dispatcherID.String())) // if the span is not found, and the status is working, we need to remove it from dispatcher - _ = c.messageCenter.SendCommand(replica.NewRemoveDispatcherMessage(from, c.changefeedID, status.ID, status.Mode)) + _ = c.messageCenter.SendCommand(replica.NewRemoveDispatcherMessage(from, c.changefeedID, status.ID, status.Mode, heartbeatpb.OperatorType_O_Remove)) } continue } diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 69300041fc..8a1d541e6d 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -21,6 +21,7 @@ import ( "github.com/pingcap/log" "github.com/pingcap/ticdc/heartbeatpb" "github.com/pingcap/ticdc/logservice/schemastore" + "github.com/pingcap/ticdc/maintainer/operator" "github.com/pingcap/ticdc/maintainer/replica" "github.com/pingcap/ticdc/maintainer/span" "github.com/pingcap/ticdc/maintainer/split" @@ -107,6 +108,8 @@ func (c *Controller) FinishBootstrap( workingTaskMap, redoWorkingTaskMap := c.buildWorkingTaskMap(allNodesResp, tableSplitMap) // Step 4: Process tables and build schema info + // restore current working operators first + c.restoreCurrentWorkingOperators(allNodesResp) schemaInfos := c.processTablesAndBuildSchemaInfo(tables, workingTaskMap, redoWorkingTaskMap, isMysqlCompatibleBackend) // Step 5: Handle any remaining working tasks (likely dropped tables) @@ -214,10 +217,12 @@ func (c *Controller) processTableSpans( ) { tableSpans, isTableWorking := workingTaskMap[table.TableID] spanController := c.getSpanController(mode) + replicaSets := spanController.GetTasksByTableID(table.TableID) + isTableSpanExists := replicaSets != nil && len(replicaSets) > 0 splitEnabled := spanController.ShouldEnableSplit(table.Splitable) // Add new table if not working - if isTableWorking { + if isTableWorking || isTableSpanExists { // Handle existing table spans keyspaceID := c.GetKeyspaceID() span := common.TableIDToComparableSpan(keyspaceID, table.TableID) @@ -234,6 +239,11 @@ func (c *Controller) processTableSpans( spanController.AddWorkingSpans(tableSpans) if c.enableTableAcrossNodes { + if isTableSpanExists { + for _, replicaSet := range replicaSets { + tableSpans.ReplaceOrInsert(replicaSet.Span, replicaSet) + } + } c.handleTableHoles(spanController, table, tableSpans, tableSpan, splitEnabled) } // Remove processed table from working task map @@ -409,3 +419,65 @@ func findHoles(currentSpan utils.Map[*heartbeatpb.TableSpan, *replica.SpanReplic } return holes } + +func (c *Controller) restoreCurrentWorkingOperators( + allNodesResp map[node.ID]*heartbeatpb.MaintainerBootstrapResponse, +) error { + for node, resp := range allNodesResp { + for _, req := range resp.Operators { + dispatcherID := common.NewDispatcherIDFromPB(req.Config.DispatcherID) + spanController := c.getSpanController(req.Config.Mode) + replicaSet := spanController.GetTaskByID(dispatcherID) + if replicaSet != nil { + log.Error("found duplicate replica set, which should not happen", + zap.String("nodeID", node.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.Any("replicaSet", replicaSet)) + return errors.New("duplicate replica set found") + } + replicaSet = replica.NewSpanReplication( + c.changefeedID, + dispatcherID, + req.Config.SchemaID, + req.Config.Span, + req.Config.StartTs, + req.Config.Mode, + req.Config.EnabledSplit, + ) + spanController.AddAbsentReplicaSet(replicaSet) + switch req.ScheduleAction { + case heartbeatpb.ScheduleAction_Create: + switch req.OperatorType { + case heartbeatpb.OperatorType_O_Add, heartbeatpb.OperatorType_O_Move, heartbeatpb.OperatorType_O_Split: + op := operator.NewAddDispatcherOperator(spanController, replicaSet, node, heartbeatpb.OperatorType_O_Add) + c.operatorController.AddOperator(op) + op.Start() + } + case heartbeatpb.ScheduleAction_Remove: + switch req.OperatorType { + case heartbeatpb.OperatorType_O_Remove: + op := operator.NewRemoveDispatcherOperator( + spanController, + replicaSet, + heartbeatpb.OperatorType_O_Remove, + nil, + ) + c.operatorController.AddOperator(op) + op.Start() + case heartbeatpb.OperatorType_O_Move, heartbeatpb.OperatorType_O_Split: + op := operator.NewRemoveDispatcherOperator( + spanController, + replicaSet, + req.OperatorType, + func() { // post finish + spanController.MarkAbsentWithoutLock(replicaSet) + }, + ) + c.operatorController.AddOperator(op) + op.Start() + } + } + } + } + return nil +} diff --git a/maintainer/maintainer_controller_helper.go b/maintainer/maintainer_controller_helper.go index ead2e4d2d2..947c1ff7f5 100644 --- a/maintainer/maintainer_controller_helper.go +++ b/maintainer/maintainer_controller_helper.go @@ -68,7 +68,7 @@ func (c *Controller) moveTable(tableId int64, targetNode node.ID, mode int64) er count := 0 maxTry := 30 for !op.IsFinished() && count < maxTry { - time.Sleep(1 * time.Second) + time.Sleep(2 * time.Second) count += 1 log.Info("wait for move table operator finished", zap.Int("count", count)) } diff --git a/maintainer/operator/operator_add.go b/maintainer/operator/operator_add.go index 3a32897f88..679d1270c1 100644 --- a/maintainer/operator/operator_add.go +++ b/maintainer/operator/operator_add.go @@ -34,6 +34,8 @@ type AddDispatcherOperator struct { finished atomic.Bool removed atomic.Bool spanController *span.Controller + // This add operator may be a part of move/split operator + operatorType heartbeatpb.OperatorType sendThrottler sendThrottler } @@ -42,6 +44,7 @@ func NewAddDispatcherOperator( spanController *span.Controller, replicaSet *replica.SpanReplication, dest node.ID, + operatorType heartbeatpb.OperatorType, ) *AddDispatcherOperator { return &AddDispatcherOperator{ replicaSet: replicaSet, @@ -81,7 +84,7 @@ func (m *AddDispatcherOperator) Schedule() *messaging.TargetMessage { if !m.sendThrottler.shouldSend() { return nil } - return m.replicaSet.NewAddDispatcherMessage(m.dest) + return m.replicaSet.NewAddDispatcherMessage(m.dest, m.operatorType) } // OnNodeRemove is called when node offline, and the replicaset must already move to absent status and will be scheduled again @@ -110,6 +113,9 @@ func (m *AddDispatcherOperator) OnTaskRemoved() { } func (m *AddDispatcherOperator) Start() { + if m.removed.Load() || m.finished.Load() { + return + } m.spanController.BindSpanToNode("", m.dest, m.replicaSet) } diff --git a/maintainer/operator/operator_add_test.go b/maintainer/operator/operator_add_test.go index 54fb276fcd..bf38519793 100644 --- a/maintainer/operator/operator_add_test.go +++ b/maintainer/operator/operator_add_test.go @@ -50,7 +50,7 @@ func TestAddOperator_DestNodeRemoved(t *testing.T) { spanController.AddAbsentReplicaSet(absentReplicaSet) - op := NewAddDispatcherOperator(spanController, absentReplicaSet, nodeB) + op := NewAddDispatcherOperator(spanController, absentReplicaSet, nodeB, heartbeatpb.OperatorType_O_Add) require.NotNil(t, op) op.Start() diff --git a/maintainer/operator/operator_controller.go b/maintainer/operator/operator_controller.go index 11186dc8f7..c10e098be7 100644 --- a/maintainer/operator/operator_controller.go +++ b/maintainer/operator/operator_controller.go @@ -117,7 +117,7 @@ func (oc *Controller) Execute() time.Time { func (oc *Controller) RemoveTasksBySchemaID(schemaID int64) { tasks := oc.spanController.GetRemoveTasksBySchemaID(schemaID) for _, task := range tasks { - oc.removeReplicaSet(newRemoveDispatcherOperator(oc.spanController, task)) + oc.removeReplicaSet(newRemoveDispatcherOperator(oc.spanController, task, heartbeatpb.OperatorType_O_Remove)) } oc.spanController.RemoveBySchemaID(schemaID) } @@ -135,7 +135,7 @@ func (oc *Controller) RemoveTasksBySchemaID(schemaID int64) { func (oc *Controller) RemoveTasksByTableIDs(tables ...int64) { tasks := oc.spanController.GetRemoveTasksByTableIDs(tables...) for _, task := range tasks { - oc.removeReplicaSet(newRemoveDispatcherOperator(oc.spanController, task)) + oc.removeReplicaSet(newRemoveDispatcherOperator(oc.spanController, task, heartbeatpb.OperatorType_O_Remove)) } oc.spanController.RemoveByTableIDs(tables...) } @@ -356,12 +356,7 @@ func (oc *Controller) checkAffectedNodes(op operator.Operator[common.DispatcherI } func (oc *Controller) NewMoveOperator(replicaSet *replica.SpanReplication, origin, dest node.ID) operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus] { - return &MoveDispatcherOperator{ - replicaSet: replicaSet, - origin: origin, - dest: dest, - spanController: oc.spanController, - } + return NewMoveDispatcherOperator(oc.spanController, replicaSet, origin, dest) } func checkMergeOperator(affectedReplicaSets []*replica.SpanReplication) bool { diff --git a/maintainer/operator/operator_move.go b/maintainer/operator/operator_move.go index 350dfae5d5..fcccbe4adc 100644 --- a/maintainer/operator/operator_move.go +++ b/maintainer/operator/operator_move.go @@ -91,13 +91,13 @@ func (m *MoveDispatcherOperator) Schedule() *messaging.TargetMessage { if !m.sendThrottler.shouldSend() { return nil } - return m.replicaSet.NewAddDispatcherMessage(m.dest) + return m.replicaSet.NewAddDispatcherMessage(m.dest, heartbeatpb.OperatorType_O_Move) } if !m.sendThrottler.shouldSend() { return nil } - return m.replicaSet.NewRemoveDispatcherMessage(m.origin) + return m.replicaSet.NewRemoveDispatcherMessage(m.origin, heartbeatpb.OperatorType_O_Move) } func (m *MoveDispatcherOperator) OnNodeRemove(n node.ID) { diff --git a/maintainer/operator/operator_remove.go b/maintainer/operator/operator_remove.go index 0ecfd69557..3ec59580ec 100644 --- a/maintainer/operator/operator_remove.go +++ b/maintainer/operator/operator_remove.go @@ -32,15 +32,34 @@ import ( type removeDispatcherOperator struct { replicaSet *replica.SpanReplication finished atomic.Bool + postFinish func() spanController *span.Controller + // This remove operator may be a part of move/split operator + operatorType heartbeatpb.OperatorType sendThrottler sendThrottler } -func newRemoveDispatcherOperator(spanController *span.Controller, replicaSet *replica.SpanReplication) *removeDispatcherOperator { +func NewRemoveDispatcherOperator( + spanController *span.Controller, + replicaSet *replica.SpanReplication, + operatorType heartbeatpb.OperatorType, + postFinish func(), +) *removeDispatcherOperator { return &removeDispatcherOperator{ replicaSet: replicaSet, spanController: spanController, + postFinish: postFinish, + operatorType: operatorType, + sendThrottler: newSendThrottler(), + } +} + +func newRemoveDispatcherOperator(spanController *span.Controller, replicaSet *replica.SpanReplication, operatorType heartbeatpb.OperatorType) *removeDispatcherOperator { + return &removeDispatcherOperator{ + replicaSet: replicaSet, + spanController: spanController, + operatorType: operatorType, sendThrottler: newSendThrottler(), } } @@ -56,11 +75,11 @@ func (m *removeDispatcherOperator) Check(from node.ID, status *heartbeatpb.Table } func (m *removeDispatcherOperator) Schedule() *messaging.TargetMessage { - if !m.sendThrottler.shouldSend() { + if !m.sendThrottler.shouldSend() || m.finished.Load() { return nil } - return m.replicaSet.NewRemoveDispatcherMessage(m.replicaSet.GetNodeID()) + return m.replicaSet.NewRemoveDispatcherMessage(m.replicaSet.GetNodeID(), m.operatorType) } // OnNodeRemove is called when node offline, and the replicaset has been removed from spanController, so it's ok. @@ -96,6 +115,10 @@ func (m *removeDispatcherOperator) PostFinish() { log.Info("remove dispatcher operator finished", zap.String("replicaSet", m.replicaSet.ID.String()), zap.String("changefeed", m.replicaSet.ChangefeedID.String())) + + if m.postFinish != nil { + m.postFinish() + } } func (m *removeDispatcherOperator) String() string { diff --git a/maintainer/operator/operator_remove_test.go b/maintainer/operator/operator_remove_test.go index 1902a34253..e3777f7123 100644 --- a/maintainer/operator/operator_remove_test.go +++ b/maintainer/operator/operator_remove_test.go @@ -16,6 +16,7 @@ package operator import ( "testing" + "github.com/pingcap/ticdc/heartbeatpb" "github.com/pingcap/ticdc/pkg/messaging" "github.com/stretchr/testify/require" ) @@ -27,7 +28,7 @@ import ( func TestRemoveOperator_NodeRemovedBeforeStopped(t *testing.T) { spanController, _, replicaSet, nodeA, _ := setupTestEnvironment(t) - op := newRemoveDispatcherOperator(spanController, replicaSet) + op := newRemoveDispatcherOperator(spanController, replicaSet, heartbeatpb.OperatorType_O_Remove) require.NotNil(t, op) op.Start() diff --git a/maintainer/operator/operator_split.go b/maintainer/operator/operator_split.go index c97d452c94..d88cba8d6c 100644 --- a/maintainer/operator/operator_split.go +++ b/maintainer/operator/operator_split.go @@ -133,7 +133,7 @@ func (m *SplitDispatcherOperator) Schedule() *messaging.TargetMessage { if !m.sendThrottler.shouldSend() { return nil } - return m.replicaSet.NewRemoveDispatcherMessage(m.originNode) + return m.replicaSet.NewRemoveDispatcherMessage(m.originNode, heartbeatpb.OperatorType_O_Split) } // OnTaskRemoved is called when the task is removed by ddl diff --git a/maintainer/replica/replication_span.go b/maintainer/replica/replication_span.go index 6e86f086db..fa3f772e4a 100644 --- a/maintainer/replica/replication_span.go +++ b/maintainer/replica/replication_span.go @@ -228,7 +228,7 @@ func (r *SpanReplication) GetGroupID() replica.GroupID { return r.groupID } -func (r *SpanReplication) NewAddDispatcherMessage(server node.ID) *messaging.TargetMessage { +func (r *SpanReplication) NewAddDispatcherMessage(server node.ID, operatorType heartbeatpb.OperatorType) *messaging.TargetMessage { return messaging.NewSingleTargetMessage(server, messaging.HeartbeatCollectorTopic, &heartbeatpb.ScheduleDispatcherRequest{ @@ -239,16 +239,18 @@ func (r *SpanReplication) NewAddDispatcherMessage(server node.ID) *messaging.Tar Span: r.Span, StartTs: r.status.Load().CheckpointTs, Mode: r.GetMode(), + EnabledSplit: r.enabledSplit, }, ScheduleAction: heartbeatpb.ScheduleAction_Create, + OperatorType: operatorType, }) } -func (r *SpanReplication) NewRemoveDispatcherMessage(server node.ID) *messaging.TargetMessage { - return NewRemoveDispatcherMessage(server, r.ChangefeedID, r.ID.ToPB(), r.GetMode()) +func (r *SpanReplication) NewRemoveDispatcherMessage(server node.ID, operatorType heartbeatpb.OperatorType) *messaging.TargetMessage { + return NewRemoveDispatcherMessage(server, r.ChangefeedID, r.ID.ToPB(), r.GetMode(), operatorType) } -func NewRemoveDispatcherMessage(server node.ID, cfID common.ChangeFeedID, dispatcherID *heartbeatpb.DispatcherID, mode int64) *messaging.TargetMessage { +func NewRemoveDispatcherMessage(server node.ID, cfID common.ChangeFeedID, dispatcherID *heartbeatpb.DispatcherID, mode int64, operatorType heartbeatpb.OperatorType) *messaging.TargetMessage { return messaging.NewSingleTargetMessage(server, messaging.HeartbeatCollectorTopic, &heartbeatpb.ScheduleDispatcherRequest{ @@ -258,5 +260,6 @@ func NewRemoveDispatcherMessage(server node.ID, cfID common.ChangeFeedID, dispat Mode: mode, }, ScheduleAction: heartbeatpb.ScheduleAction_Remove, + OperatorType: operatorType, }) } diff --git a/maintainer/replica/replication_span_test.go b/maintainer/replica/replication_span_test.go index 36419fabb0..52e4a0c697 100644 --- a/maintainer/replica/replication_span_test.go +++ b/maintainer/replica/replication_span_test.go @@ -35,7 +35,7 @@ func TestNewRemoveDispatcherMessage(t *testing.T) { t.Parallel() replicaSet := NewSpanReplication(common.NewChangeFeedIDWithName("test", common.DefaultKeyspaceNamme), common.NewDispatcherID(), 1, getTableSpanByID(4), 10, common.DefaultMode, false) - msg := replicaSet.NewRemoveDispatcherMessage("node1") + msg := replicaSet.NewRemoveDispatcherMessage("node1", heartbeatpb.OperatorType_O_Remove) req := msg.Message[0].(*heartbeatpb.ScheduleDispatcherRequest) require.Equal(t, heartbeatpb.ScheduleAction_Remove, req.ScheduleAction) require.Equal(t, replicaSet.ID.ToPB(), req.Config.DispatcherID) @@ -47,7 +47,7 @@ func TestSpanReplication_NewAddDispatcherMessage(t *testing.T) { replicaSet := NewSpanReplication(common.NewChangeFeedIDWithName("test", common.DefaultKeyspaceNamme), common.NewDispatcherID(), 1, getTableSpanByID(4), 10, common.DefaultMode, false) - msg := replicaSet.NewAddDispatcherMessage("node1") + msg := replicaSet.NewAddDispatcherMessage("node1", heartbeatpb.OperatorType_O_Add) require.Equal(t, "node1", msg.To.String()) req := msg.Message[0].(*heartbeatpb.ScheduleDispatcherRequest) require.Equal(t, heartbeatpb.ScheduleAction_Create, req.ScheduleAction) diff --git a/maintainer/scheduler/balance_splits.go b/maintainer/scheduler/balance_splits.go index d956f29123..0aedd450c7 100644 --- a/maintainer/scheduler/balance_splits.go +++ b/maintainer/scheduler/balance_splits.go @@ -18,6 +18,7 @@ import ( "time" "github.com/pingcap/log" + "github.com/pingcap/ticdc/heartbeatpb" "github.com/pingcap/ticdc/maintainer/operator" "github.com/pingcap/ticdc/maintainer/replica" "github.com/pingcap/ticdc/maintainer/span" @@ -118,7 +119,7 @@ func (s *balanceSplitsScheduler) Execute() time.Time { splitSpans := s.splitter.Split(context.Background(), checkResult.SplitSpan.Span, checkResult.SpanNum, checkResult.SpanType) if len(splitSpans) > 1 { op := operator.NewSplitDispatcherOperator(s.spanController, checkResult.SplitSpan, splitSpans, checkResult.SplitTargetNodes, func(span *replica.SpanReplication, node node.ID) bool { - return s.operatorController.AddOperator(operator.NewAddDispatcherOperator(s.spanController, span, node)) + return s.operatorController.AddOperator(operator.NewAddDispatcherOperator(s.spanController, span, node, heartbeatpb.OperatorType_O_Split)) }) ret := s.operatorController.AddOperator(op) if ret { diff --git a/maintainer/scheduler/basic.go b/maintainer/scheduler/basic.go index 094bb9aa9b..bd15109458 100644 --- a/maintainer/scheduler/basic.go +++ b/maintainer/scheduler/basic.go @@ -17,6 +17,7 @@ import ( "time" "github.com/pingcap/log" + "github.com/pingcap/ticdc/heartbeatpb" "github.com/pingcap/ticdc/maintainer/operator" "github.com/pingcap/ticdc/maintainer/replica" "github.com/pingcap/ticdc/maintainer/span" @@ -155,7 +156,7 @@ func (s *basicScheduler) schedule(groupID pkgreplica.GroupID, availableSize int) absentReplications := s.spanController.GetAbsentByGroup(groupID, availableSize) pkgScheduler.BasicSchedule(availableSize, absentReplications, nodeSize, func(replication *replica.SpanReplication, id node.ID) bool { - return s.operatorController.AddOperator(operator.NewAddDispatcherOperator(s.spanController, replication, id)) + return s.operatorController.AddOperator(operator.NewAddDispatcherOperator(s.spanController, replication, id, heartbeatpb.OperatorType_O_Add)) }) return len(absentReplications) } From 7288257a1298bf0cc0202993261427887a69980f Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 18 Dec 2025 15:18:02 +0800 Subject: [PATCH 02/25] fix a typo --- downstreamadapter/dispatcher/redo_dispatcher.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/downstreamadapter/dispatcher/redo_dispatcher.go b/downstreamadapter/dispatcher/redo_dispatcher.go index 184e15eec1..f4a1ef9d62 100644 --- a/downstreamadapter/dispatcher/redo_dispatcher.go +++ b/downstreamadapter/dispatcher/redo_dispatcher.go @@ -39,7 +39,7 @@ type RedoDispatcher struct { func NewRedoDispatcher( id common.DispatcherID, tableSpan *heartbeatpb.TableSpan, - endabledSplit bool, + enabledSplit bool, startTs uint64, schemaID int64, schemaIDToDispatchers *SchemaIDToDispatchers, @@ -50,7 +50,7 @@ func NewRedoDispatcher( basicDispatcher := NewBasicDispatcher( id, tableSpan, - endabledSplit, + enabledSplit, startTs, schemaID, schemaIDToDispatchers, From b9637e2371b4e394e36c9a6610ef933d14075b43 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 18 Dec 2025 15:19:48 +0800 Subject: [PATCH 03/25] fix a log typo --- .../dispatcherorchestrator/dispatcher_orchestrator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go b/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go index 99f1ea6c0f..2ed3a52196 100644 --- a/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go +++ b/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go @@ -408,7 +408,7 @@ func createBootstrapResponse( req := value.(*heartbeatpb.ScheduleDispatcherRequest) d, ok := manager.GetDispatcherMap().Get(common.NewDispatcherIDFromPB(req.Config.DispatcherID)) if !ok { - log.Error("Redo dispatcher not found, this should not happen", + log.Error("Dispatcher not found, this should not happen", zap.String("changefeed", changefeedID.String()), zap.String("dispatcherID", req.Config.DispatcherID.String()), ) From ce070cc07e612e8ad6ab41a1f0024b93bc9a57fc Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 18 Dec 2025 15:21:25 +0800 Subject: [PATCH 04/25] handle err for restoreCurrentWorkingOperators --- maintainer/maintainer_controller_bootstrap.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 8a1d541e6d..8f6294408e 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -109,7 +109,9 @@ func (c *Controller) FinishBootstrap( // Step 4: Process tables and build schema info // restore current working operators first - c.restoreCurrentWorkingOperators(allNodesResp) + if err := c.restoreCurrentWorkingOperators(allNodesResp); err != nil { + return nil, err + } schemaInfos := c.processTablesAndBuildSchemaInfo(tables, workingTaskMap, redoWorkingTaskMap, isMysqlCompatibleBackend) // Step 5: Handle any remaining working tasks (likely dropped tables) From b0929db24ffb8c950e664a6123578e00b2075e11 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 18 Dec 2025 15:23:29 +0800 Subject: [PATCH 05/25] modify a comment --- downstreamadapter/dispatchermanager/dispatcher_manager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager.go b/downstreamadapter/dispatchermanager/dispatcher_manager.go index ae0a78762d..98a03fe89f 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager.go @@ -85,8 +85,8 @@ type DispatcherManager struct { // redoDispatcherMap restore all the redo dispatchers in the DispatcherManager, including redo table trigger event dispatcher redoDispatcherMap *DispatcherMap[*dispatcher.RedoDispatcher] // currentOperatorMap stores the current operators for each dispatcher - currentOperatorMap sync.Map // map[span]*dispatcher.CurrentOperator - redoCurrentOperatorMap sync.Map // map[span]*dispatcher.CurrentOperator + currentOperatorMap sync.Map // map[span.String()]*dispatcher.CurrentOperator + redoCurrentOperatorMap sync.Map // map[span.string()]*dispatcher.CurrentOperator // schemaIDToDispatchers is shared in the DispatcherManager, // it store all the infos about schemaID->Dispatchers // Dispatchers may change the schemaID when meets some special events, such as rename ddl From 050e13f22e977f4711bf4a005eccb22955bcb21c Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 18 Dec 2025 16:45:11 +0800 Subject: [PATCH 06/25] resolve conflicts --- maintainer/operator/operator_add_test.go | 8 ++++---- maintainer/operator/operator_controller_test.go | 2 +- maintainer/operator/operator_remove_test.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/maintainer/operator/operator_add_test.go b/maintainer/operator/operator_add_test.go index 14d3e35ea0..6e8cc8ef7b 100644 --- a/maintainer/operator/operator_add_test.go +++ b/maintainer/operator/operator_add_test.go @@ -87,7 +87,7 @@ func TestAddOperator_DestReportsWorking(t *testing.T) { spanController, changefeedID, _, _, nodeB := setupTestEnvironment(t) absentReplicaSet := newAddTestReplicaSet(spanController, changefeedID) - op := NewAddDispatcherOperator(spanController, absentReplicaSet, nodeB) + op := NewAddDispatcherOperator(spanController, absentReplicaSet, nodeB, heartbeatpb.OperatorType_O_Add) require.NotNil(t, op) op.Start() @@ -119,7 +119,7 @@ func TestAddOperator_DestReportsRemoved(t *testing.T) { spanController, changefeedID, _, _, nodeB := setupTestEnvironment(t) absentReplicaSet := newAddTestReplicaSet(spanController, changefeedID) - op := NewAddDispatcherOperator(spanController, absentReplicaSet, nodeB) + op := NewAddDispatcherOperator(spanController, absentReplicaSet, nodeB, heartbeatpb.OperatorType_O_Add) require.NotNil(t, op) op.Start() @@ -149,7 +149,7 @@ func TestAddOperator_StoppedStatusIgnored(t *testing.T) { spanController, changefeedID, _, _, nodeB := setupTestEnvironment(t) absentReplicaSet := newAddTestReplicaSet(spanController, changefeedID) - op := NewAddDispatcherOperator(spanController, absentReplicaSet, nodeB) + op := NewAddDispatcherOperator(spanController, absentReplicaSet, nodeB, heartbeatpb.OperatorType_O_Add) require.NotNil(t, op) op.Start() @@ -176,7 +176,7 @@ func TestAddOperator_TaskRemovedDoesNotReintroduceSpan(t *testing.T) { spanController, changefeedID, _, _, nodeB := setupTestEnvironment(t) absentReplicaSet := newAddTestReplicaSet(spanController, changefeedID) - op := NewAddDispatcherOperator(spanController, absentReplicaSet, nodeB) + op := NewAddDispatcherOperator(spanController, absentReplicaSet, nodeB, heartbeatpb.OperatorType_O_Add) require.NotNil(t, op) op.Start() diff --git a/maintainer/operator/operator_controller_test.go b/maintainer/operator/operator_controller_test.go index 245e0d12e0..6cbea8d94e 100644 --- a/maintainer/operator/operator_controller_test.go +++ b/maintainer/operator/operator_controller_test.go @@ -128,7 +128,7 @@ func TestController_PostFinishCalledOnceOnReplace(t *testing.T) { }() <-op.isFinishedCalled - oc.removeReplicaSet(newRemoveDispatcherOperator(spanController, replicaSet)) + oc.removeReplicaSet(newRemoveDispatcherOperator(spanController, replicaSet, heartbeatpb.OperatorType_O_Remove)) wg.Wait() require.Equal(t, int32(1), op.postFinishCount.Load()) diff --git a/maintainer/operator/operator_remove_test.go b/maintainer/operator/operator_remove_test.go index 768e380fcf..8f681016d5 100644 --- a/maintainer/operator/operator_remove_test.go +++ b/maintainer/operator/operator_remove_test.go @@ -53,7 +53,7 @@ func TestRemoveOperator_SnapshotNodeIDAfterMarkAbsent(t *testing.T) { spanController, _, replicaSet, nodeA, _ := setupTestEnvironment(t) spanController.AddReplicatingSpan(replicaSet) - op := newRemoveDispatcherOperator(spanController, replicaSet) + op := newRemoveDispatcherOperator(spanController, replicaSet, heartbeatpb.OperatorType_O_Remove) require.NotNil(t, op) spanController.MarkSpanAbsent(replicaSet) @@ -75,7 +75,7 @@ func TestRemoveOperator_SnapshotNodeIDAfterMarkAbsent(t *testing.T) { func TestRemoveOperator_NotFinishedOnWaitingMerge(t *testing.T) { spanController, _, replicaSet, nodeA, _ := setupTestEnvironment(t) - op := newRemoveDispatcherOperator(spanController, replicaSet) + op := newRemoveDispatcherOperator(spanController, replicaSet, heartbeatpb.OperatorType_O_Remove) require.NotNil(t, op) waitingMergeStatus := &heartbeatpb.TableSpanStatus{ @@ -98,7 +98,7 @@ func TestRemoveOperator_NotFinishedOnWaitingMerge(t *testing.T) { func TestRemoveOperator_FinishedOnRemovedStatus(t *testing.T) { spanController, _, replicaSet, nodeA, _ := setupTestEnvironment(t) - op := newRemoveDispatcherOperator(spanController, replicaSet) + op := newRemoveDispatcherOperator(spanController, replicaSet, heartbeatpb.OperatorType_O_Remove) require.NotNil(t, op) removedStatus := &heartbeatpb.TableSpanStatus{ From a7be9496be931f344a1b754a5639c72ca3d083e4 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 18 Dec 2025 17:31:16 +0800 Subject: [PATCH 07/25] fix newRemoveDispatcherOperator node id --- maintainer/operator/operator_remove.go | 1 + 1 file changed, 1 insertion(+) diff --git a/maintainer/operator/operator_remove.go b/maintainer/operator/operator_remove.go index 023f42c7ca..76d4af480a 100644 --- a/maintainer/operator/operator_remove.go +++ b/maintainer/operator/operator_remove.go @@ -60,6 +60,7 @@ func NewRemoveDispatcherOperator( func newRemoveDispatcherOperator(spanController *span.Controller, replicaSet *replica.SpanReplication, operatorType heartbeatpb.OperatorType) *removeDispatcherOperator { return &removeDispatcherOperator{ replicaSet: replicaSet, + nodeID: replicaSet.GetNodeID(), spanController: spanController, operatorType: operatorType, sendThrottler: newSendThrottler(), From c9891d876d0154a3c5fac09c44f35a1d039eeb5d Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Fri, 19 Dec 2025 17:14:14 +0800 Subject: [PATCH 08/25] handle return value for AddOperator and add some logs for it --- maintainer/maintainer_controller_bootstrap.go | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 8f6294408e..3144ba124f 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -452,7 +452,17 @@ func (c *Controller) restoreCurrentWorkingOperators( switch req.OperatorType { case heartbeatpb.OperatorType_O_Add, heartbeatpb.OperatorType_O_Move, heartbeatpb.OperatorType_O_Split: op := operator.NewAddDispatcherOperator(spanController, replicaSet, node, heartbeatpb.OperatorType_O_Add) - c.operatorController.AddOperator(op) + if ok := c.operatorController.AddOperator(op); !ok { + log.Error("add operator failed when dealing current working operators in bootstrap, should not happen", + zap.String("nodeID", node.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", op.ID().String()), + zap.String("originOperatorType", req.OperatorType.String()), + zap.Any("operator", op), + zap.Any("replicaSet", replicaSet), + ) + return errors.ErrOperatorIsNil.GenWithStack("add operator failed when bootstrap") + } op.Start() } case heartbeatpb.ScheduleAction_Remove: @@ -464,7 +474,17 @@ func (c *Controller) restoreCurrentWorkingOperators( heartbeatpb.OperatorType_O_Remove, nil, ) - c.operatorController.AddOperator(op) + if ok := c.operatorController.AddOperator(op); !ok { + log.Error("add operator failed when dealing current working operators in bootstrap, should not happen", + zap.String("nodeID", node.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", op.ID().String()), + zap.String("originOperatorType", req.OperatorType.String()), + zap.Any("operator", op), + zap.Any("replicaSet", replicaSet), + ) + return errors.ErrOperatorIsNil.GenWithStack("add operator failed when bootstrap") + } op.Start() case heartbeatpb.OperatorType_O_Move, heartbeatpb.OperatorType_O_Split: op := operator.NewRemoveDispatcherOperator( @@ -475,7 +495,17 @@ func (c *Controller) restoreCurrentWorkingOperators( spanController.MarkAbsentWithoutLock(replicaSet) }, ) - c.operatorController.AddOperator(op) + if ok := c.operatorController.AddOperator(op); !ok { + log.Error("add operator failed when dealing current working operators in bootstrap, should not happen", + zap.String("nodeID", node.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", op.ID().String()), + zap.String("originOperatorType", req.OperatorType.String()), + zap.Any("operator", op), + zap.Any("replicaSet", replicaSet), + ) + return errors.ErrOperatorIsNil.GenWithStack("add operator failed when bootstrap") + } op.Start() } } From 8c4e099a17ee364f3d3d2835c59c6f69feea9ef8 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Fri, 19 Dec 2025 17:30:14 +0800 Subject: [PATCH 09/25] add some logs for dispatcher manager store current working operators --- .../dispatchermanager/dispatcher_manager.go | 5 ++ .../dispatcher_manager_redo.go | 5 ++ downstreamadapter/dispatchermanager/helper.go | 50 ++++++++++++++++++- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager.go b/downstreamadapter/dispatchermanager/dispatcher_manager.go index cf12c84c99..d47e7c8b15 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager.go @@ -921,6 +921,11 @@ func (e *DispatcherManager) cleanEventDispatcher(id common.DispatcherID, schemaI e.dispatcherMap.Delete(id) e.schemaIDToDispatchers.Delete(schemaID, id) e.currentOperatorMap.Delete(spanStr) + log.Debug("delete current working remove operator", + zap.String("changefeedID", e.changefeedID.String()), + zap.String("dispatcherID", id.String()), + zap.String("span", spanStr), + ) if e.tableTriggerEventDispatcher != nil && e.tableTriggerEventDispatcher.GetId() == id { e.tableTriggerEventDispatcher = nil e.metricTableTriggerEventDispatcherCount.Dec() diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go b/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go index 36ace77885..bdfeb2fa5b 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go @@ -221,6 +221,11 @@ func (e *DispatcherManager) cleanRedoDispatcher(id common.DispatcherID, schemaID e.redoDispatcherMap.Delete(id) e.redoSchemaIDToDispatchers.Delete(schemaID, id) e.redoCurrentOperatorMap.Delete(spanStr) + log.Debug("delete current working remove operator for redo dispatcher", + zap.String("changefeedID", e.changefeedID.String()), + zap.String("dispatcherID", id.String()), + zap.String("span", spanStr), + ) if e.redoTableTriggerEventDispatcher != nil && e.redoTableTriggerEventDispatcher.GetId() == id { e.redoTableTriggerEventDispatcher = nil e.metricRedoTableTriggerEventDispatcherCount.Dec() diff --git a/downstreamadapter/dispatchermanager/helper.go b/downstreamadapter/dispatchermanager/helper.go index d74aa8b087..1b53fb5922 100644 --- a/downstreamadapter/dispatchermanager/helper.go +++ b/downstreamadapter/dispatchermanager/helper.go @@ -218,9 +218,21 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher } if common.IsRedoMode(config.Mode) { dispatcherManager.redoCurrentOperatorMap.Store(req.Config.Span.String(), req) + log.Debug("store current working add operator for redo dispatcher", + zap.String("changefeedID", req.ChangefeedID.String()), + zap.String("dispatcherID", dispatcherID.String()), + zap.String("span", req.Config.Span.String()), + zap.Any("operator", req), + ) redoInfos[dispatcherID] = info } else { dispatcherManager.currentOperatorMap.Store(req.Config.Span.String(), req) + log.Debug("store current working add operator", + zap.String("changefeedID", req.ChangefeedID.String()), + zap.String("dispatcherID", dispatcherID.String()), + zap.String("span", req.Config.Span.String()), + zap.Any("operator", req), + ) infos[dispatcherID] = info } case heartbeatpb.ScheduleAction_Remove: @@ -229,9 +241,21 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher } if common.IsRedoMode(config.Mode) { dispatcherManager.redoCurrentOperatorMap.Store(req.Config.Span.String(), req) + log.Debug("store current working remove operator for redo dispatcher", + zap.String("changefeedID", req.ChangefeedID.String()), + zap.String("dispatcherID", dispatcherID.String()), + zap.String("span", req.Config.Span.String()), + zap.Any("operator", req), + ) removeDispatcher(dispatcherManager, dispatcherID, dispatcherManager.redoDispatcherMap, dispatcherManager.redoSink.SinkType()) } else { dispatcherManager.currentOperatorMap.Store(req.Config.Span.String(), req) + log.Debug("store current working remove operator", + zap.String("changefeedID", req.ChangefeedID.String()), + zap.String("dispatcherID", dispatcherID.String()), + zap.String("span", req.Config.Span.String()), + zap.Any("operator", req), + ) removeDispatcher(dispatcherManager, dispatcherID, dispatcherManager.dispatcherMap, dispatcherManager.sink.SinkType()) } } @@ -243,7 +267,18 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher dispatcherManager.handleError(context.Background(), err) } for _, info := range redoInfos { - dispatcherManager.redoCurrentOperatorMap.Delete(info.TableSpan.String()) + if v, ok := dispatcherManager.redoCurrentOperatorMap.Load(info.TableSpan.String()); ok { + req := v.(SchedulerDispatcherRequest) + log.Debug("delete current working add operator for redo dispatcher", + zap.String("changefeedID", dispatcherManager.changefeedID.String()), + zap.String("dispatcherID", info.Id.String()), + zap.String("span", info.TableSpan.String()), + zap.Any("operator", req), + ) + dispatcherManager.redoCurrentOperatorMap.Delete(info.TableSpan.String()) + } else { + log.Error("current working operator not found for redo dispatcher, should not happen", zap.String("span", info.TableSpan.String())) + } } } if len(infos) > 0 { @@ -252,7 +287,18 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher dispatcherManager.handleError(context.Background(), err) } for _, info := range infos { - dispatcherManager.currentOperatorMap.Delete(info.TableSpan.String()) + if v, ok := dispatcherManager.currentOperatorMap.Load(info.TableSpan.String()); ok { + req := v.(SchedulerDispatcherRequest) + log.Debug("delete current working add operator", + zap.String("changefeedID", dispatcherManager.changefeedID.String()), + zap.String("dispatcherID", info.Id.String()), + zap.String("span", info.TableSpan.String()), + zap.Any("operator", req), + ) + dispatcherManager.currentOperatorMap.Delete(info.TableSpan.String()) + } else { + log.Error("current working operator not found, should not happen", zap.String("span", info.TableSpan.String())) + } } } return false From 75638b287295b6d1319c418e771d8f0a165a9a8f Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Mon, 22 Dec 2025 17:29:58 +0800 Subject: [PATCH 10/25] fix remove operator nil span --- .../dispatchermanager/dispatcher_manager.go | 1 + .../dispatcher_manager_redo.go | 1 + downstreamadapter/dispatchermanager/helper.go | 42 ++++++++++++++----- maintainer/maintainer_controller.go | 2 +- maintainer/replica/replication_span.go | 5 ++- maintainer/replica/replication_span_test.go | 1 + 6 files changed, 39 insertions(+), 13 deletions(-) diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager.go b/downstreamadapter/dispatchermanager/dispatcher_manager.go index d47e7c8b15..f5eb5776ea 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager.go @@ -921,6 +921,7 @@ func (e *DispatcherManager) cleanEventDispatcher(id common.DispatcherID, schemaI e.dispatcherMap.Delete(id) e.schemaIDToDispatchers.Delete(schemaID, id) e.currentOperatorMap.Delete(spanStr) + e.currentOperatorMap.Delete(id.String()) log.Debug("delete current working remove operator", zap.String("changefeedID", e.changefeedID.String()), zap.String("dispatcherID", id.String()), diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go b/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go index bdfeb2fa5b..67668c5d71 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go @@ -221,6 +221,7 @@ func (e *DispatcherManager) cleanRedoDispatcher(id common.DispatcherID, schemaID e.redoDispatcherMap.Delete(id) e.redoSchemaIDToDispatchers.Delete(schemaID, id) e.redoCurrentOperatorMap.Delete(spanStr) + e.redoCurrentOperatorMap.Delete(id.String()) log.Debug("delete current working remove operator for redo dispatcher", zap.String("changefeedID", e.changefeedID.String()), zap.String("dispatcherID", id.String()), diff --git a/downstreamadapter/dispatchermanager/helper.go b/downstreamadapter/dispatchermanager/helper.go index 1b53fb5922..a94be74d02 100644 --- a/downstreamadapter/dispatchermanager/helper.go +++ b/downstreamadapter/dispatchermanager/helper.go @@ -173,6 +173,19 @@ func newSchedulerDispatcherRequestDynamicStream() dynstream.DynamicStream[int, c return ds } +func schedulerDispatcherKey(req *heartbeatpb.ScheduleDispatcherRequest) string { + if req == nil || req.Config == nil { + return "" + } + if req.Config.Span != nil { + return req.Config.Span.String() + } + if req.Config.DispatcherID != nil { + return common.NewDispatcherIDFromPB(req.Config.DispatcherID).String() + } + return "" +} + type SchedulerDispatcherRequest struct { *heartbeatpb.ScheduleDispatcherRequest } @@ -196,12 +209,21 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher log.Warn("scheduleDispatcherRequest is nil, skip") continue } + if req.Config == nil { + log.Warn("scheduleDispatcherRequest config is nil, skip") + continue + } + operatorKey := schedulerDispatcherKey(req.ScheduleDispatcherRequest) + if operatorKey == "" { + log.Warn("scheduleDispatcherRequest has no valid operator key, skip") + continue + } // If there is already an operator for the span, skip this request. - _, exists := dispatcherManager.currentOperatorMap.Load(req.Config.Span.String()) + _, exists := dispatcherManager.currentOperatorMap.Load(operatorKey) if exists { continue } - _, redoExists := dispatcherManager.redoCurrentOperatorMap.Load(req.Config.Span.String()) + _, redoExists := dispatcherManager.redoCurrentOperatorMap.Load(operatorKey) if redoExists { continue } @@ -217,20 +239,20 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher EnabledSplit: config.EnabledSplit, } if common.IsRedoMode(config.Mode) { - dispatcherManager.redoCurrentOperatorMap.Store(req.Config.Span.String(), req) + dispatcherManager.redoCurrentOperatorMap.Store(operatorKey, req) log.Debug("store current working add operator for redo dispatcher", zap.String("changefeedID", req.ChangefeedID.String()), zap.String("dispatcherID", dispatcherID.String()), - zap.String("span", req.Config.Span.String()), + zap.String("span", operatorKey), zap.Any("operator", req), ) redoInfos[dispatcherID] = info } else { - dispatcherManager.currentOperatorMap.Store(req.Config.Span.String(), req) + dispatcherManager.currentOperatorMap.Store(operatorKey, req) log.Debug("store current working add operator", zap.String("changefeedID", req.ChangefeedID.String()), zap.String("dispatcherID", dispatcherID.String()), - zap.String("span", req.Config.Span.String()), + zap.String("span", operatorKey), zap.Any("operator", req), ) infos[dispatcherID] = info @@ -240,20 +262,20 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher log.Error("invalid remove dispatcher request count in one batch", zap.Int("count", len(reqs))) } if common.IsRedoMode(config.Mode) { - dispatcherManager.redoCurrentOperatorMap.Store(req.Config.Span.String(), req) + dispatcherManager.redoCurrentOperatorMap.Store(operatorKey, req) log.Debug("store current working remove operator for redo dispatcher", zap.String("changefeedID", req.ChangefeedID.String()), zap.String("dispatcherID", dispatcherID.String()), - zap.String("span", req.Config.Span.String()), + zap.String("span", operatorKey), zap.Any("operator", req), ) removeDispatcher(dispatcherManager, dispatcherID, dispatcherManager.redoDispatcherMap, dispatcherManager.redoSink.SinkType()) } else { - dispatcherManager.currentOperatorMap.Store(req.Config.Span.String(), req) + dispatcherManager.currentOperatorMap.Store(operatorKey, req) log.Debug("store current working remove operator", zap.String("changefeedID", req.ChangefeedID.String()), zap.String("dispatcherID", dispatcherID.String()), - zap.String("span", req.Config.Span.String()), + zap.String("span", operatorKey), zap.Any("operator", req), ) removeDispatcher(dispatcherManager, dispatcherID, dispatcherManager.dispatcherMap, dispatcherManager.sink.SinkType()) diff --git a/maintainer/maintainer_controller.go b/maintainer/maintainer_controller.go index 045ed2d09c..5ac2f33291 100644 --- a/maintainer/maintainer_controller.go +++ b/maintainer/maintainer_controller.go @@ -157,7 +157,7 @@ func (c *Controller) HandleStatus(from node.ID, statusList []*heartbeatpb.TableS zap.Any("status", status), zap.String("dispatcherID", dispatcherID.String())) // if the span is not found, and the status is working, we need to remove it from dispatcher - _ = c.messageCenter.SendCommand(replica.NewRemoveDispatcherMessage(from, c.changefeedID, status.ID, status.Mode, heartbeatpb.OperatorType_O_Remove)) + _ = c.messageCenter.SendCommand(replica.NewRemoveDispatcherMessage(from, c.changefeedID, status.ID, nil, status.Mode, heartbeatpb.OperatorType_O_Remove)) } continue } diff --git a/maintainer/replica/replication_span.go b/maintainer/replica/replication_span.go index fa3f772e4a..d1d1827cd0 100644 --- a/maintainer/replica/replication_span.go +++ b/maintainer/replica/replication_span.go @@ -247,16 +247,17 @@ func (r *SpanReplication) NewAddDispatcherMessage(server node.ID, operatorType h } func (r *SpanReplication) NewRemoveDispatcherMessage(server node.ID, operatorType heartbeatpb.OperatorType) *messaging.TargetMessage { - return NewRemoveDispatcherMessage(server, r.ChangefeedID, r.ID.ToPB(), r.GetMode(), operatorType) + return NewRemoveDispatcherMessage(server, r.ChangefeedID, r.ID.ToPB(), r.Span, r.GetMode(), operatorType) } -func NewRemoveDispatcherMessage(server node.ID, cfID common.ChangeFeedID, dispatcherID *heartbeatpb.DispatcherID, mode int64, operatorType heartbeatpb.OperatorType) *messaging.TargetMessage { +func NewRemoveDispatcherMessage(server node.ID, cfID common.ChangeFeedID, dispatcherID *heartbeatpb.DispatcherID, span *heartbeatpb.TableSpan, mode int64, operatorType heartbeatpb.OperatorType) *messaging.TargetMessage { return messaging.NewSingleTargetMessage(server, messaging.HeartbeatCollectorTopic, &heartbeatpb.ScheduleDispatcherRequest{ ChangefeedID: cfID.ToPB(), Config: &heartbeatpb.DispatcherConfig{ DispatcherID: dispatcherID, + Span: span, Mode: mode, }, ScheduleAction: heartbeatpb.ScheduleAction_Remove, diff --git a/maintainer/replica/replication_span_test.go b/maintainer/replica/replication_span_test.go index 52e4a0c697..cf1a9566fa 100644 --- a/maintainer/replica/replication_span_test.go +++ b/maintainer/replica/replication_span_test.go @@ -39,6 +39,7 @@ func TestNewRemoveDispatcherMessage(t *testing.T) { req := msg.Message[0].(*heartbeatpb.ScheduleDispatcherRequest) require.Equal(t, heartbeatpb.ScheduleAction_Remove, req.ScheduleAction) require.Equal(t, replicaSet.ID.ToPB(), req.Config.DispatcherID) + require.Equal(t, replicaSet.Span, req.Config.Span) require.Equal(t, "node1", msg.To.String()) } From 26f5a83af82b7c99a54f6cd16fbc25acc1307885 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Mon, 22 Dec 2025 18:18:56 +0800 Subject: [PATCH 11/25] remove enabled split --- .../dispatcher/basic_dispatcher.go | 7 - .../dispatcher/event_dispatcher.go | 2 - .../dispatcher/event_dispatcher_test.go | 4 - .../dispatcher/redo_dispatcher.go | 2 - .../dispatcher/redo_dispatcher_test.go | 1 - .../dispatchermanager/dispatcher_manager.go | 4 +- .../dispatcher_manager_helper.go | 6 +- .../dispatcher_manager_info.go | 9 +- .../dispatcher_manager_redo.go | 4 +- .../dispatcher_manager_test.go | 1 - downstreamadapter/dispatchermanager/helper.go | 9 +- .../dispatcher_orchestrator.go | 6 +- heartbeatpb/heartbeat.pb.go | 320 ++++++++---------- heartbeatpb/heartbeat.proto | 1 - maintainer/maintainer_controller_bootstrap.go | 5 +- maintainer/replica/replication_span.go | 1 - 16 files changed, 156 insertions(+), 226 deletions(-) diff --git a/downstreamadapter/dispatcher/basic_dispatcher.go b/downstreamadapter/dispatcher/basic_dispatcher.go index aea7de44ab..a1be958058 100644 --- a/downstreamadapter/dispatcher/basic_dispatcher.go +++ b/downstreamadapter/dispatcher/basic_dispatcher.go @@ -120,7 +120,6 @@ type BasicDispatcher struct { // or just a part of the table (span). When true, the dispatcher handles the entire table; // when false, it only handles a portion of the table. isCompleteTable bool - enabledSplit bool // startTs is the timestamp that the dispatcher need to receive and flush events. startTs uint64 @@ -196,7 +195,6 @@ type BasicDispatcher struct { func NewBasicDispatcher( id common.DispatcherID, tableSpan *heartbeatpb.TableSpan, - enabledSplit bool, startTs uint64, schemaID int64, schemaIDToDispatchers *SchemaIDToDispatchers, @@ -210,7 +208,6 @@ func NewBasicDispatcher( dispatcher := &BasicDispatcher{ id: id, tableSpan: tableSpan, - enabledSplit: enabledSplit, isCompleteTable: common.IsCompleteSpan(tableSpan), startTs: startTs, skipSyncpointAtStartTs: skipSyncpointAtStartTs, @@ -913,7 +910,3 @@ func (d *BasicDispatcher) removeDispatcher() { zap.Stringer("dispatcherID", d.id)) } } - -func (d *BasicDispatcher) IsEnabledSplit() bool { - return d.enabledSplit -} diff --git a/downstreamadapter/dispatcher/event_dispatcher.go b/downstreamadapter/dispatcher/event_dispatcher.go index b74272c14c..65464b919b 100644 --- a/downstreamadapter/dispatcher/event_dispatcher.go +++ b/downstreamadapter/dispatcher/event_dispatcher.go @@ -54,7 +54,6 @@ type EventDispatcher struct { func NewEventDispatcher( id common.DispatcherID, tableSpan *heartbeatpb.TableSpan, - enabledSplit bool, startTs uint64, schemaID int64, schemaIDToDispatchers *SchemaIDToDispatchers, @@ -69,7 +68,6 @@ func NewEventDispatcher( basicDispatcher := NewBasicDispatcher( id, tableSpan, - enabledSplit, startTs, schemaID, schemaIDToDispatchers, diff --git a/downstreamadapter/dispatcher/event_dispatcher_test.go b/downstreamadapter/dispatcher/event_dispatcher_test.go index 540b8318db..31dacf0cfa 100644 --- a/downstreamadapter/dispatcher/event_dispatcher_test.go +++ b/downstreamadapter/dispatcher/event_dispatcher_test.go @@ -87,7 +87,6 @@ func newDispatcherForTest(sink sink.Sink, tableSpan *heartbeatpb.TableSpan) *Eve return NewEventDispatcher( common.NewDispatcherID(), tableSpan, - false, common.Ts(0), // startTs 1, // schemaID NewSchemaIDToDispatchers(), @@ -830,7 +829,6 @@ func TestDispatcherSplittableCheck(t *testing.T) { dispatcher := NewEventDispatcher( common.NewDispatcherID(), tableSpan, - false, common.Ts(0), // startTs 1, // schemaID NewSchemaIDToDispatchers(), @@ -937,7 +935,6 @@ func TestDispatcher_SkipDMLAsStartTs_FilterCorrectly(t *testing.T) { dispatcher := NewEventDispatcher( common.NewDispatcherID(), tableSpan, - false, common.Ts(99), // startTs = 99 (ddlTs - 1) 1, // schemaID NewSchemaIDToDispatchers(), @@ -1017,7 +1014,6 @@ func TestDispatcher_SkipDMLAsStartTs_Disabled(t *testing.T) { dispatcher := NewEventDispatcher( common.NewDispatcherID(), tableSpan, - false, common.Ts(99), // startTs = 99 1, NewSchemaIDToDispatchers(), diff --git a/downstreamadapter/dispatcher/redo_dispatcher.go b/downstreamadapter/dispatcher/redo_dispatcher.go index 4bba6476ab..d80d78c954 100644 --- a/downstreamadapter/dispatcher/redo_dispatcher.go +++ b/downstreamadapter/dispatcher/redo_dispatcher.go @@ -40,7 +40,6 @@ type RedoDispatcher struct { func NewRedoDispatcher( id common.DispatcherID, tableSpan *heartbeatpb.TableSpan, - enabledSplit bool, startTs uint64, schemaID int64, schemaIDToDispatchers *SchemaIDToDispatchers, @@ -51,7 +50,6 @@ func NewRedoDispatcher( basicDispatcher := NewBasicDispatcher( id, tableSpan, - enabledSplit, startTs, schemaID, schemaIDToDispatchers, diff --git a/downstreamadapter/dispatcher/redo_dispatcher_test.go b/downstreamadapter/dispatcher/redo_dispatcher_test.go index 9855e96a3a..ea240bf750 100644 --- a/downstreamadapter/dispatcher/redo_dispatcher_test.go +++ b/downstreamadapter/dispatcher/redo_dispatcher_test.go @@ -53,7 +53,6 @@ func newRedoDispatcherForTest(sink sink.Sink, tableSpan *heartbeatpb.TableSpan) return NewRedoDispatcher( common.NewDispatcherID(), tableSpan, - false, common.Ts(0), // startTs 1, // schemaID NewSchemaIDToDispatchers(), diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager.go b/downstreamadapter/dispatchermanager/dispatcher_manager.go index c1cdd70052..f907b68d5c 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager.go @@ -392,7 +392,7 @@ func (e *DispatcherManager) newEventDispatchers(infos map[common.DispatcherID]di start := time.Now() currentPdTs := e.pdClock.CurrentTS() - dispatcherIds, tableIds, startTsList, tableSpans, schemaIds, enabledSplits := prepareCreateDispatcher(infos, e.dispatcherMap) + dispatcherIds, tableIds, startTsList, tableSpans, schemaIds := prepareCreateDispatcher(infos, e.dispatcherMap) if len(dispatcherIds) == 0 { return nil } @@ -431,7 +431,6 @@ func (e *DispatcherManager) newEventDispatchers(infos map[common.DispatcherID]di d := dispatcher.NewEventDispatcher( id, tableSpans[idx], - enabledSplits[idx], uint64(newStartTsList[idx]), schemaIds[idx], e.schemaIDToDispatchers, @@ -821,7 +820,6 @@ func (e *DispatcherManager) mergeEventDispatcher(dispatcherIDs []common.Dispatch mergedDispatcher := dispatcher.NewEventDispatcher( mergedDispatcherID, mergedSpan, - true, // enabledSplit fakeStartTs, // real startTs will be calculated later. schemaID, e.schemaIDToDispatchers, diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_helper.go b/downstreamadapter/dispatchermanager/dispatcher_manager_helper.go index 089dd06dcd..8a37141d88 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_helper.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_helper.go @@ -72,14 +72,13 @@ func getDispatcherStatus(id common.DispatcherID, dispatcherItem dispatcher.Dispa } func prepareCreateDispatcher[T dispatcher.Dispatcher](infos map[common.DispatcherID]dispatcherCreateInfo, dispatcherMap *DispatcherMap[T]) ( - []common.DispatcherID, []int64, []int64, []*heartbeatpb.TableSpan, []int64, []bool, + []common.DispatcherID, []int64, []int64, []*heartbeatpb.TableSpan, []int64, ) { dispatcherIds := make([]common.DispatcherID, 0, len(infos)) tableIds := make([]int64, 0, len(infos)) startTsList := make([]int64, 0, len(infos)) tableSpans := make([]*heartbeatpb.TableSpan, 0, len(infos)) schemaIds := make([]int64, 0, len(infos)) - enabledSplits := make([]bool, 0, len(infos)) for _, info := range infos { id := info.Id if _, ok := dispatcherMap.Get(id); ok { @@ -90,9 +89,8 @@ func prepareCreateDispatcher[T dispatcher.Dispatcher](infos map[common.Dispatche startTsList = append(startTsList, int64(info.StartTs)) tableSpans = append(tableSpans, info.TableSpan) schemaIds = append(schemaIds, info.SchemaID) - enabledSplits = append(enabledSplits, info.EnabledSplit) } - return dispatcherIds, tableIds, startTsList, tableSpans, schemaIds, enabledSplits + return dispatcherIds, tableIds, startTsList, tableSpans, schemaIds } func prepareMergeDispatcher[T dispatcher.Dispatcher](changefeedID common.ChangeFeedID, diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_info.go b/downstreamadapter/dispatchermanager/dispatcher_manager_info.go index aea79d5031..a1c6aa73ae 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_info.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_info.go @@ -25,11 +25,10 @@ import ( // event_dispatcher_mananger_info.go is used to store the basic info and function of the event dispatcher manager type dispatcherCreateInfo struct { - Id common.DispatcherID - TableSpan *heartbeatpb.TableSpan - StartTs uint64 - SchemaID int64 - EnabledSplit bool + Id common.DispatcherID + TableSpan *heartbeatpb.TableSpan + StartTs uint64 + SchemaID int64 } type cleanMap struct { diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go b/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go index d1121f14f7..253a556725 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_redo.go @@ -118,7 +118,7 @@ func (e *DispatcherManager) NewRedoTableTriggerEventDispatcher(id *heartbeatpb.D func (e *DispatcherManager) newRedoDispatchers(infos map[common.DispatcherID]dispatcherCreateInfo, removeDDLTs bool) error { start := time.Now() - dispatcherIds, tableIds, startTsList, tableSpans, schemaIds, enabledSplits := prepareCreateDispatcher(infos, e.redoDispatcherMap) + dispatcherIds, tableIds, startTsList, tableSpans, schemaIds := prepareCreateDispatcher(infos, e.redoDispatcherMap) if len(dispatcherIds) == 0 { return nil } @@ -154,7 +154,6 @@ func (e *DispatcherManager) newRedoDispatchers(infos map[common.DispatcherID]dis rd := dispatcher.NewRedoDispatcher( id, tableSpans[idx], - enabledSplits[idx], uint64(newStartTsList[idx]), schemaIds[idx], e.redoSchemaIDToDispatchers, @@ -217,7 +216,6 @@ func (e *DispatcherManager) mergeRedoDispatcher(dispatcherIDs []common.Dispatche mergedDispatcher := dispatcher.NewRedoDispatcher( mergedDispatcherID, mergedSpan, - true, fakeStartTs, // real startTs will be calculated later. schemaID, e.redoSchemaIDToDispatchers, diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go index e62b7df5b9..243f0e4a37 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go @@ -64,7 +64,6 @@ func createTestDispatcher(t *testing.T, manager *DispatcherManager, id common.Di d := dispatcher.NewEventDispatcher( id, span, - false, 0, 0, dispatcher.NewSchemaIDToDispatchers(), diff --git a/downstreamadapter/dispatchermanager/helper.go b/downstreamadapter/dispatchermanager/helper.go index 90eb857c6a..412558b3af 100644 --- a/downstreamadapter/dispatchermanager/helper.go +++ b/downstreamadapter/dispatchermanager/helper.go @@ -232,11 +232,10 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher switch req.ScheduleAction { case heartbeatpb.ScheduleAction_Create: info := dispatcherCreateInfo{ - Id: dispatcherID, - TableSpan: config.Span, - StartTs: config.StartTs, - SchemaID: config.SchemaID, - EnabledSplit: config.EnabledSplit, + Id: dispatcherID, + TableSpan: config.Span, + StartTs: config.StartTs, + SchemaID: config.SchemaID, } if common.IsRedoMode(config.Mode) { dispatcherManager.redoCurrentOperatorMap.Store(operatorKey, req) diff --git a/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go b/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go index 687fac9f27..9507a494f8 100644 --- a/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go +++ b/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go @@ -375,14 +375,13 @@ func createBootstrapResponse( }) manager.GetRedoCurrentOperatorMap().Range(func(key, value any) bool { req := value.(*heartbeatpb.ScheduleDispatcherRequest) - d, ok := manager.GetRedoDispatcherMap().Get(common.NewDispatcherIDFromPB(req.Config.DispatcherID)) + _, ok := manager.GetRedoDispatcherMap().Get(common.NewDispatcherIDFromPB(req.Config.DispatcherID)) if !ok { log.Error("Redo dispatcher not found, this should not happen", zap.String("changefeed", changefeedID.String()), zap.String("dispatcherID", req.Config.DispatcherID.String()), ) } - req.Config.EnabledSplit = d.IsEnabledSplit() response.Operators = append(response.Operators, &heartbeatpb.ScheduleDispatcherRequest{ ChangefeedID: req.ChangefeedID, @@ -406,14 +405,13 @@ func createBootstrapResponse( }) manager.GetCurrentOperatorMap().Range(func(key, value any) bool { req := value.(*heartbeatpb.ScheduleDispatcherRequest) - d, ok := manager.GetDispatcherMap().Get(common.NewDispatcherIDFromPB(req.Config.DispatcherID)) + _, ok := manager.GetDispatcherMap().Get(common.NewDispatcherIDFromPB(req.Config.DispatcherID)) if !ok { log.Error("Dispatcher not found, this should not happen", zap.String("changefeed", changefeedID.String()), zap.String("dispatcherID", req.Config.DispatcherID.String()), ) } - req.Config.EnabledSplit = d.IsEnabledSplit() response.Operators = append(response.Operators, &heartbeatpb.ScheduleDispatcherRequest{ ChangefeedID: req.ChangefeedID, Config: req.Config, diff --git a/heartbeatpb/heartbeat.pb.go b/heartbeatpb/heartbeat.pb.go index c1201fa689..a5bb71149f 100644 --- a/heartbeatpb/heartbeat.pb.go +++ b/heartbeatpb/heartbeat.pb.go @@ -957,7 +957,6 @@ type DispatcherConfig struct { DispatcherID *DispatcherID `protobuf:"bytes,3,opt,name=dispatcherID,proto3" json:"dispatcherID,omitempty"` SchemaID int64 `protobuf:"varint,4,opt,name=schemaID,proto3" json:"schemaID,omitempty"` Mode int64 `protobuf:"varint,5,opt,name=mode,proto3" json:"mode,omitempty"` - EnabledSplit bool `protobuf:"varint,6,opt,name=enabledSplit,proto3" json:"enabledSplit,omitempty"` } func (m *DispatcherConfig) Reset() { *m = DispatcherConfig{} } @@ -1028,13 +1027,6 @@ func (m *DispatcherConfig) GetMode() int64 { return 0 } -func (m *DispatcherConfig) GetEnabledSplit() bool { - if m != nil { - return m.EnabledSplit - } - return false -} - type ScheduleDispatcherRequest struct { ChangefeedID *ChangefeedID `protobuf:"bytes,1,opt,name=changefeedID,proto3" json:"changefeedID,omitempty"` Config *DispatcherConfig `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` @@ -2960,146 +2952,145 @@ func init() { func init() { proto.RegisterFile("heartbeatpb/heartbeat.proto", fileDescriptor_6d584080fdadb670) } var fileDescriptor_6d584080fdadb670 = []byte{ - // 2213 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x59, 0x4b, 0x6c, 0x1c, 0x49, - 0x19, 0x76, 0x77, 0xcf, 0xf3, 0x1f, 0x8f, 0xdd, 0xa9, 0x6c, 0x9c, 0x49, 0xfc, 0x88, 0xd3, 0xc0, - 0xca, 0x78, 0xc1, 0x51, 0xbc, 0x1b, 0xf1, 0xd0, 0x42, 0xb0, 0x67, 0xb2, 0xbb, 0x23, 0xe3, 0x87, - 0xca, 0x46, 0xe1, 0x71, 0x18, 0xda, 0xdd, 0x95, 0x71, 0xcb, 0x33, 0xdd, 0x9d, 0xae, 0x76, 0x1c, - 0x47, 0x5a, 0x10, 0x42, 0xdc, 0x38, 0x70, 0x80, 0x03, 0x47, 0xce, 0x48, 0x88, 0x0b, 0x47, 0x24, - 0x6e, 0x20, 0x71, 0xc9, 0x09, 0x71, 0x44, 0xc9, 0x91, 0x0b, 0xe2, 0xc2, 0x15, 0x55, 0x75, 0x55, - 0xbf, 0xa6, 0xc7, 0x0f, 0x79, 0x94, 0x5b, 0x57, 0xd5, 0xf7, 0xff, 0xf5, 0xd7, 0xff, 0xff, 0xf5, - 0x3f, 0xaa, 0x61, 0xfe, 0x88, 0x98, 0x41, 0x78, 0x48, 0xcc, 0xd0, 0x3f, 0x7c, 0x10, 0x7f, 0xaf, - 0xf9, 0x81, 0x17, 0x7a, 0xa8, 0x91, 0x5a, 0x34, 0xce, 0xa0, 0x7e, 0x60, 0x1e, 0x0e, 0xc8, 0xbe, - 0x6f, 0xba, 0xa8, 0x05, 0x55, 0x3e, 0xe8, 0x76, 0x5a, 0xca, 0xb2, 0xb2, 0xa2, 0x61, 0x39, 0x44, - 0x77, 0xa1, 0xb6, 0x1f, 0x9a, 0x41, 0xb8, 0x45, 0xce, 0x5a, 0xea, 0xb2, 0xb2, 0x32, 0x8d, 0xe3, - 0x31, 0x9a, 0x83, 0xca, 0x13, 0xd7, 0x66, 0x2b, 0x1a, 0x5f, 0x11, 0x23, 0xb4, 0x04, 0xb0, 0x45, - 0xce, 0xa8, 0x6f, 0x5a, 0x8c, 0x61, 0x69, 0x59, 0x59, 0x69, 0xe2, 0xd4, 0x8c, 0xf1, 0x0f, 0x15, - 0xf4, 0xcf, 0x98, 0x28, 0x9b, 0xc4, 0x0c, 0x31, 0x79, 0x7e, 0x42, 0x68, 0x88, 0xbe, 0x05, 0xd3, - 0xd6, 0x91, 0xe9, 0xf6, 0xc9, 0x33, 0x42, 0x6c, 0x21, 0x47, 0x63, 0xfd, 0xce, 0x5a, 0x4a, 0xe6, - 0xb5, 0x76, 0x0a, 0x80, 0x33, 0x70, 0xf4, 0x11, 0xd4, 0x4f, 0xcd, 0x90, 0x04, 0x43, 0x33, 0x38, - 0xe6, 0x82, 0x36, 0xd6, 0xe7, 0x32, 0xb4, 0x4f, 0xe5, 0x2a, 0x4e, 0x80, 0xe8, 0x63, 0x68, 0x06, - 0xc4, 0xf6, 0xe2, 0x35, 0x7e, 0x90, 0xf1, 0x94, 0x59, 0x30, 0xfa, 0x3a, 0xd4, 0x68, 0x68, 0x86, - 0x27, 0x94, 0xd0, 0x56, 0x69, 0x59, 0x5b, 0x69, 0xac, 0x2f, 0x64, 0x08, 0x63, 0xfd, 0xee, 0x73, - 0x14, 0x8e, 0xd1, 0x68, 0x05, 0x66, 0x2d, 0x6f, 0xe8, 0x93, 0x01, 0x09, 0x49, 0xb4, 0xd8, 0x2a, - 0x2f, 0x2b, 0x2b, 0x35, 0x9c, 0x9f, 0x46, 0x1f, 0x80, 0x46, 0x82, 0xa0, 0x55, 0x29, 0xd0, 0x06, - 0x3e, 0x71, 0x5d, 0xc7, 0xed, 0x3f, 0x09, 0x02, 0x2f, 0xc0, 0x0c, 0x65, 0xfc, 0x42, 0x81, 0x7a, - 0x22, 0x9e, 0xc1, 0x34, 0x4a, 0xac, 0x63, 0xdf, 0x73, 0xdc, 0xf0, 0x80, 0x72, 0x8d, 0x96, 0x70, - 0x66, 0x8e, 0x99, 0x2a, 0x20, 0xd4, 0x1b, 0xbc, 0x20, 0xf6, 0x01, 0xe5, 0x7a, 0x2b, 0xe1, 0xd4, - 0x0c, 0xd2, 0x41, 0xa3, 0xe4, 0x39, 0x57, 0x4b, 0x09, 0xb3, 0x4f, 0xc6, 0x75, 0x60,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x19, 0x94, 0x4a, 0x51, 0x50, - 0x92, 0xe3, 0xd8, 0xb3, 0xcb, 0x89, 0x67, 0x33, 0x63, 0x13, 0x97, 0x09, 0x67, 0xef, 0xfb, 0x03, - 0x27, 0xe4, 0x39, 0xae, 0x86, 0x33, 0x73, 0xc6, 0x6f, 0x54, 0xb8, 0xc3, 0x22, 0x9b, 0x7d, 0x32, - 0x48, 0x05, 0xa6, 0x09, 0xd5, 0x0c, 0x8f, 0xa0, 0x62, 0x71, 0xfd, 0x5d, 0x10, 0x6d, 0x22, 0x25, - 0x63, 0x01, 0x46, 0x6d, 0x98, 0xa1, 0x42, 0xa4, 0x28, 0x0e, 0x71, 0x45, 0xcd, 0xac, 0xcf, 0x67, - 0xc8, 0xf7, 0x33, 0x10, 0x9c, 0x23, 0x61, 0xa2, 0x7b, 0x3e, 0x09, 0xcc, 0xd0, 0x0b, 0x78, 0x0e, - 0x29, 0x71, 0x16, 0x59, 0xd1, 0x77, 0x53, 0x00, 0x9c, 0x81, 0x1b, 0xff, 0x53, 0x60, 0x6e, 0x9b, - 0x04, 0xfd, 0xc9, 0x2b, 0xe5, 0x31, 0x34, 0xed, 0x2b, 0xe6, 0xa6, 0x0c, 0x1e, 0x75, 0x01, 0x0d, - 0x99, 0x64, 0x76, 0xe7, 0x4a, 0xbe, 0x54, 0x40, 0x14, 0x7b, 0x4d, 0x29, 0x15, 0x0f, 0xf7, 0xe0, - 0xe6, 0xb6, 0xe9, 0xb8, 0xa1, 0xe9, 0xb8, 0x24, 0xf8, 0x4c, 0x72, 0x43, 0xdf, 0x48, 0xd5, 0x62, - 0x4a, 0x41, 0xfc, 0x4d, 0x68, 0xf2, 0xc5, 0x98, 0xf1, 0x17, 0x15, 0xf4, 0xfc, 0xf2, 0x75, 0xb5, - 0xb8, 0x08, 0xc0, 0xbe, 0x7a, 0x6c, 0x13, 0xc2, 0xdd, 0xab, 0x8e, 0xeb, 0x6c, 0x86, 0xb1, 0x27, - 0xe8, 0x21, 0x94, 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2, 0x07, 0x38, 0x1a, 0xa8, 0x0c, 0xd3, 0x61, 0x18, 0x6d, 0xf5, 0x2b, - 0xb9, 0x6c, 0x8e, 0xaa, 0xa0, 0x6d, 0x0c, 0x06, 0xfa, 0x14, 0xaa, 0x80, 0xda, 0xd9, 0x8c, 0x64, - 0xd8, 0xf1, 0x82, 0xa1, 0x39, 0xd0, 0xd5, 0xd5, 0x57, 0x30, 0x93, 0x8d, 0x15, 0x9c, 0xad, 0x17, - 0x1c, 0x3b, 0x6e, 0x3f, 0xda, 0x70, 0x3f, 0xe4, 0x49, 0x21, 0xda, 0x30, 0x3a, 0x87, 0xad, 0xab, - 0x48, 0x87, 0xe9, 0xae, 0xeb, 0x84, 0x8e, 0x39, 0x70, 0x5e, 0x31, 0xac, 0x86, 0x9a, 0x50, 0xdf, - 0x0b, 0x88, 0x6f, 0x06, 0x6c, 0x58, 0x42, 0x33, 0x00, 0xfc, 0x38, 0x98, 0x98, 0xf6, 0x99, 0x5e, - 0x66, 0x04, 0x4f, 0x4d, 0x27, 0x74, 0xdc, 0x7e, 0x74, 0xca, 0xca, 0xe6, 0xb7, 0xff, 0xf6, 0x66, - 0x49, 0x79, 0xfd, 0x66, 0x49, 0xf9, 0xd7, 0x9b, 0x25, 0xe5, 0x57, 0x6f, 0x97, 0xa6, 0x5e, 0xbf, - 0x5d, 0x9a, 0xfa, 0xe7, 0xdb, 0xa5, 0xa9, 0x1f, 0x7e, 0xb1, 0xef, 0x84, 0x47, 0x27, 0x87, 0x6b, - 0x96, 0x37, 0x7c, 0xe0, 0x3b, 0x6e, 0xdf, 0x32, 0xfd, 0x07, 0xa1, 0x63, 0xd9, 0xd6, 0x83, 0x94, - 0xe1, 0x0f, 0x2b, 0xfc, 0xff, 0xf6, 0x87, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xdf, 0x07, - 0xa1, 0xfe, 0x1e, 0x00, 0x00, + // 2199 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x59, 0x4b, 0x6f, 0xdc, 0xc8, + 0x11, 0x16, 0xc9, 0x79, 0xd6, 0x68, 0x24, 0xba, 0xbd, 0x96, 0xc7, 0xd6, 0xc3, 0x32, 0x93, 0x2c, + 0x14, 0x6d, 0x22, 0xc3, 0xda, 0x35, 0xf2, 0xc0, 0x26, 0x8e, 0x34, 0xe3, 0xdd, 0x1d, 0x28, 0x7a, + 0xa0, 0xa5, 0xc0, 0x79, 0x1c, 0x26, 0x14, 0xd9, 0x1e, 0x11, 0x9a, 0x21, 0x69, 0x36, 0x65, 0x59, + 0x06, 0x36, 0x41, 0x10, 0xe4, 0x96, 0x43, 0x0e, 0xc9, 0x21, 0xc7, 0x9c, 0x03, 0x04, 0xb9, 0xe4, + 0x18, 0x20, 0xb7, 0x04, 0xc8, 0xc5, 0xa7, 0x20, 0xc7, 0xc0, 0xfe, 0x03, 0x41, 0x2e, 0xb9, 0x2e, + 0xba, 0xc9, 0x26, 0x9b, 0x1c, 0x8e, 0x1e, 0xd0, 0xc0, 0x37, 0x76, 0x77, 0x55, 0x75, 0x75, 0x55, + 0xf5, 0x57, 0xd5, 0x45, 0x98, 0x3f, 0x22, 0x66, 0x10, 0x1e, 0x12, 0x33, 0xf4, 0x0f, 0x1f, 0x24, + 0xdf, 0x6b, 0x7e, 0xe0, 0x85, 0x1e, 0x6a, 0x48, 0x8b, 0xc6, 0x19, 0xd4, 0x0f, 0xcc, 0xc3, 0x01, + 0xd9, 0xf7, 0x4d, 0x17, 0xb5, 0xa0, 0xca, 0x07, 0xdd, 0x4e, 0x4b, 0x59, 0x56, 0x56, 0x34, 0x2c, + 0x86, 0xe8, 0x2e, 0xd4, 0xf6, 0x43, 0x33, 0x08, 0xb7, 0xc8, 0x59, 0x4b, 0x5d, 0x56, 0x56, 0xa6, + 0x71, 0x32, 0x46, 0x73, 0x50, 0x79, 0xe2, 0xda, 0x6c, 0x45, 0xe3, 0x2b, 0xf1, 0x08, 0x2d, 0x01, + 0x6c, 0x91, 0x33, 0xea, 0x9b, 0x16, 0x13, 0x58, 0x5a, 0x56, 0x56, 0x9a, 0x58, 0x9a, 0x31, 0xfe, + 0xa5, 0x82, 0xfe, 0x19, 0x53, 0x65, 0x93, 0x98, 0x21, 0x26, 0xcf, 0x4f, 0x08, 0x0d, 0xd1, 0x77, + 0x60, 0xda, 0x3a, 0x32, 0xdd, 0x3e, 0x79, 0x46, 0x88, 0x1d, 0xeb, 0xd1, 0x58, 0xbf, 0xb3, 0x26, + 0xe9, 0xbc, 0xd6, 0x96, 0x08, 0x70, 0x86, 0x1c, 0x7d, 0x04, 0xf5, 0x53, 0x33, 0x24, 0xc1, 0xd0, + 0x0c, 0x8e, 0xb9, 0xa2, 0x8d, 0xf5, 0xb9, 0x0c, 0xef, 0x53, 0xb1, 0x8a, 0x53, 0x42, 0xf4, 0x31, + 0x34, 0x03, 0x62, 0x7b, 0xc9, 0x1a, 0x3f, 0xc8, 0x78, 0xce, 0x2c, 0x31, 0xfa, 0x26, 0xd4, 0x68, + 0x68, 0x86, 0x27, 0x94, 0xd0, 0x56, 0x69, 0x59, 0x5b, 0x69, 0xac, 0x2f, 0x64, 0x18, 0x13, 0xfb, + 0xee, 0x73, 0x2a, 0x9c, 0x50, 0xa3, 0x15, 0x98, 0xb5, 0xbc, 0xa1, 0x4f, 0x06, 0x24, 0x24, 0xd1, + 0x62, 0xab, 0xbc, 0xac, 0xac, 0xd4, 0x70, 0x7e, 0x1a, 0x7d, 0x00, 0x1a, 0x09, 0x82, 0x56, 0xa5, + 0xc0, 0x1a, 0xf8, 0xc4, 0x75, 0x1d, 0xb7, 0xff, 0x24, 0x08, 0xbc, 0x00, 0x33, 0x2a, 0xe3, 0x57, + 0x0a, 0xd4, 0x53, 0xf5, 0x0c, 0x66, 0x51, 0x62, 0x1d, 0xfb, 0x9e, 0xe3, 0x86, 0x07, 0x94, 0x5b, + 0xb4, 0x84, 0x33, 0x73, 0xcc, 0x55, 0x01, 0xa1, 0xde, 0xe0, 0x05, 0xb1, 0x0f, 0x28, 0xb7, 0x5b, + 0x09, 0x4b, 0x33, 0x48, 0x07, 0x8d, 0x92, 0xe7, 0xdc, 0x2c, 0x25, 0xcc, 0x3e, 0x99, 0xd4, 0x81, + 0x49, 0xc3, 0xfd, 0x33, 0xd7, 0xe2, 0x3c, 0xa5, 0x48, 0xaa, 0x3c, 0x67, 0x7c, 0x0e, 0x7a, 0xc7, + 0xa1, 0xbe, 0x19, 0x5a, 0x47, 0x24, 0xd8, 0xb0, 0x42, 0xc7, 0x73, 0xd1, 0x07, 0x50, 0x31, 0xf9, + 0x17, 0xd7, 0x63, 0x66, 0xfd, 0x66, 0xe6, 0x2c, 0x11, 0x11, 0x8e, 0x49, 0x58, 0xd4, 0xb5, 0xbd, + 0xe1, 0xd0, 0x09, 0x13, 0xa5, 0x92, 0x31, 0x5a, 0x86, 0x46, 0x97, 0xb2, 0xad, 0xf6, 0xd8, 0x19, + 0xb8, 0x6a, 0x35, 0x2c, 0x4f, 0x19, 0x6d, 0xd0, 0x36, 0xda, 0x5b, 0x19, 0x21, 0xca, 0xf9, 0x42, + 0xd4, 0x51, 0x21, 0xbf, 0x54, 0xe1, 0x56, 0xd7, 0x7d, 0x36, 0x38, 0x21, 0xec, 0x50, 0xe9, 0x71, + 0x28, 0xfa, 0x1e, 0x34, 0x93, 0x85, 0x83, 0x33, 0x9f, 0xc4, 0x07, 0xba, 0x9b, 0x39, 0x50, 0x86, + 0x02, 0x67, 0x19, 0xd0, 0x63, 0x68, 0xa6, 0x02, 0xbb, 0x1d, 0x76, 0x46, 0x6d, 0xc4, 0xbd, 0x32, + 0x05, 0xce, 0xd2, 0xf3, 0x5b, 0x69, 0x1d, 0x91, 0xa1, 0xd9, 0xed, 0x70, 0x03, 0x68, 0x38, 0x19, + 0xa3, 0x2d, 0xb8, 0x49, 0x5e, 0x5a, 0x83, 0x13, 0x9b, 0x48, 0x3c, 0x36, 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0xdf, 0x2b, 0x70, 0x1b, 0x93, 0xa1, 0xf7, 0x82, 0x5c, 0xeb, 0x40, 0x2d, 0xa8, 0x5a, 0x26, 0xb5, + 0x4c, 0x9b, 0xc4, 0xf5, 0xac, 0x18, 0xb2, 0x95, 0x80, 0xcb, 0xb7, 0xe3, 0x72, 0x59, 0x0c, 0xf3, + 0xba, 0x95, 0x46, 0x74, 0xfb, 0x93, 0x06, 0x77, 0x53, 0xad, 0x46, 0xbc, 0x7f, 0xcd, 0xab, 0x34, + 0xce, 0x07, 0x77, 0x78, 0x68, 0x04, 0x92, 0xf9, 0x93, 0x24, 0x65, 0xc1, 0xfd, 0x90, 0x65, 0xb4, + 0x5e, 0x18, 0x38, 0xfd, 0x3e, 0x09, 0x7a, 0xe4, 0x05, 0x71, 0xc3, 0x5e, 0x8a, 0x53, 0xe2, 0x1c, + 0xe7, 0x22, 0xd2, 0x22, 0x97, 0x71, 0x10, 0x89, 0x78, 0xc2, 0x24, 0xc8, 0x65, 0x6f, 0xb1, 0x7b, + 0xcb, 0xc5, 0xee, 0x1d, 0xc0, 0xfb, 0xec, 0x59, 0xd8, 0xbb, 0x58, 0xab, 0xca, 0x45, 0x5a, 0xdd, + 0x67, 0x82, 0x0e, 0xce, 0xd5, 0x2c, 0xe7, 0xb0, 0xea, 0x88, 0xc3, 0xfe, 0xa8, 0xc2, 0x7c, 0xa1, + 0xc3, 0x26, 0x53, 0xf1, 0x3e, 0x82, 0x32, 0xab, 0x22, 0x44, 0xea, 0xb8, 0x97, 0xe1, 0x4b, 0x76, + 0x4b, 0x6b, 0x8e, 0x88, 0x5a, 0x80, 0x97, 0x76, 0x99, 0x67, 0xec, 0xe5, 0xe0, 0xb0, 0x03, 0x75, + 0x91, 0x35, 0x69, 0x0c, 0x8a, 0xef, 0x17, 0x26, 0xe9, 0x91, 0x2c, 0x8a, 0x53, 0x46, 0x96, 0x6b, + 0x97, 0x52, 0x6b, 0xed, 0x79, 0x34, 0x9c, 0x74, 0x88, 0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4f, 0x75, 0x85, 0x0f, 0x70, 0x34, 0x50, 0x19, 0x4d, 0x87, 0xd1, 0x68, + 0xab, 0x5f, 0xcb, 0x65, 0x73, 0x54, 0x05, 0x6d, 0x63, 0x30, 0xd0, 0xa7, 0x50, 0x05, 0xd4, 0xce, + 0x66, 0xa4, 0xc3, 0x8e, 0x17, 0x0c, 0xcd, 0x81, 0xae, 0xae, 0xbe, 0x82, 0x99, 0x2c, 0x56, 0x70, + 0xb1, 0x5e, 0x70, 0xec, 0xb8, 0xfd, 0x68, 0xc3, 0xfd, 0x90, 0x27, 0x85, 0x68, 0xc3, 0xe8, 0x1c, + 0xb6, 0xae, 0x22, 0x1d, 0xa6, 0xbb, 0xae, 0x13, 0x3a, 0xe6, 0xc0, 0x79, 0xc5, 0x68, 0x35, 0xd4, + 0x84, 0xfa, 0x5e, 0x40, 0x7c, 0x33, 0x60, 0xc3, 0x12, 0x9a, 0x01, 0xe0, 0xc7, 0xc1, 0xc4, 0xb4, + 0xcf, 0xf4, 0x32, 0x63, 0x78, 0x6a, 0x3a, 0xa1, 0xe3, 0xf6, 0xa3, 0x53, 0x56, 0x36, 0xbf, 0xfb, + 0x8f, 0x37, 0x4b, 0xca, 0xeb, 0x37, 0x4b, 0xca, 0x7f, 0xde, 0x2c, 0x29, 0xbf, 0x79, 0xbb, 0x34, + 0xf5, 0xfa, 0xed, 0xd2, 0xd4, 0xbf, 0xdf, 0x2e, 0x4d, 0xfd, 0xf8, 0xcb, 0x7d, 0x27, 0x3c, 0x3a, + 0x39, 0x5c, 0xb3, 0xbc, 0xe1, 0x03, 0xdf, 0x71, 0xfb, 0x96, 0xe9, 0x3f, 0x08, 0x1d, 0xcb, 0xb6, + 0x1e, 0x48, 0x8e, 0x3f, 0xac, 0xf0, 0x7f, 0xd7, 0x1f, 0x7e, 0x11, 0x00, 0x00, 0xff, 0xff, 0xa1, + 0x23, 0xcf, 0x04, 0xda, 0x1e, 0x00, 0x00, } func (m *TableSpan) Marshal() (dAtA []byte, err error) { @@ -3725,16 +3716,6 @@ func (m *DispatcherConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.EnabledSplit { - i-- - if m.EnabledSplit { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x30 - } if m.Mode != 0 { i = encodeVarintHeartbeat(dAtA, i, uint64(m.Mode)) i-- @@ -5630,9 +5611,6 @@ func (m *DispatcherConfig) Size() (n int) { if m.Mode != 0 { n += 1 + sovHeartbeat(uint64(m.Mode)) } - if m.EnabledSplit { - n += 2 - } return n } @@ -8066,26 +8044,6 @@ func (m *DispatcherConfig) Unmarshal(dAtA []byte) error { break } } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EnabledSplit", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHeartbeat - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.EnabledSplit = bool(v != 0) default: iNdEx = preIndex skippy, err := skipHeartbeat(dAtA[iNdEx:]) diff --git a/heartbeatpb/heartbeat.proto b/heartbeatpb/heartbeat.proto index c7039ba8b8..2750899f65 100644 --- a/heartbeatpb/heartbeat.proto +++ b/heartbeatpb/heartbeat.proto @@ -110,7 +110,6 @@ message DispatcherConfig { DispatcherID dispatcherID = 3; int64 schemaID = 4; int64 mode = 5; - bool enabledSplit = 6; } message ScheduleDispatcherRequest { diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 3144ba124f..74dca45b66 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -109,7 +109,7 @@ func (c *Controller) FinishBootstrap( // Step 4: Process tables and build schema info // restore current working operators first - if err := c.restoreCurrentWorkingOperators(allNodesResp); err != nil { + if err := c.restoreCurrentWorkingOperators(allNodesResp, tableSplitMap); err != nil { return nil, err } schemaInfos := c.processTablesAndBuildSchemaInfo(tables, workingTaskMap, redoWorkingTaskMap, isMysqlCompatibleBackend) @@ -424,6 +424,7 @@ func findHoles(currentSpan utils.Map[*heartbeatpb.TableSpan, *replica.SpanReplic func (c *Controller) restoreCurrentWorkingOperators( allNodesResp map[node.ID]*heartbeatpb.MaintainerBootstrapResponse, + tableSplitMap map[int64]bool, ) error { for node, resp := range allNodesResp { for _, req := range resp.Operators { @@ -444,7 +445,7 @@ func (c *Controller) restoreCurrentWorkingOperators( req.Config.Span, req.Config.StartTs, req.Config.Mode, - req.Config.EnabledSplit, + spanController.ShouldEnableSplit(tableSplitMap[req.Config.Span.TableID]), ) spanController.AddAbsentReplicaSet(replicaSet) switch req.ScheduleAction { diff --git a/maintainer/replica/replication_span.go b/maintainer/replica/replication_span.go index d1d1827cd0..4dc1bd5596 100644 --- a/maintainer/replica/replication_span.go +++ b/maintainer/replica/replication_span.go @@ -239,7 +239,6 @@ func (r *SpanReplication) NewAddDispatcherMessage(server node.ID, operatorType h Span: r.Span, StartTs: r.status.Load().CheckpointTs, Mode: r.GetMode(), - EnabledSplit: r.enabledSplit, }, ScheduleAction: heartbeatpb.ScheduleAction_Create, OperatorType: operatorType, From d1d87524275eaa83acc1cd7f7f8423343d67aa43 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Tue, 23 Dec 2025 17:48:03 +0800 Subject: [PATCH 12/25] fix(*): ensure merge operator consistency when maintainer restart --- .../dispatchermanager/dispatcher_manager.go | 6 +- .../dispatcher_manager_merge.go | 101 ++++++ .../dispatchermanager/heartbeat_collector.go | 7 + downstreamadapter/dispatchermanager/helper.go | 27 +- downstreamadapter/dispatchermanager/task.go | 2 + .../dispatcher_orchestrator.go | 1 + heartbeatpb/heartbeat.pb.go | 340 +++++++++++------- heartbeatpb/heartbeat.proto | 2 + maintainer/maintainer_controller.go | 7 +- maintainer/maintainer_controller_bootstrap.go | 244 +++++++++++++ maintainer/operator/operator_controller.go | 50 +++ maintainer/operator/operator_merge.go | 28 ++ 12 files changed, 673 insertions(+), 142 deletions(-) create mode 100644 downstreamadapter/dispatchermanager/dispatcher_manager_merge.go diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager.go b/downstreamadapter/dispatchermanager/dispatcher_manager.go index f907b68d5c..b95428571a 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager.go @@ -86,8 +86,9 @@ type DispatcherManager struct { // redoDispatcherMap restore all the redo dispatchers in the DispatcherManager, including redo table trigger event dispatcher redoDispatcherMap *DispatcherMap[*dispatcher.RedoDispatcher] // currentOperatorMap stores the current operators for each dispatcher - currentOperatorMap sync.Map // map[span.String()]*dispatcher.CurrentOperator - redoCurrentOperatorMap sync.Map // map[span.string()]*dispatcher.CurrentOperator + currentOperatorMap sync.Map // map[span.String() or dispatcher.ID.String()]*dispatcher.CurrentOperator + redoCurrentOperatorMap sync.Map // map[span.string() or dispatcher.ID.String()]*dispatcher.CurrentOperator + mergeOperatorMap sync.Map // map[mergedDispatcherID.String()]*heartbeatpb.MergeDispatcherRequest // schemaIDToDispatchers is shared in the DispatcherManager, // it store all the infos about schemaID->Dispatchers // Dispatchers may change the schemaID when meets some special events, such as rename ddl @@ -178,6 +179,7 @@ func NewDispatcherManager( dispatcherMap: newDispatcherMap[*dispatcher.EventDispatcher](), currentOperatorMap: sync.Map{}, redoCurrentOperatorMap: sync.Map{}, + mergeOperatorMap: sync.Map{}, changefeedID: changefeedID, keyspaceID: keyspaceID, pdClock: pdClock, diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go b/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go new file mode 100644 index 0000000000..2bb527da88 --- /dev/null +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go @@ -0,0 +1,101 @@ +// 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" +) + +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)) +} + +func (e *DispatcherManager) RemoveMergeOperator(mergedDispatcherID common.DispatcherID) { + e.mergeOperatorMap.Delete(mergedDispatcherID.String()) +} + +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) +} + +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 +} diff --git a/downstreamadapter/dispatchermanager/heartbeat_collector.go b/downstreamadapter/dispatchermanager/heartbeat_collector.go index bbeb2a123b..84308d5406 100644 --- a/downstreamadapter/dispatchermanager/heartbeat_collector.go +++ b/downstreamadapter/dispatchermanager/heartbeat_collector.go @@ -60,6 +60,8 @@ type HeartBeatCollector struct { mergeDispatcherRequestDynamicStream dynstream.DynamicStream[int, common.GID, MergeDispatcherRequest, *DispatcherManager, *MergeDispatcherRequestHandler] mc messaging.MessageCenter + dispatcherManagers sync.Map // map[common.GID]*DispatcherManager + wg sync.WaitGroup cancel context.CancelFunc isClosed atomic.Bool @@ -128,6 +130,7 @@ func (c *HeartBeatCollector) RegisterDispatcherManager(m *DispatcherManager) err if err != nil { return errors.Trace(err) } + c.dispatcherManagers.Store(m.changefeedID.Id, m) return nil } @@ -170,6 +173,7 @@ func (c *HeartBeatCollector) RemoveDispatcherManager(id common.ChangeFeedID) err if err != nil { return errors.Trace(err) } + c.dispatcherManagers.Delete(id.Id) return nil } @@ -284,6 +288,9 @@ func (c *HeartBeatCollector) RecvMessages(_ context.Context, msg *messaging.Targ NewRedoMetaMessage(redoMessage)) case messaging.TypeMergeDispatcherRequest: mergeDispatcherRequest := msg.Message[0].(*heartbeatpb.MergeDispatcherRequest) + if manager, ok := c.dispatcherManagers.Load(common.NewChangefeedGIDFromPB(mergeDispatcherRequest.ChangefeedID)); ok { + manager.(*DispatcherManager).TrackMergeOperator(mergeDispatcherRequest) + } c.mergeDispatcherRequestDynamicStream.Push( common.NewChangefeedGIDFromPB(mergeDispatcherRequest.ChangefeedID), NewMergeDispatcherRequest(mergeDispatcherRequest)) diff --git a/downstreamadapter/dispatchermanager/helper.go b/downstreamadapter/dispatchermanager/helper.go index 412558b3af..972d09c62e 100644 --- a/downstreamadapter/dispatchermanager/helper.go +++ b/downstreamadapter/dispatchermanager/helper.go @@ -180,6 +180,11 @@ func schedulerDispatcherKey(req *heartbeatpb.ScheduleDispatcherRequest) string { if req.Config.Span != nil { return req.Config.Span.String() } + log.Info("nil span for operator", + zap.String("changefeedID", req.ChangefeedID.String()), + zap.String("dispatcherID", common.NewDispatcherIDFromPB(req.Config.DispatcherID).String()), + zap.Any("operator", req), + ) if req.Config.DispatcherID != nil { return common.NewDispatcherIDFromPB(req.Config.DispatcherID).String() } @@ -221,10 +226,22 @@ func (h *SchedulerDispatcherRequestHandler) Handle(dispatcherManager *Dispatcher // If there is already an operator for the span, skip this request. _, exists := dispatcherManager.currentOperatorMap.Load(operatorKey) if exists { + log.Warn("operator key exists, skip this request", + zap.String("changefeedID", req.ChangefeedID.String()), + zap.String("dispatcherID", common.NewDispatcherIDFromPB(req.Config.DispatcherID).String()), + zap.String("operatorKey", operatorKey), + zap.Any("operator", req), + ) continue } _, redoExists := dispatcherManager.redoCurrentOperatorMap.Load(operatorKey) if redoExists { + log.Warn("redo operator key exists, skip this request", + zap.String("changefeedID", req.ChangefeedID.String()), + zap.String("dispatcherID", common.NewDispatcherIDFromPB(req.Config.DispatcherID).String()), + zap.String("operatorKey", operatorKey), + zap.Any("operator", req), + ) continue } config := req.Config @@ -649,11 +666,19 @@ func (h *MergeDispatcherRequestHandler) Handle(dispatcherManager *DispatcherMana } mergeDispatcherRequest := reqs[0] + dispatcherManager.TrackMergeOperator(mergeDispatcherRequest.MergeDispatcherRequest) dispatcherIDs := make([]common.DispatcherID, 0, len(mergeDispatcherRequest.DispatcherIDs)) for _, id := range mergeDispatcherRequest.DispatcherIDs { dispatcherIDs = append(dispatcherIDs, common.NewDispatcherIDFromPB(id)) } - dispatcherManager.MergeDispatcher(dispatcherIDs, common.NewDispatcherIDFromPB(mergeDispatcherRequest.MergedDispatcherID), mergeDispatcherRequest.Mode) + task := dispatcherManager.MergeDispatcher( + dispatcherIDs, + common.NewDispatcherIDFromPB(mergeDispatcherRequest.MergedDispatcherID), + mergeDispatcherRequest.Mode, + ) + if task == nil { + dispatcherManager.MaybeCleanupMergeOperator(mergeDispatcherRequest.MergeDispatcherRequest) + } return false } diff --git a/downstreamadapter/dispatchermanager/task.go b/downstreamadapter/dispatchermanager/task.go index a2da8b8fac..016111e4dc 100644 --- a/downstreamadapter/dispatchermanager/task.go +++ b/downstreamadapter/dispatchermanager/task.go @@ -208,6 +208,7 @@ func abortMerge[T dispatcher.Dispatcher](t *MergeCheckTask, dispatcherMap *Dispa } removeDispatcher(t.manager, t.mergedDispatcher.GetId(), dispatcherMap, sinkType) + t.manager.RemoveMergeOperator(t.mergedDispatcher.GetId()) } func doMerge[T dispatcher.Dispatcher](t *MergeCheckTask, dispatcherMap *DispatcherMap[T]) { @@ -335,6 +336,7 @@ func doMerge[T dispatcher.Dispatcher](t *MergeCheckTask, dispatcherMap *Dispatch } dispatcher.Remove() } + t.manager.RemoveMergeOperator(t.mergedDispatcher.GetId()) } var ( diff --git a/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go b/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go index 9507a494f8..22aeac984d 100644 --- a/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go +++ b/downstreamadapter/dispatcherorchestrator/dispatcher_orchestrator.go @@ -420,6 +420,7 @@ func createBootstrapResponse( }) return true }) + response.MergeOperators = append(response.MergeOperators, manager.GetMergeOperators()...) return response } diff --git a/heartbeatpb/heartbeat.pb.go b/heartbeatpb/heartbeat.pb.go index a5bb71149f..6f8adbccb7 100644 --- a/heartbeatpb/heartbeat.pb.go +++ b/heartbeatpb/heartbeat.pb.go @@ -1637,6 +1637,8 @@ type MaintainerBootstrapResponse struct { // - checkpoint_ts is set to 0 CheckpointTs uint64 `protobuf:"varint,4,opt,name=checkpoint_ts,json=checkpointTs,proto3" json:"checkpoint_ts,omitempty"` Operators []*ScheduleDispatcherRequest `protobuf:"bytes,5,rep,name=operators,proto3" json:"operators,omitempty"` + // merge_operators contains in-flight merge dispatcher requests for bootstrap recovery. + MergeOperators []*MergeDispatcherRequest `protobuf:"bytes,6,rep,name=merge_operators,json=mergeOperators,proto3" json:"merge_operators,omitempty"` } func (m *MaintainerBootstrapResponse) Reset() { *m = MaintainerBootstrapResponse{} } @@ -1707,6 +1709,13 @@ func (m *MaintainerBootstrapResponse) GetOperators() []*ScheduleDispatcherReques return nil } +func (m *MaintainerBootstrapResponse) GetMergeOperators() []*MergeDispatcherRequest { + if m != nil { + return m.MergeOperators + } + return nil +} + type MaintainerPostBootstrapRequest struct { ChangefeedID *ChangefeedID `protobuf:"bytes,1,opt,name=changefeedID,proto3" json:"changefeedID,omitempty"` TableTriggerEventDispatcherId *DispatcherID `protobuf:"bytes,2,opt,name=table_trigger_event_dispatcher_id,json=tableTriggerEventDispatcherId,proto3" json:"table_trigger_event_dispatcher_id,omitempty"` @@ -2952,145 +2961,146 @@ func init() { func init() { proto.RegisterFile("heartbeatpb/heartbeat.proto", fileDescriptor_6d584080fdadb670) } var fileDescriptor_6d584080fdadb670 = []byte{ - // 2199 bytes of a gzipped FileDescriptorProto + // 2222 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x59, 0x4b, 0x6f, 0xdc, 0xc8, - 0x11, 0x16, 0xc9, 0x79, 0xd6, 0x68, 0x24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, 0xfe, - 0xa5, 0x82, 0xfe, 0x19, 0x53, 0x65, 0x93, 0x98, 0x21, 0x26, 0xcf, 0x4f, 0x08, 0x0d, 0xd1, 0x77, - 0x60, 0xda, 0x3a, 0x32, 0xdd, 0x3e, 0x79, 0x46, 0x88, 0x1d, 0xeb, 0xd1, 0x58, 0xbf, 0xb3, 0x26, - 0xe9, 0xbc, 0xd6, 0x96, 0x08, 0x70, 0x86, 0x1c, 0x7d, 0x04, 0xf5, 0x53, 0x33, 0x24, 0xc1, 0xd0, - 0x0c, 0x8e, 0xb9, 0xa2, 0x8d, 0xf5, 0xb9, 0x0c, 0xef, 0x53, 0xb1, 0x8a, 0x53, 0x42, 0xf4, 0x31, - 0x34, 0x03, 0x62, 0x7b, 0xc9, 0x1a, 0x3f, 0xc8, 0x78, 0xce, 0x2c, 0x31, 0xfa, 0x26, 0xd4, 0x68, - 0x68, 0x86, 0x27, 0x94, 0xd0, 0x56, 0x69, 0x59, 0x5b, 0x69, 0xac, 0x2f, 0x64, 0x18, 0x13, 0xfb, - 0xee, 0x73, 0x2a, 0x9c, 0x50, 0xa3, 0x15, 0x98, 0xb5, 0xbc, 0xa1, 0x4f, 0x06, 0x24, 0x24, 0xd1, - 0x62, 0xab, 0xbc, 0xac, 0xac, 0xd4, 0x70, 0x7e, 0x1a, 0x7d, 0x00, 0x1a, 0x09, 0x82, 0x56, 0xa5, - 0xc0, 0x1a, 0xf8, 0xc4, 0x75, 0x1d, 0xb7, 0xff, 0x24, 0x08, 0xbc, 0x00, 0x33, 0x2a, 0xe3, 0x57, - 0x0a, 0xd4, 0x53, 0xf5, 0x0c, 0x66, 0x51, 0x62, 0x1d, 0xfb, 0x9e, 0xe3, 0x86, 0x07, 0x94, 0x5b, - 0xb4, 0x84, 0x33, 0x73, 0xcc, 0x55, 0x01, 0xa1, 0xde, 0xe0, 0x05, 0xb1, 0x0f, 0x28, 0xb7, 0x5b, - 0x09, 0x4b, 0x33, 0x48, 0x07, 0x8d, 0x92, 0xe7, 0xdc, 0x2c, 0x25, 0xcc, 0x3e, 0x99, 0xd4, 0x81, - 0x49, 0xc3, 0xfd, 0x33, 0xd7, 0xe2, 0x3c, 0xa5, 0x48, 0xaa, 0x3c, 0x67, 0x7c, 0x0e, 0x7a, 0xc7, - 0xa1, 0xbe, 0x19, 0x5a, 0x47, 0x24, 0xd8, 0xb0, 0x42, 0xc7, 0x73, 0xd1, 0x07, 0x50, 0x31, 0xf9, - 0x17, 0xd7, 0x63, 0x66, 0xfd, 0x66, 0xe6, 0x2c, 0x11, 0x11, 0x8e, 0x49, 0x58, 0xd4, 0xb5, 0xbd, - 0xe1, 0xd0, 0x09, 0x13, 0xa5, 0x92, 0x31, 0x5a, 0x86, 0x46, 0x97, 0xb2, 0xad, 0xf6, 0xd8, 0x19, - 0xb8, 0x6a, 0x35, 0x2c, 0x4f, 0x19, 0x6d, 0xd0, 0x36, 0xda, 0x5b, 0x19, 0x21, 0xca, 0xf9, 0x42, - 0xd4, 0x51, 0x21, 0xbf, 0x54, 0xe1, 0x56, 0xd7, 0x7d, 0x36, 0x38, 0x21, 0xec, 0x50, 0xe9, 0x71, - 0x28, 0xfa, 0x1e, 0x34, 0x93, 0x85, 0x83, 0x33, 0x9f, 0xc4, 0x07, 0xba, 0x9b, 0x39, 0x50, 0x86, - 0x02, 0x67, 0x19, 0xd0, 0x63, 0x68, 0xa6, 0x02, 0xbb, 0x1d, 0x76, 0x46, 0x6d, 0xc4, 0xbd, 0x32, - 0x05, 0xce, 0xd2, 0xf3, 0x5b, 0x69, 0x1d, 0x91, 0xa1, 0xd9, 0xed, 0x70, 0x03, 0x68, 0x38, 0x19, - 0xa3, 0x2d, 0xb8, 0x49, 0x5e, 0x5a, 0x83, 0x13, 0x9b, 0x48, 0x3c, 0x36, 0xf7, 0xd3, 0xb9, 0x5b, - 0x14, 0x71, 0x19, 0x7f, 0x57, 0x64, 0x57, 0xc6, 0x31, 0xf9, 0x43, 0xb8, 0xe5, 0x14, 0x59, 0x26, -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0xf5, 0xac, 0x18, 0xb2, 0x95, 0x80, 0xcb, 0xb7, 0xe3, 0x72, 0x59, 0x0c, 0xf3, - 0xba, 0x95, 0x46, 0x74, 0xfb, 0x93, 0x06, 0x77, 0x53, 0xad, 0x46, 0xbc, 0x7f, 0xcd, 0xab, 0x34, - 0xce, 0x07, 0x77, 0x78, 0x68, 0x04, 0x92, 0xf9, 0x93, 0x24, 0x65, 0xc1, 0xfd, 0x90, 0x65, 0xb4, - 0x5e, 0x18, 0x38, 0xfd, 0x3e, 0x09, 0x7a, 0xe4, 0x05, 0x71, 0xc3, 0x5e, 0x8a, 0x53, 0xe2, 0x1c, - 0xe7, 0x22, 0xd2, 0x22, 0x97, 0x71, 0x10, 0x89, 0x78, 0xc2, 0x24, 0xc8, 0x65, 0x6f, 0xb1, 0x7b, - 0xcb, 0xc5, 0xee, 0x1d, 0xc0, 0xfb, 0xec, 0x59, 0xd8, 0xbb, 0x58, 0xab, 0xca, 0x45, 0x5a, 0xdd, - 0x67, 0x82, 0x0e, 0xce, 0xd5, 0x2c, 0xe7, 0xb0, 0xea, 0x88, 0xc3, 0xfe, 0xa8, 0xc2, 0x7c, 0xa1, - 0xc3, 0x26, 0x53, 0xf1, 0x3e, 0x82, 0x32, 0xab, 0x22, 0x44, 0xea, 0xb8, 0x97, 0xe1, 0x4b, 0x76, - 0x4b, 0x6b, 0x8e, 0x88, 0x5a, 0x80, 0x97, 0x76, 0x99, 0x67, 0xec, 0xe5, 0xe0, 0xb0, 0x03, 0x75, - 0x91, 0x35, 0x69, 0x0c, 0x8a, 0xef, 0x17, 0x26, 0xe9, 0x91, 0x2c, 0x8a, 0x53, 0x46, 0x96, 0x6b, - 0x97, 0x52, 0x6b, 0xed, 0x79, 0x34, 0x9c, 0x74, 0x88, 0x5f, 0x2a, 0x5e, 0xd5, 0x6b, 0xc6, 0xeb, - 0x43, 0xa8, 0x46, 0xa5, 0x16, 0xbb, 0x2e, 0xcc, 0x14, 0xb7, 0x47, 0x4c, 0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f, 0x23, 0x1d, 0xb4, 0x81, 0x77, 0x1a, 0x03, 0x05, 0xfb, 0x64, 0xba, 0xc9, 0x66, 0xb9, 0x1c, - 0x17, 0xd7, 0x96, 0x15, 0x0e, 0xb1, 0x66, 0xec, 0x9b, 0x41, 0xab, 0x78, 0x1d, 0xc4, 0xaa, 0x25, - 0x63, 0xe3, 0xa7, 0x70, 0xef, 0xfb, 0x5e, 0x5f, 0x7a, 0xa4, 0xa7, 0x4d, 0xcd, 0xc9, 0x38, 0xd0, - 0xf8, 0x85, 0x02, 0xcb, 0xe3, 0xb7, 0x98, 0x4c, 0x22, 0xbc, 0xa0, 0x63, 0xba, 0xba, 0x08, 0x95, - 0xb8, 0x31, 0x57, 0x87, 0xf2, 0xd3, 0xc0, 0x09, 0x89, 0x3e, 0x85, 0x6a, 0x50, 0xda, 0x33, 0x29, - 0xd5, 0x95, 0xd5, 0x95, 0x28, 0x83, 0x48, 0xfd, 0x3b, 0x80, 0x4a, 0x3b, 0x20, 0x26, 0xa7, 0x03, - 0xa8, 0x44, 0x4f, 0x73, 0x5d, 0x59, 0xdd, 0x86, 0x69, 0xb9, 0x6d, 0xc7, 0xc4, 0xed, 0xf6, 0x36, - 0x6c, 0x5b, 0x9f, 0x42, 0xd3, 0x50, 0xdb, 0xed, 0x09, 0x42, 0xc6, 0xb4, 0xdb, 0xdb, 0x66, 0xdf, - 0x2a, 0x6a, 0x40, 0x75, 0xb7, 0xc7, 0xf3, 0x95, 0xae, 0x45, 0x03, 0xde, 0xdb, 0xd3, 0x4b, 0xab, - 0xdf, 0x06, 0x48, 0xb1, 0x8b, 0x29, 0xb4, 0xb3, 0xbb, 0xf3, 0x44, 0x9f, 0x62, 0x44, 0x4f, 0x37, - 0xba, 0x07, 0xdd, 0x9d, 0x4f, 0x75, 0x85, 0x0f, 0x70, 0x34, 0x50, 0x19, 0x4d, 0x87, 0xd1, 0x68, - 0xab, 0x5f, 0xcb, 0x65, 0x73, 0x54, 0x05, 0x6d, 0x63,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x93, 0xae, 0x8d, + 0x00, 0x6e, 0x8f, 0x6c, 0x39, 0x99, 0xdb, 0xc5, 0xba, 0xc2, 0xa1, 0x65, 0x11, 0x4a, 0xc5, 0x9e, + 0xf1, 0xd0, 0xf8, 0xb5, 0x02, 0x7a, 0xfa, 0x88, 0x13, 0x05, 0xe0, 0x04, 0xde, 0xc0, 0xee, 0x42, + 0x2d, 0x0e, 0xd3, 0x28, 0x97, 0x68, 0x38, 0x19, 0x9f, 0xf7, 0xbc, 0x65, 0xfc, 0x04, 0xca, 0x9c, + 0xee, 0x82, 0x37, 0xeb, 0x71, 0x61, 0xb9, 0x08, 0xf5, 0x03, 0xbf, 0xef, 0x70, 0x14, 0x88, 0x8b, + 0xa1, 0x74, 0xc2, 0x70, 0x61, 0x46, 0x50, 0x46, 0xb6, 0x3a, 0x67, 0x97, 0x15, 0x68, 0xec, 0xf5, + 0xed, 0xdc, 0x46, 0xf2, 0x14, 0xa3, 0xd8, 0x25, 0xa7, 0xb9, 0x93, 0xc8, 0x53, 0xc6, 0x1f, 0x34, + 0x28, 0x47, 0x01, 0xb6, 0x08, 0xf5, 0x0e, 0xdd, 0x62, 0x01, 0x47, 0xa2, 0x72, 0xaf, 0x86, 0xd3, + 0x09, 0xa6, 0x05, 0xff, 0x4c, 0x7b, 0xf6, 0x78, 0x88, 0x1e, 0x43, 0x23, 0xfa, 0x14, 0xf0, 0x31, + 0xda, 0xec, 0xe6, 0x9d, 0x87, 0x65, 0x0e, 0xb4, 0x0d, 0x37, 0x76, 0x09, 0xb1, 0xdb, 0x81, 0xe7, + 0xfb, 0x82, 0x22, 0xae, 0x9f, 0x2e, 0x10, 0x33, 0xca, 0x87, 0x3e, 0x82, 0x59, 0x36, 0xb9, 0x69, + 0xdb, 0x89, 0xa8, 0x28, 0x35, 0xa3, 0xd1, 0xfb, 0x8f, 0xf3, 0xa4, 0xac, 0xf9, 0xfe, 0x81, 0x6f, + 0x9b, 0x21, 0x89, 0x4d, 0x28, 0x72, 0x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, 0xb4, 0x19, 0x8d, 0xb6, 0xf6, 0xf5, 0x5c, 0x36, 0x47, 0x55, 0xd0, 0x36, 0xfb, + 0x7d, 0x7d, 0x0a, 0x55, 0x40, 0x6d, 0x6f, 0x45, 0x3a, 0xec, 0x7a, 0xc1, 0xc0, 0xec, 0xeb, 0xea, + 0xda, 0x2b, 0x98, 0xc9, 0x62, 0x05, 0x17, 0xeb, 0x05, 0x27, 0x8e, 0xdb, 0x8b, 0x36, 0x3c, 0x08, + 0x79, 0x52, 0x88, 0x36, 0x8c, 0xce, 0x61, 0xeb, 0x2a, 0xd2, 0x61, 0xba, 0xe3, 0x3a, 0xa1, 0x63, + 0xf6, 0x9d, 0x57, 0x8c, 0x56, 0x43, 0x4d, 0xa8, 0xef, 0x07, 0xc4, 0x37, 0x03, 0x36, 0x2c, 0xa1, + 0x19, 0x00, 0x7e, 0x1c, 0x4c, 0x4c, 0xfb, 0x4c, 0x2f, 0x33, 0x86, 0xa7, 0xa6, 0x13, 0x3a, 0x6e, + 0x2f, 0x3a, 0x65, 0x65, 0xeb, 0x7b, 0x7f, 0x7f, 0xbd, 0xac, 0x7c, 0xf1, 0x7a, 0x59, 0xf9, 0xf7, + 0xeb, 0x65, 0xe5, 0x37, 0x6f, 0x96, 0xa7, 0xbe, 0x78, 0xb3, 0x3c, 0xf5, 0xaf, 0x37, 0xcb, 0x53, + 0x3f, 0xfe, 0x4a, 0xcf, 0x09, 0x8f, 0x87, 0x47, 0xeb, 0x96, 0x37, 0x78, 0xe0, 0x3b, 0x6e, 0xcf, + 0x32, 0xfd, 0x07, 0xa1, 0x63, 0xd9, 0xd6, 0x03, 0xc9, 0xf1, 0x47, 0x15, 0xfe, 0x27, 0xfc, 0x83, + 0x2f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x62, 0xb7, 0x32, 0xa6, 0x28, 0x1f, 0x00, 0x00, } func (m *TableSpan) Marshal() (dAtA []byte, err error) { @@ -4292,6 +4302,20 @@ func (m *MaintainerBootstrapResponse) MarshalToSizedBuffer(dAtA []byte) (int, er _ = i var l int _ = l + if len(m.MergeOperators) > 0 { + for iNdEx := len(m.MergeOperators) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.MergeOperators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintHeartbeat(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } if len(m.Operators) > 0 { for iNdEx := len(m.Operators) - 1; iNdEx >= 0; iNdEx-- { { @@ -5851,6 +5875,12 @@ func (m *MaintainerBootstrapResponse) Size() (n int) { n += 1 + l + sovHeartbeat(uint64(l)) } } + if len(m.MergeOperators) > 0 { + for _, e := range m.MergeOperators { + l = e.Size() + n += 1 + l + sovHeartbeat(uint64(l)) + } + } return n } @@ -9627,6 +9657,40 @@ func (m *MaintainerBootstrapResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MergeOperators", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeartbeat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthHeartbeat + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthHeartbeat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MergeOperators = append(m.MergeOperators, &MergeDispatcherRequest{}) + if err := m.MergeOperators[len(m.MergeOperators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipHeartbeat(dAtA[iNdEx:]) diff --git a/heartbeatpb/heartbeat.proto b/heartbeatpb/heartbeat.proto index 2750899f65..080a91c1d2 100644 --- a/heartbeatpb/heartbeat.proto +++ b/heartbeatpb/heartbeat.proto @@ -187,6 +187,8 @@ message MaintainerBootstrapResponse { // - checkpoint_ts is set to 0 uint64 checkpoint_ts = 4; repeated ScheduleDispatcherRequest operators = 5; + // merge_operators contains in-flight merge dispatcher requests for bootstrap recovery. + repeated MergeDispatcherRequest merge_operators = 6; } message MaintainerPostBootstrapRequest { diff --git a/maintainer/maintainer_controller.go b/maintainer/maintainer_controller.go index 5ac2f33291..f543ff59c3 100644 --- a/maintainer/maintainer_controller.go +++ b/maintainer/maintainer_controller.go @@ -143,12 +143,13 @@ func (c *Controller) HandleStatus(from node.ID, statusList []*heartbeatpb.TableS spanController := c.getSpanController(status.Mode) operatorController.UpdateOperatorStatus(dispatcherID, from, status) + op := operatorController.GetOperator(dispatcherID) stm := spanController.GetTaskByID(dispatcherID) if stm == nil { if status.ComponentStatus != heartbeatpb.ComponentState_Working { continue } - if op := operatorController.GetOperator(dispatcherID); op == nil { + if op == nil { // it's normal case when the span is not found in replication db // the span is removed from replication db first, so here we only check if the span status is working or not log.Warn("no span found, remove it", @@ -171,6 +172,10 @@ func (c *Controller) HandleStatus(from node.ID, statusList []*heartbeatpb.TableS continue } spanController.UpdateStatus(stm, status) + if status.ComponentStatus == heartbeatpb.ComponentState_Working && op == nil && + !spanController.IsReplicating(stm) && stm.GetNodeID() != "" { + spanController.MarkSpanReplicating(stm) + } } } diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 74dca45b66..970e7528ba 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -16,6 +16,7 @@ package maintainer import ( "bytes" "context" + "sort" "time" "github.com/pingcap/log" @@ -113,6 +114,9 @@ func (c *Controller) FinishBootstrap( return nil, err } schemaInfos := c.processTablesAndBuildSchemaInfo(tables, workingTaskMap, redoWorkingTaskMap, isMysqlCompatibleBackend) + if err := c.restoreCurrentMergeOperators(allNodesResp, tableSplitMap); err != nil { + return nil, err + } // Step 5: Handle any remaining working tasks (likely dropped tables) c.handleRemainingWorkingTasks(workingTaskMap, redoWorkingTaskMap) @@ -514,3 +518,243 @@ func (c *Controller) restoreCurrentWorkingOperators( } return nil } + +func (c *Controller) restoreCurrentMergeOperators( + allNodesResp map[node.ID]*heartbeatpb.MaintainerBootstrapResponse, + tableSplitMap map[int64]bool, +) error { + for nodeID, resp := range allNodesResp { + if len(resp.MergeOperators) == 0 { + continue + } + spanInfoByID := make(map[string]*heartbeatpb.BootstrapTableSpan, len(resp.Spans)) + for _, spanInfo := range resp.Spans { + if spanInfo == nil || spanInfo.ID == nil || spanInfo.Span == nil { + continue + } + spanInfoByID[common.NewDispatcherIDFromPB(spanInfo.ID).String()] = spanInfo + } + + for _, mergeReq := range resp.MergeOperators { + if mergeReq == nil || mergeReq.MergedDispatcherID == nil { + continue + } + if len(mergeReq.DispatcherIDs) < 2 { + log.Warn("merge operator has insufficient dispatcher IDs", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String())) + continue + } + + spanController := c.getSpanController(mergeReq.Mode) + operatorController := c.getOperatorController(mergeReq.Mode) + mergedDispatcherID := common.NewDispatcherIDFromPB(mergeReq.MergedDispatcherID) + + // get source replica sets + sourceReplicaSets := make([]*replica.SpanReplication, 0, len(mergeReq.DispatcherIDs)) + sourceComplete := true + seenSources := make(map[string]struct{}, len(mergeReq.DispatcherIDs)) + for _, idPB := range mergeReq.DispatcherIDs { + if idPB == nil { + sourceComplete = false + break + } + dispatcherID := common.NewDispatcherIDFromPB(idPB) + if _, ok := seenSources[dispatcherID.String()]; ok { + continue + } + seenSources[dispatcherID.String()] = struct{}{} + + replicaSet := spanController.GetTaskByID(dispatcherID) + if replicaSet == nil { + spanInfo := spanInfoByID[dispatcherID.String()] + if spanInfo == nil { + sourceComplete = false + break + } + splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[spanInfo.Span.TableID]) + replicaSet = c.createSpanReplication(spanInfo, nodeID, splitEnabled) + spanController.AddReplicatingSpan(replicaSet) + } + sourceReplicaSets = append(sourceReplicaSets, replicaSet) + } + + // process merged replica set + mergedSpanInfo := spanInfoByID[mergedDispatcherID.String()] + mergedReplicaSet := spanController.GetTaskByID(mergedDispatcherID) + // if merge already finished, remove source spans and mark merged span as replicating, done + if mergedSpanInfo != nil && mergedSpanInfo.ComponentStatus == heartbeatpb.ComponentState_Working { + if mergedReplicaSet == nil { + splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[mergedSpanInfo.Span.TableID]) + mergedReplicaSet = c.createSpanReplication(mergedSpanInfo, nodeID, splitEnabled) + spanController.AddReplicatingSpan(mergedReplicaSet) + } + for _, replicaSet := range sourceReplicaSets { + if mergedReplicaSet != nil && replicaSet.ID == mergedReplicaSet.ID { + continue + } + spanController.RemoveReplicatingSpan(replicaSet) + } + if mergedReplicaSet != nil { + spanController.MarkSpanReplicating(mergedReplicaSet) + } + log.Info("merge already finished during bootstrap", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", mergedDispatcherID.String())) + continue + } + + // if merge not finished and source spans are not complete, + // mark source spans as scheduling and create merged span if exists and mark it as scheduling + if !sourceComplete || len(sourceReplicaSets) < 2 { + log.Warn("skip restoring merge operator due to missing source dispatchers", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", mergedDispatcherID.String())) + for _, replicaSet := range sourceReplicaSets { + spanController.MarkSpanScheduling(replicaSet) + } + if mergedSpanInfo != nil { + if mergedReplicaSet == nil { + splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[mergedSpanInfo.Span.TableID]) + mergedReplicaSet = c.createSpanReplication(mergedSpanInfo, nodeID, splitEnabled) + if mergedSpanInfo.ComponentStatus == heartbeatpb.ComponentState_Working { + spanController.AddReplicatingSpan(mergedReplicaSet) + } else { + spanController.AddSchedulingReplicaSet(mergedReplicaSet, nodeID) + } + } else if mergedSpanInfo.ComponentStatus == heartbeatpb.ComponentState_Working { + spanController.MarkSpanReplicating(mergedReplicaSet) + } else { + spanController.MarkSpanScheduling(mergedReplicaSet) + } + } + continue + } + + // if merge not finished and source spans are complete, + // restore merge operator and occupy operators + sort.Slice(sourceReplicaSets, func(i, j int) bool { + return bytes.Compare(sourceReplicaSets[i].Span.StartKey, sourceReplicaSets[j].Span.StartKey) < 0 + }) + + createdMerged := false + if mergedReplicaSet == nil { + if mergedSpanInfo != nil { + splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[mergedSpanInfo.Span.TableID]) + mergedReplicaSet = c.createSpanReplication(mergedSpanInfo, nodeID, splitEnabled) + spanController.AddSchedulingReplicaSet(mergedReplicaSet, nodeID) + } else { + mergedSpan, schemaID, checkpointTs, ok := buildMergedSpanFromReplicas(sourceReplicaSets) + if !ok { + log.Warn("skip restoring merge operator due to invalid merge spans", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", mergedDispatcherID.String())) + continue + } + splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[mergedSpan.TableID]) + status := &heartbeatpb.TableSpanStatus{ + ID: mergedDispatcherID.ToPB(), + CheckpointTs: checkpointTs, + Mode: mergeReq.Mode, + ComponentStatus: heartbeatpb.ComponentState_Preparing, + } + mergedReplicaSet = replica.NewWorkingSpanReplication( + c.changefeedID, + mergedDispatcherID, + schemaID, + mergedSpan, + status, + nodeID, + splitEnabled, + ) + spanController.AddSchedulingReplicaSet(mergedReplicaSet, nodeID) + createdMerged = true + } + } + + if mergedReplicaSet == nil { + log.Warn("merge replica set not found when restoring merge", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", mergedDispatcherID.String())) + continue + } + + spanController.MarkSpanScheduling(mergedReplicaSet) + + mergeOp := operatorController.AddRestoredMergeOperator(sourceReplicaSets, mergedReplicaSet) + if mergeOp == nil { + log.Error("restore merge operator failed", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", mergedDispatcherID.String()), + zap.Any("mergedReplicaSet", mergedReplicaSet), + zap.Any("toMergedReplicaSets", sourceReplicaSets), + ) + if createdMerged { + spanController.RemoveReplicatingSpan(mergedReplicaSet) + } + return errors.ErrOperatorIsNil.GenWithStack("restore merge operator failed when bootstrap") + } + mergeOp.Start() + } + } + return nil +} + +func buildMergedSpanFromReplicas( + replicaSets []*replica.SpanReplication, +) (*heartbeatpb.TableSpan, int64, uint64, bool) { + if len(replicaSets) < 2 { + return nil, 0, 0, false + } + first := replicaSets[0] + if first == nil || first.Span == nil { + return nil, 0, 0, false + } + tableID := first.Span.TableID + keyspaceID := first.Span.KeyspaceID + schemaID := first.GetSchemaID() + nodeID := first.GetNodeID() + startKey := first.Span.StartKey + endKey := first.Span.EndKey + firstStatus := first.GetStatus() + if firstStatus == nil { + return nil, 0, 0, false + } + minCheckpoint := firstStatus.CheckpointTs + prevSpan := first.Span + for idx := 1; idx < len(replicaSets); idx++ { + replicaSet := replicaSets[idx] + if replicaSet == nil || replicaSet.Span == nil { + return nil, 0, 0, false + } + if replicaSet.Span.TableID != tableID || + replicaSet.Span.KeyspaceID != keyspaceID || + replicaSet.GetSchemaID() != schemaID || + replicaSet.GetNodeID() != nodeID { + return nil, 0, 0, false + } + if !common.IsTableSpanConsecutive(prevSpan, replicaSet.Span) { + return nil, 0, 0, false + } + status := replicaSet.GetStatus() + if status == nil { + return nil, 0, 0, false + } + if checkpoint := status.CheckpointTs; checkpoint < minCheckpoint { + minCheckpoint = checkpoint + } + prevSpan = replicaSet.Span + endKey = replicaSet.Span.EndKey + } + return &heartbeatpb.TableSpan{ + TableID: tableID, + StartKey: startKey, + EndKey: endKey, + KeyspaceID: keyspaceID, + }, schemaID, minCheckpoint, true +} diff --git a/maintainer/operator/operator_controller.go b/maintainer/operator/operator_controller.go index b1aefea3fb..a32873e104 100644 --- a/maintainer/operator/operator_controller.go +++ b/maintainer/operator/operator_controller.go @@ -460,6 +460,56 @@ func (oc *Controller) AddMergeOperator( return mergeOperator } +func (oc *Controller) AddRestoredMergeOperator( + affectedReplicaSets []*replica.SpanReplication, + mergedReplicaSet *replica.SpanReplication, +) operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus] { + if mergedReplicaSet == nil { + return nil + } + if !checkMergeOperator(affectedReplicaSets) { + return nil + } + + operators := make([]operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus], 0, len(affectedReplicaSets)) + for _, replicaSet := range affectedReplicaSets { + operator := NewOccupyDispatcherOperator(oc.spanController, replicaSet) + ret := oc.AddOperator(operator) + if ret { + operators = append(operators, operator) + } else { + log.Error("failed to add occupy dispatcher operator when restoring merge", + zap.Stringer("changefeedID", oc.changefeedID), + zap.Int64("group", replicaSet.GetGroupID()), + zap.String("span", common.FormatTableSpan(replicaSet.Span)), + zap.String("operator", operator.String())) + for _, op := range operators { + oc.cancelOperator(op.ID()) + } + return nil + } + } + + mergeOperator := NewRestoredMergeDispatcherOperator(oc.spanController, affectedReplicaSets, mergedReplicaSet, operators) + ret := oc.AddOperator(mergeOperator) + if !ret { + log.Error("failed to add merge dispatcher operator when restoring merge", + zap.Stringer("changefeedID", oc.changefeedID), + zap.Any("mergeSpans", affectedReplicaSets), + zap.String("operator", mergeOperator.String())) + for _, op := range operators { + oc.cancelOperator(op.ID()) + } + return nil + } + log.Info("restore merge operator", + zap.String("role", oc.role), + zap.Stringer("changefeedID", oc.changefeedID), + zap.Int("affectedReplicaSets", len(affectedReplicaSets)), + ) + return mergeOperator +} + func (oc *Controller) GetAllOperators() []operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus] { oc.mu.RLock() defer oc.mu.RUnlock() diff --git a/maintainer/operator/operator_merge.go b/maintainer/operator/operator_merge.go index 1c24e08f91..4499d43205 100644 --- a/maintainer/operator/operator_merge.go +++ b/maintainer/operator/operator_merge.go @@ -150,6 +150,34 @@ func NewMergeDispatcherOperator( return op } +func NewRestoredMergeDispatcherOperator( + spanController *span.Controller, + toMergedReplicaSets []*replica.SpanReplication, + mergedReplicaSet *replica.SpanReplication, + occupyOperators []operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus], +) *MergeDispatcherOperator { + toMergedSpans := make([]*heartbeatpb.TableSpan, 0, len(toMergedReplicaSets)) + for _, replicaSet := range toMergedReplicaSets { + toMergedSpans = append(toMergedSpans, replicaSet.Span) + } + + dispatcherIDs := buildDispatcherIDs(toMergedReplicaSets) + spansInfo := buildMergedSpanInfo(toMergedSpans) + + return &MergeDispatcherOperator{ + spanController: spanController, + originNode: toMergedReplicaSets[0].GetNodeID(), + id: mergedReplicaSet.ID, + dispatcherIDs: dispatcherIDs, + toMergedReplicaSets: toMergedReplicaSets, + checkpointTs: 0, + mergedSpanInfo: spansInfo, + occupyOperators: occupyOperators, + newReplicaSet: mergedReplicaSet, + sendThrottler: newSendThrottler(), + } +} + func setOccupyOperatorsFinished(occupyOperators []operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus]) { for _, occupyOperator := range occupyOperators { // occupyOperators are created by AddMergeOperator and are guaranteed to be OccupyDispatcherOperator. From b8473b1ac2520bcb20b8840f8f66b20b5d9f1216 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Tue, 23 Dec 2025 19:29:34 +0800 Subject: [PATCH 13/25] fix maintainer uts --- maintainer/maintainer_controller.go | 3 +++ maintainer/maintainer_manager_test.go | 4 ++++ maintainer/maintainer_test.go | 2 ++ 3 files changed, 9 insertions(+) diff --git a/maintainer/maintainer_controller.go b/maintainer/maintainer_controller.go index f543ff59c3..a76387664f 100644 --- a/maintainer/maintainer_controller.go +++ b/maintainer/maintainer_controller.go @@ -174,6 +174,9 @@ func (c *Controller) HandleStatus(from node.ID, statusList []*heartbeatpb.TableS spanController.UpdateStatus(stm, status) if status.ComponentStatus == heartbeatpb.ComponentState_Working && op == nil && !spanController.IsReplicating(stm) && stm.GetNodeID() != "" { + if spanController.IsDDLDispatcher(dispatcherID) { + continue + } spanController.MarkSpanReplicating(stm) } } diff --git a/maintainer/maintainer_manager_test.go b/maintainer/maintainer_manager_test.go index 92aeb255b9..9f0cd1480f 100644 --- a/maintainer/maintainer_manager_test.go +++ b/maintainer/maintainer_manager_test.go @@ -24,6 +24,7 @@ import ( "github.com/pingcap/kvproto/pkg/keyspacepb" "github.com/pingcap/log" "github.com/pingcap/ticdc/heartbeatpb" + "github.com/pingcap/ticdc/maintainer/testutil" "github.com/pingcap/ticdc/pkg/common" appcontext "github.com/pingcap/ticdc/pkg/common/context" commonEvent "github.com/pingcap/ticdc/pkg/common/event" @@ -64,6 +65,8 @@ func TestMaintainerSchedulesNodeChanges(t *testing.T) { ) mockPDClock := pdutil.NewClock4Test() appcontext.SetService(appcontext.DefaultPDClock, mockPDClock) + appcontext.SetService(appcontext.RegionCache, testutil.NewMockRegionCache()) + appcontext.SetService(appcontext.PDAPIClient, testutil.NewMockPDAPIClient()) appcontext.SetService(appcontext.SchemaStore, store) mc := messaging.NewMessageCenter(ctx, selfNode.ID, config.NewDefaultMessageCenterConfig(selfNode.AdvertiseAddr), nil) @@ -269,6 +272,7 @@ func TestMaintainerSchedulesNodeChanges(t *testing.T) { func TestMaintainerBootstrapWithTablesReported(t *testing.T) { ctx := context.Background() ctx, cancel := context.WithCancel(ctx) + testutil.SetUpTestServices() selfNode := node.NewInfo("127.0.0.1:18301", "") etcdClient := newMockEtcdClient(string(selfNode.ID)) nodeManager := watcher.NewNodeManager(nil, etcdClient) diff --git a/maintainer/maintainer_test.go b/maintainer/maintainer_test.go index 4598e6dafe..1d82b72c26 100644 --- a/maintainer/maintainer_test.go +++ b/maintainer/maintainer_test.go @@ -25,6 +25,7 @@ import ( "github.com/pingcap/log" "github.com/pingcap/ticdc/heartbeatpb" + "github.com/pingcap/ticdc/maintainer/testutil" "github.com/pingcap/ticdc/pkg/common" appcontext "github.com/pingcap/ticdc/pkg/common/context" commonEvent "github.com/pingcap/ticdc/pkg/common/event" @@ -256,6 +257,7 @@ func (m *mockDispatcherManager) sendHeartbeat() { func TestMaintainerSchedule(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) + testutil.SetUpTestServices() mux := http.NewServeMux() registry := prometheus.NewRegistry() metrics.InitMetrics(registry) From 8e3b14a1c784457268f6bd215d6b9e38eda3d841 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Wed, 11 Mar 2026 19:42:15 +0800 Subject: [PATCH 14/25] add test case --- tests/integration_tests/_utils/get_table_id | 3 +- .../conf/diff_config.toml | 2 +- .../maintainer_failover_when_operator/run.sh | 174 +++++++++++++++++- 3 files changed, 168 insertions(+), 11 deletions(-) diff --git a/tests/integration_tests/_utils/get_table_id b/tests/integration_tests/_utils/get_table_id index cf9a1a0363..a3177b367d 100755 --- a/tests/integration_tests/_utils/get_table_id +++ b/tests/integration_tests/_utils/get_table_id @@ -15,7 +15,8 @@ MAX_RETRIES=5 retries=0 while [ $retries -lt $MAX_RETRIES ]; do - id=$(curl http://127.0.0.1:10080/schema/"${dbName}"/"${tableName}" | jq .id) + # Follow the configured upstream status endpoint so tests can run against non-default local ports. + id=$(curl "http://${UP_TIDB_HOST:-127.0.0.1}:${UP_TIDB_STATUS:-10080}/schema/${dbName}/${tableName}" | jq .id) if [ -n "$id" ]; then echo $id exit 0 diff --git a/tests/integration_tests/maintainer_failover_when_operator/conf/diff_config.toml b/tests/integration_tests/maintainer_failover_when_operator/conf/diff_config.toml index 27d2d57567..7899ec9e3d 100644 --- a/tests/integration_tests/maintainer_failover_when_operator/conf/diff_config.toml +++ b/tests/integration_tests/maintainer_failover_when_operator/conf/diff_config.toml @@ -13,7 +13,7 @@ check-struct-only = false target-instance = "tidb0" - target-check-tables = ["maintainer_failover_when_operator.t1", "maintainer_failover_when_operator.t2", "maintainer_failover_when_operator.t4", "maintainer_failover_when_operator.t5"] + target-check-tables = ["maintainer_failover_when_operator.t1", "maintainer_failover_when_operator.t2", "maintainer_failover_when_operator.t4", "maintainer_failover_when_operator.t5", "maintainer_failover_when_operator.t6"] [data-sources] [data-sources.mysql1] diff --git a/tests/integration_tests/maintainer_failover_when_operator/run.sh b/tests/integration_tests/maintainer_failover_when_operator/run.sh index f71f72ca0b..63c6aac3e2 100755 --- a/tests/integration_tests/maintainer_failover_when_operator/run.sh +++ b/tests/integration_tests/maintainer_failover_when_operator/run.sh @@ -5,13 +5,14 @@ set -eu # This integration test verifies operator consistency across maintainer failover. # # What it validates: -# - Dispatcher managers persist "in-flight" scheduling requests (Create/Remove with an OperatorType). +# - Dispatcher managers persist "in-flight" scheduling requests (Create/Remove with an OperatorType) +# and merge requests. # - After the maintainer fails over, the new maintainer can restore these unfinished operators from # bootstrap responses and keep table scheduling converging instead of leaking or duplicating dispatchers. # # Main steps (per subcase): # 1) Start a 3-capture CDC cluster and create a changefeed. -# 2) Trigger Move / Split / Remove / Create operators and keep them in-progress using failpoints. +# 2) Trigger Move / Split / Remove / Create / Merge operators and keep them in-progress using failpoints. # 3) Kill the current maintainer capture to force a maintainer move. # 4) Disable failpoints and verify tables eventually converge (scheduled on a live capture, dropped table # stays dropped, and downstream data matches upstream via sync-diff). @@ -25,7 +26,25 @@ ROOT_WORK_DIR=$OUT_DIR/$TEST_NAME CDC_BINARY=cdc.test SINK_TYPE=$1 -CDC_ADDRS=("127.0.0.1:8300" "127.0.0.1:8301" "127.0.0.1:8302") +CDC_ADDRS_OVERRIDE=${CDC_ADDRS_OVERRIDE:-"127.0.0.1:8300 127.0.0.1:8301 127.0.0.1:8302"} +read -r -a CDC_ADDRS <<<"$CDC_ADDRS_OVERRIDE" +if [ "${#CDC_ADDRS[@]}" -ne 3 ]; then + echo "CDC_ADDRS_OVERRIDE must contain exactly 3 addresses" >&2 + exit 1 +fi +# Keep CLI-based helpers (changefeed create/query and move/split/merge operations) pointed at the same +# first capture when the case overrides the CDC addresses for isolated local reruns. +export CDC_HOST=${CDC_ADDRS[0]%:*} +export CDC_PORT=${CDC_ADDRS[0]#*:} +CDC_API_SERVER="http://${CDC_ADDRS[0]}" + +function cdc_cli_changefeed() { + command cdc_cli_changefeed "$@" --server "$CDC_API_SERVER" +} + +function run_cdc_cli() { + command run_cdc_cli "$@" --server "$CDC_API_SERVER" +} FAILPOINT_NOT_READY_TO_CLOSE_DISPATCHER="github.com/pingcap/ticdc/downstreamadapter/dispatcher/NotReadyToCloseDispatcher" FAILPOINT_BLOCK_CREATE_DISPATCHER="github.com/pingcap/ticdc/downstreamadapter/dispatchermanager/BlockCreateDispatcher" @@ -53,6 +72,83 @@ function get_table_replication_count() { jq -r --argjson tid "$table_id" '[.items[].table_ids[] | select(. == $tid)] | length' } +function wait_for_table_replication_count() { + local api_addr=$1 + local changefeed_id=$2 + local table_id=$3 + local target_count=$4 + local comparison_mode=$5 + local mode=$6 + local retry=${7:-30} + + for ((i = 0; i < retry; i++)); do + local count + count=$(get_table_replication_count "$api_addr" "$changefeed_id" "$table_id" "$mode") + if [ -n "$count" ] && [ "$count" != "null" ]; then + case "$comparison_mode" in + eq) + if [ "$count" -eq "$target_count" ]; then + echo "$count" + return 0 + fi + ;; + ge) + if [ "$count" -ge "$target_count" ]; then + echo "$count" + return 0 + fi + ;; + le) + if [ "$count" -le "$target_count" ]; then + echo "$count" + return 0 + fi + ;; + *) + echo "unknown comparison mode: $comparison_mode" >&2 + return 1 + ;; + esac + fi + sleep 2 + done + echo "table $table_id replication count did not satisfy $comparison_mode $target_count" >&2 + return 1 +} + +function wait_for_all_table_replications_on_addr() { + local api_addr=$1 + local changefeed_id=$2 + local table_id=$3 + local target_addr=$4 + local mode=$5 + local retry=${6:-30} + + for ((i = 0; i < retry; i++)); do + local target_id + target_id=$(get_capture_id_by_addr "$api_addr" "$target_addr") + if [ -z "$target_id" ] || [ "$target_id" == "null" ]; then + sleep 2 + continue + fi + + local resp + resp=$(curl -s "http://${api_addr}/api/v2/changefeeds/${changefeed_id}/tables?keyspace=$KEYSPACE_NAME&mode=$mode") + local total_count + total_count=$(echo "$resp" | jq -r --argjson tid "$table_id" '[.items[] | select(.table_ids | index($tid))] | length') + local target_count + target_count=$(echo "$resp" | jq -r --argjson tid "$table_id" --arg target "$target_id" '[.items[] | select((.table_ids | index($tid)) and .node_id == $target)] | length') + if [ "$total_count" != "null" ] && [ "$target_count" != "null" ] && + [ "$total_count" -gt 0 ] && [ "$total_count" -eq "$target_count" ]; then + echo "$target_count" + return 0 + fi + sleep 2 + done + echo "table $table_id still has replicas outside $target_addr" >&2 + return 1 +} + function get_maintainer_addr() { local api_addr=$1 local changefeed_id=$2 @@ -125,6 +221,20 @@ function wait_for_add_operator_inflight_in_logs() { return 1 } +function wait_for_restored_merge_operator_in_logs() { + local work_dir=$1 + local retry=$2 + + for ((i = 0; i < retry; i++)); do + if grep -qs "restore merge operator" "$work_dir"/cdc*.log 2>/dev/null; then + return 0 + fi + sleep 2 + done + echo "restored merge operator not observed in logs" >&2 + return 1 +} + function wait_for_maintainer_move() { local api_addr=$1 local changefeed_id=$2 @@ -223,8 +333,13 @@ function create_diff_config() { local work_dir=$1 local target_config_path=$2 - # update output-dir to point to current work directory to avoid collision between subcases. - sed "s|output-dir = \".*\"|output-dir = \"$work_dir/sync_diff/output\"|" "$CUR/conf/diff_config.toml" >"$target_config_path" + # Keep sync-diff aligned with the TiDB endpoints selected for this run, so isolated local reruns do not + # accidentally compare against another default-port cluster on the machine. + sed \ + -e "s|output-dir = \".*\"|output-dir = \"$work_dir/sync_diff/output\"|" \ + -e "/\\[data-sources.mysql1\\]/,/^$/{s/host = \".*\"/host = \"$UP_TIDB_HOST\"/; s/port = [0-9][0-9]*/port = $UP_TIDB_PORT/;}" \ + -e "/\\[data-sources.tidb0\\]/,/^$/{s/host = \".*\"/host = \"$DOWN_TIDB_HOST\"/; s/port = [0-9][0-9]*/port = $DOWN_TIDB_PORT/;}" \ + "$CUR/conf/diff_config.toml" >"$target_config_path" } function run_impl() { @@ -239,9 +354,11 @@ function run_impl() { # Disable balance scheduler to avoid unexpected auto split/move interfering with this test. export GO_FAILPOINTS='github.com/pingcap/ticdc/maintainer/scheduler/StopBalanceScheduler=return(true)' - run_cdc_server --workdir "$work_dir" --binary $CDC_BINARY --logsuffix 1 --addr "127.0.0.1:8300" - run_cdc_server --workdir "$work_dir" --binary $CDC_BINARY --logsuffix 2 --addr "127.0.0.1:8301" - run_cdc_server --workdir "$work_dir" --binary $CDC_BINARY --logsuffix 3 --addr "127.0.0.1:8302" + # Always pass the freshly started upstream PD explicitly so every capture joins the test cluster + # instead of silently falling back to the default 2379 endpoint during isolated local reruns. + run_cdc_server --workdir "$work_dir" --binary $CDC_BINARY --logsuffix 1 --addr "${CDC_ADDRS[0]}" --pd "$pd_addr" + run_cdc_server --workdir "$work_dir" --binary $CDC_BINARY --logsuffix 2 --addr "${CDC_ADDRS[1]}" --pd "$pd_addr" + run_cdc_server --workdir "$work_dir" --binary $CDC_BINARY --logsuffix 3 --addr "${CDC_ADDRS[2]}" --pd "$pd_addr" export GO_FAILPOINTS='' TOPIC_NAME="ticdc-move-table-maintainer-failover-$RANDOM" @@ -252,7 +369,7 @@ function run_impl() { run_pulsar_cluster "$work_dir" normal SINK_URI="pulsar://127.0.0.1:6650/$TOPIC_NAME?protocol=canal-json&enable-tidb-extension=true" ;; - *) SINK_URI="mysql://normal:123456@127.0.0.1:3306/?max-txn-row=1" ;; + *) SINK_URI="mysql://normal:123456@127.0.0.1:${DOWN_TIDB_PORT}/?max-txn-row=1" ;; esac changefeed_config="$work_dir/changefeed.toml" create_changefeed_config "$mode" "$work_dir" "$changefeed_config" @@ -267,17 +384,22 @@ function run_impl() { run_sql "CREATE TABLE maintainer_failover_when_operator.t1(id INT PRIMARY KEY, val VARCHAR(20));" ${UP_TIDB_HOST} ${UP_TIDB_PORT} # move run_sql "CREATE TABLE maintainer_failover_when_operator.t2(id INT PRIMARY KEY, val VARCHAR(20));" ${UP_TIDB_HOST} ${UP_TIDB_PORT} # split run_sql "CREATE TABLE maintainer_failover_when_operator.t3(id INT PRIMARY KEY, val VARCHAR(20));" ${UP_TIDB_HOST} ${UP_TIDB_PORT} # remove + run_sql "CREATE TABLE maintainer_failover_when_operator.t6(id INT PRIMARY KEY, val VARCHAR(20));" ${UP_TIDB_HOST} ${UP_TIDB_PORT} # merge run_sql "split table maintainer_failover_when_operator.t2 between (1) and (100000) regions 20;" ${UP_TIDB_HOST} ${UP_TIDB_PORT} + run_sql "split table maintainer_failover_when_operator.t6 between (1) and (100000) regions 20;" ${UP_TIDB_HOST} ${UP_TIDB_PORT} run_sql "INSERT INTO maintainer_failover_when_operator.t1 VALUES (1, 'a'), (2, 'b');" ${UP_TIDB_HOST} ${UP_TIDB_PORT} run_sql "INSERT INTO maintainer_failover_when_operator.t2 VALUES (1, 'a'), (2, 'b');" ${UP_TIDB_HOST} ${UP_TIDB_PORT} run_sql "INSERT INTO maintainer_failover_when_operator.t3 VALUES (1, 'a'), (2, 'b');" ${UP_TIDB_HOST} ${UP_TIDB_PORT} + run_sql "INSERT INTO maintainer_failover_when_operator.t6 VALUES (1, 'a'), (2, 'b');" ${UP_TIDB_HOST} ${UP_TIDB_PORT} check_table_exists "maintainer_failover_when_operator.t1" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 check_table_exists "maintainer_failover_when_operator.t2" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 check_table_exists "maintainer_failover_when_operator.t3" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 + check_table_exists "maintainer_failover_when_operator.t6" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 table_id_1=$(get_table_id "maintainer_failover_when_operator" "t1") table_id_2=$(get_table_id "maintainer_failover_when_operator" "t2") table_id_3=$(get_table_id "maintainer_failover_when_operator" "t3") + table_id_6=$(get_table_id "maintainer_failover_when_operator" "t6") api_addr=${CDC_ADDRS[0]} maintainer_addr=$(get_maintainer_addr "$api_addr" "$changefeed_id") @@ -297,9 +419,28 @@ function run_impl() { ensure_table_single_replication "$api_addr" "$changefeed_id" "$table_id_1" "$mode" ensure_table_single_replication "$api_addr" "$changefeed_id" "$table_id_2" "$mode" ensure_table_single_replication "$api_addr" "$changefeed_id" "$table_id_3" "$mode" + ensure_table_single_replication "$api_addr" "$changefeed_id" "$table_id_6" "$mode" ensure_table_on_addr "$api_addr" "$changefeed_id" "$table_id_1" "$origin_addr" "$mode" ensure_table_on_addr "$api_addr" "$changefeed_id" "$table_id_2" "$origin_addr" "$mode" ensure_table_on_addr "$api_addr" "$changefeed_id" "$table_id_3" "$origin_addr" "$mode" + ensure_table_on_addr "$api_addr" "$changefeed_id" "$table_id_6" "$origin_addr" "$mode" + + # Prepare a dedicated split table for the merge failover scenario. + # Steps: + # 1) Split the table into multiple replications. + # 2) Move all split dispatchers onto the surviving origin capture, so the merge request is persisted on a + # node that stays alive after the maintainer moves. + # 3) Record the replication count before issuing merge; a blocked merge should temporarily add one more + # merged dispatcher, and a successful restored merge should later reduce the count by one. + split_table_with_retry "$table_id_6" "$changefeed_id" 10 "$mode" + wait_for_table_replication_count "$api_addr" "$changefeed_id" "$table_id_6" 2 ge "$mode" 60 + move_split_table_with_retry "$origin_addr" "$table_id_6" "$changefeed_id" 10 "$mode" + wait_for_all_table_replications_on_addr "$api_addr" "$changefeed_id" "$table_id_6" "$origin_addr" "$mode" 60 + merge_replication_count_before=$(get_table_replication_count "$api_addr" "$changefeed_id" "$table_id_6" "$mode") + if [ -z "$merge_replication_count_before" ] || [ "$merge_replication_count_before" == "null" ] || [ "$merge_replication_count_before" -lt 2 ]; then + echo "table $table_id_6 does not have enough replications for merge, count=$merge_replication_count_before" >&2 + exit 1 + fi enable_failpoint --addr "$origin_addr" --name "$FAILPOINT_NOT_READY_TO_CLOSE_DISPATCHER" --expr "return(true)" enable_failpoint_on_all_addrs "$FAILPOINT_BLOCK_CREATE_DISPATCHER" "pause" @@ -337,6 +478,15 @@ function run_impl() { # failpoint is enabled on origin, so the table should not move to target wait_for_table_on_addr "$api_addr" "$changefeed_id" "$table_id_1" "$origin_addr" "$mode" + # Merge operator: issue merge against the dedicated split table while source dispatcher close is blocked. + # Once the merged dispatcher appears, the maintainer can be killed safely because the merge request has + # already reached dispatcher manager state and must be restored from bootstrap on failover. + set +e + merge_table_with_retry "$table_id_6" "$changefeed_id" 1 "$mode" & + merge_pid=$! + set -e + wait_for_table_replication_count "$api_addr" "$changefeed_id" "$table_id_6" "$((merge_replication_count_before + 1))" ge "$mode" 60 + # Remove operator: drop one table while dispatcher close is blocked. run_sql "DROP TABLE maintainer_failover_when_operator.t3;" ${UP_TIDB_HOST} ${UP_TIDB_PORT} @@ -353,8 +503,12 @@ function run_impl() { disable_failpoint --addr "$origin_addr" --name "$FAILPOINT_NOT_READY_TO_CLOSE_DISPATCHER" disable_failpoint_on_all_addrs_best_effort "$FAILPOINT_BLOCK_CREATE_DISPATCHER" + wait_for_restored_merge_operator_in_logs "$work_dir" 60 + wait_for_table_replication_count "$api_addr" "$changefeed_id" "$table_id_6" "$((merge_replication_count_before - 1))" eq "$mode" 60 + set +e wait "$split_pid" + wait "$merge_pid" set -e # After removing failpoints, the table should be scheduled eventually. @@ -364,6 +518,7 @@ function run_impl() { check_table_exists "maintainer_failover_when_operator.t4" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 check_table_exists "maintainer_failover_when_operator.t5" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 + check_table_exists "maintainer_failover_when_operator.t6" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 check_table_not_exists "maintainer_failover_when_operator.t3" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 run_sql "ALTER TABLE maintainer_failover_when_operator.t1 ADD COLUMN c2 INT DEFAULT 0;" ${UP_TIDB_HOST} ${UP_TIDB_PORT} @@ -372,6 +527,7 @@ function run_impl() { run_sql "INSERT INTO maintainer_failover_when_operator.t2 VALUES (3, 'c');" ${UP_TIDB_HOST} ${UP_TIDB_PORT} run_sql "INSERT INTO maintainer_failover_when_operator.t4 VALUES (3, 'c');" ${UP_TIDB_HOST} ${UP_TIDB_PORT} run_sql "INSERT INTO maintainer_failover_when_operator.t5 VALUES (3, 'c');" ${UP_TIDB_HOST} ${UP_TIDB_PORT} + run_sql "INSERT INTO maintainer_failover_when_operator.t6 VALUES (3, 'c');" ${UP_TIDB_HOST} ${UP_TIDB_PORT} diff_config="$work_dir/diff_config.toml" create_diff_config "$work_dir" "$diff_config" From e124c26d693e08f8b8104fffe1c6a70e2bb519e7 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Wed, 8 Apr 2026 18:17:46 +0800 Subject: [PATCH 15/25] maintainer: tolerate bootstrap overlap during merge --- maintainer/maintainer_controller_bootstrap.go | 36 +-- maintainer/maintainer_controller_test.go | 244 ++++++++++++++++++ 2 files changed, 262 insertions(+), 18 deletions(-) diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 9ef8f147d7..58765f525a 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -456,40 +456,40 @@ func addToWorkingTaskMap( tableSpans.ReplaceOrInsert(span, spanReplication) } -// findHoles returns an array of Span that are not covered in the range +// findHoles returns the uncovered sub-spans in totalSpan. +// +// Bootstrap snapshots can temporarily contain overlapping spans during in-flight merge recovery: +// for example, source dispatchers in WaitingMerge can coexist with a merged dispatcher in +// Preparing/Initializing. We therefore compute holes from the union of reported coverage instead +// of assuming the input spans are strictly non-overlapping. func findHoles(currentSpan utils.Map[*heartbeatpb.TableSpan, *replica.SpanReplication], totalSpan *heartbeatpb.TableSpan) []*heartbeatpb.TableSpan { - lastSpan := &heartbeatpb.TableSpan{ - TableID: totalSpan.TableID, - StartKey: totalSpan.StartKey, - EndKey: totalSpan.StartKey, - KeyspaceID: totalSpan.KeyspaceID, - } + coveredEnd := totalSpan.StartKey var holes []*heartbeatpb.TableSpan // table span is sorted currentSpan.Ascend(func(current *heartbeatpb.TableSpan, _ *replica.SpanReplication) bool { - ord := bytes.Compare(lastSpan.EndKey, current.StartKey) - if ord < 0 { + // Skip spans that are fully covered by earlier overlaps. This preserves complete table + // coverage without manufacturing holes for legitimate bootstrap overlap. + if bytes.Compare(current.EndKey, coveredEnd) <= 0 { + return true + } + if bytes.Compare(coveredEnd, current.StartKey) < 0 { // Find a hole. holes = append(holes, &heartbeatpb.TableSpan{ TableID: totalSpan.TableID, - StartKey: lastSpan.EndKey, + StartKey: coveredEnd, EndKey: current.StartKey, KeyspaceID: totalSpan.KeyspaceID, }) - } else if ord > 0 { - log.Panic("map is out of order", - zap.String("lastSpan", lastSpan.String()), - zap.String("current", current.String())) } - lastSpan = current + coveredEnd = current.EndKey return true }) // Check if there is a hole in the end. - // the lastSpan not reach the totalSpan end - if !bytes.Equal(lastSpan.EndKey, totalSpan.EndKey) { + // coveredEnd not reach the totalSpan end + if !bytes.Equal(coveredEnd, totalSpan.EndKey) { holes = append(holes, &heartbeatpb.TableSpan{ TableID: totalSpan.TableID, - StartKey: lastSpan.EndKey, + StartKey: coveredEnd, EndKey: totalSpan.EndKey, KeyspaceID: totalSpan.KeyspaceID, }) diff --git a/maintainer/maintainer_controller_test.go b/maintainer/maintainer_controller_test.go index 31a75342f5..f46c456a15 100644 --- a/maintainer/maintainer_controller_test.go +++ b/maintainer/maintainer_controller_test.go @@ -1537,6 +1537,242 @@ func TestFinishBootstrapSkipsStaleCreateOperatorForDroppedTable(t *testing.T) { } } +// TestFinishBootstrapRestoresInFlightMergeWithoutDuplicateCoverage covers maintainer failover in +// the middle of a merge. The bootstrap snapshot contains two source spans in WaitingMerge and the +// overlapping merged target span in Preparing. FinishBootstrap must not panic in findHoles or +// create a fresh absent table task; instead it should rebuild the merge-related tasks/operators +// from the bootstrap snapshot. +func TestFinishBootstrapRestoresInFlightMergeWithoutDuplicateCoverage(t *testing.T) { + testutil.SetUpTestServices(t) + nodeManager := appcontext.GetService[*watcher.NodeManager](watcher.NodeManagerName) + nodeManager.GetAliveNodes()["node1"] = &node.Info{ID: "node1"} + + tableTriggerEventDispatcherID := common.NewDispatcherID() + cfID := common.NewChangeFeedIDWithName("test", common.DefaultKeyspaceName) + ddlSpan := replica.NewWorkingSpanReplication(cfID, tableTriggerEventDispatcherID, + common.DDLSpanSchemaID, + common.KeyspaceDDLSpan(common.DefaultKeyspaceID), &heartbeatpb.TableSpanStatus{ + ID: tableTriggerEventDispatcherID.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Working, + CheckpointTs: 1, + }, "node1", false) + + cfg := config.GetDefaultReplicaConfig().Clone() + cfg.Scheduler = &config.ChangefeedSchedulerConfig{ + EnableTableAcrossNodes: util.AddressOf(true), + BalanceScoreThreshold: util.AddressOf(1), + MinTrafficPercentage: util.AddressOf(0.8), + MaxTrafficPercentage: util.AddressOf(1.2), + } + refresher := replica.NewRegionCountRefresher(cfID, time.Minute) + s := NewController(cfID, 1, &mockThreadPool{}, cfg, ddlSpan, nil, 1000, 0, refresher, common.DefaultKeyspace, false) + + schemaStore := eventservice.NewMockSchemaStore() + schemaStore.SetTables([]commonEvent.Table{ + { + TableID: 1, + SchemaID: 1, + Splitable: true, + SchemaTableName: &commonEvent.SchemaTableName{SchemaName: "test", TableName: "t1"}, + }, + }) + appcontext.SetService(appcontext.SchemaStore, schemaStore) + + totalSpan := common.TableIDToComparableSpan(common.DefaultKeyspaceID, 1) + midKey := appendNew(totalSpan.StartKey, 'a') + sourceSpan1 := &heartbeatpb.TableSpan{ + TableID: 1, + StartKey: totalSpan.StartKey, + EndKey: midKey, + KeyspaceID: common.DefaultKeyspaceID, + } + sourceSpan2 := &heartbeatpb.TableSpan{ + TableID: 1, + StartKey: midKey, + EndKey: totalSpan.EndKey, + KeyspaceID: common.DefaultKeyspaceID, + } + mergedSpan := &heartbeatpb.TableSpan{ + TableID: 1, + StartKey: totalSpan.StartKey, + EndKey: totalSpan.EndKey, + KeyspaceID: common.DefaultKeyspaceID, + } + + sourceDispatcherID1 := common.NewDispatcherID() + sourceDispatcherID2 := common.NewDispatcherID() + mergedDispatcherID := common.NewDispatcherID() + + _, err := s.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ + "node1": { + ChangefeedID: cfID.ToPB(), + Spans: []*heartbeatpb.BootstrapTableSpan{ + { + ID: sourceDispatcherID1.ToPB(), + SchemaID: 1, + Span: sourceSpan1, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: sourceDispatcherID2.ToPB(), + SchemaID: 1, + Span: sourceSpan2, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: mergedDispatcherID.ToPB(), + SchemaID: 1, + Span: mergedSpan, + ComponentStatus: heartbeatpb.ComponentState_Preparing, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }, + MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ + { + ChangefeedID: cfID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{sourceDispatcherID1.ToPB(), sourceDispatcherID2.ToPB()}, + MergedDispatcherID: mergedDispatcherID.ToPB(), + Mode: common.DefaultMode, + }, + }, + CheckpointTs: 10, + }, + }, false) + require.NoError(t, err) + require.True(t, s.bootstrapped) + + // No extra absent table span should be created during bootstrap; only the two source spans and + // the restored merged target should exist. + require.Zero(t, s.spanController.GetAbsentSize()) + require.Equal(t, 3, len(s.spanController.GetTasksByTableID(1))) + require.Equal(t, 3, s.spanController.GetSchedulingSize()) + require.Zero(t, s.spanController.GetReplicatingSize()) + require.NotNil(t, s.spanController.GetTaskByID(sourceDispatcherID1)) + require.NotNil(t, s.spanController.GetTaskByID(sourceDispatcherID2)) + require.NotNil(t, s.spanController.GetTaskByID(mergedDispatcherID)) + + mergeOp := s.operatorController.GetOperator(mergedDispatcherID) + require.NotNil(t, mergeOp) + _, ok := mergeOp.(*operator.MergeDispatcherOperator) + require.True(t, ok) +} + +// TestFinishBootstrapKeepsOverlapCoveredAfterMergeJournalCleanup covers a later merge-recovery +// window where dispatcher manager has already committed the merged dispatcher and dropped the merge +// journal, but the old source dispatchers are still waiting to be cleaned up. Bootstrap must still +// treat the overlapping spans as complete coverage and avoid creating absent hole tasks. +func TestFinishBootstrapKeepsOverlapCoveredAfterMergeJournalCleanup(t *testing.T) { + testutil.SetUpTestServices(t) + nodeManager := appcontext.GetService[*watcher.NodeManager](watcher.NodeManagerName) + nodeManager.GetAliveNodes()["node1"] = &node.Info{ID: "node1"} + + tableTriggerEventDispatcherID := common.NewDispatcherID() + cfID := common.NewChangeFeedIDWithName("test", common.DefaultKeyspaceName) + ddlSpan := replica.NewWorkingSpanReplication(cfID, tableTriggerEventDispatcherID, + common.DDLSpanSchemaID, + common.KeyspaceDDLSpan(common.DefaultKeyspaceID), &heartbeatpb.TableSpanStatus{ + ID: tableTriggerEventDispatcherID.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Working, + CheckpointTs: 1, + }, "node1", false) + + cfg := config.GetDefaultReplicaConfig().Clone() + cfg.Scheduler = &config.ChangefeedSchedulerConfig{ + EnableTableAcrossNodes: util.AddressOf(true), + BalanceScoreThreshold: util.AddressOf(1), + MinTrafficPercentage: util.AddressOf(0.8), + MaxTrafficPercentage: util.AddressOf(1.2), + } + refresher := replica.NewRegionCountRefresher(cfID, time.Minute) + s := NewController(cfID, 1, &mockThreadPool{}, cfg, ddlSpan, nil, 1000, 0, refresher, common.DefaultKeyspace, false) + + schemaStore := eventservice.NewMockSchemaStore() + schemaStore.SetTables([]commonEvent.Table{ + { + TableID: 1, + SchemaID: 1, + Splitable: true, + SchemaTableName: &commonEvent.SchemaTableName{SchemaName: "test", TableName: "t1"}, + }, + }) + appcontext.SetService(appcontext.SchemaStore, schemaStore) + + totalSpan := common.TableIDToComparableSpan(common.DefaultKeyspaceID, 1) + midKey := appendNew(totalSpan.StartKey, 'a') + sourceSpan1 := &heartbeatpb.TableSpan{ + TableID: 1, + StartKey: totalSpan.StartKey, + EndKey: midKey, + KeyspaceID: common.DefaultKeyspaceID, + } + sourceSpan2 := &heartbeatpb.TableSpan{ + TableID: 1, + StartKey: midKey, + EndKey: totalSpan.EndKey, + KeyspaceID: common.DefaultKeyspaceID, + } + mergedSpan := &heartbeatpb.TableSpan{ + TableID: 1, + StartKey: totalSpan.StartKey, + EndKey: totalSpan.EndKey, + KeyspaceID: common.DefaultKeyspaceID, + } + + sourceDispatcherID1 := common.NewDispatcherID() + sourceDispatcherID2 := common.NewDispatcherID() + mergedDispatcherID := common.NewDispatcherID() + + // Scenario: + // 1. Source dispatchers are already in WaitingMerge and still present in bootstrap spans. + // 2. The merged dispatcher is committed and visible as Initializing. + // 3. The persisted merge operator is already gone, so bootstrap only has overlapping coverage. + // Expectation: FinishBootstrap succeeds without adding absent spans for fake holes. + _, err := s.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ + "node1": { + ChangefeedID: cfID.ToPB(), + Spans: []*heartbeatpb.BootstrapTableSpan{ + { + ID: sourceDispatcherID1.ToPB(), + SchemaID: 1, + Span: sourceSpan1, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: sourceDispatcherID2.ToPB(), + SchemaID: 1, + Span: sourceSpan2, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: mergedDispatcherID.ToPB(), + SchemaID: 1, + Span: mergedSpan, + ComponentStatus: heartbeatpb.ComponentState_Initializing, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }, + CheckpointTs: 10, + }, + }, false) + require.NoError(t, err) + require.True(t, s.bootstrapped) + require.Zero(t, s.spanController.GetAbsentSize()) + require.GreaterOrEqual(t, len(s.spanController.GetTasksByTableID(1)), 2) + require.GreaterOrEqual(t, s.spanController.GetReplicatingSize(), 2) + require.Zero(t, s.spanController.GetSchedulingSize()) + require.NotNil(t, s.spanController.GetTaskByID(mergedDispatcherID)) +} + func TestSplitTableWhenBootstrapFinished(t *testing.T) { testutil.SetUpTestServices(t) nodeManager := appcontext.GetService[*watcher.NodeManager](watcher.NodeManagerName) @@ -1682,6 +1918,14 @@ func TestMapFindHole(t *testing.T) { {StartKey: []byte("t1_1"), EndKey: []byte("t2_0")}, }, }, + { // 6. overlapping spans still cover the whole range. + spans: []*heartbeatpb.TableSpan{ + {StartKey: []byte("t1_0"), EndKey: []byte("t1_1")}, + {StartKey: []byte("t1_0"), EndKey: []byte("t2_0")}, + {StartKey: []byte("t1_1"), EndKey: []byte("t2_0")}, + }, + rang: &heartbeatpb.TableSpan{StartKey: []byte("t1_0"), EndKey: []byte("t2_0")}, + }, } for i, cs := range cases { From d900f8d6d35ced7f33dab7807f77c2d6a99174ba Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Wed, 17 Jun 2026 10:50:42 +0800 Subject: [PATCH 16/25] maintainer,downstreamadapter: fix merge failover recovery --- .../dispatchermanager/dispatcher_manager.go | 1 + .../dispatcher_manager_merge.go | 96 ++++++-- .../dispatcher_manager_test.go | 54 +++++ downstreamadapter/dispatchermanager/task.go | 1 - maintainer/maintainer_controller.go | 36 +++ maintainer/maintainer_controller_bootstrap.go | 31 ++- maintainer/maintainer_controller_test.go | 210 ++++++++++++++++++ 7 files changed, 402 insertions(+), 27 deletions(-) diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager.go b/downstreamadapter/dispatchermanager/dispatcher_manager.go index 5442b91aa0..08167fbae7 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager.go @@ -933,6 +933,7 @@ func (e *DispatcherManager) aggregateDispatcherHeartbeats(needCompleteStatus boo } } } + e.cleanupFinishedMergeOperators() e.metricCheckpointTs.Set(float64(message.Watermark.CheckpointTs)) e.metricResolvedTs.Set(float64(message.Watermark.ResolvedTs)) diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go b/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go index f801e684c5..5d41279ffe 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go @@ -15,6 +15,7 @@ package dispatchermanager import ( "github.com/pingcap/log" + "github.com/pingcap/ticdc/downstreamadapter/dispatcher" "github.com/pingcap/ticdc/heartbeatpb" "github.com/pingcap/ticdc/pkg/common" "go.uber.org/zap" @@ -29,7 +30,7 @@ func (e *DispatcherManager) TrackMergeOperator(req *heartbeatpb.MergeDispatcherR e.mergeOperatorMap.Store(mergedID.String(), cloneMergeDispatcherRequest(req)) } -// RemoveMergeOperator drops the persisted merge request once the merged dispatcher has converged. +// RemoveMergeOperator drops a persisted merge request that no longer needs bootstrap recovery. func (e *DispatcherManager) RemoveMergeOperator(mergedDispatcherID common.DispatcherID) { e.mergeOperatorMap.Delete(mergedDispatcherID.String()) } @@ -40,20 +41,12 @@ func (e *DispatcherManager) MaybeCleanupMergeOperator(req *heartbeatpb.MergeDisp 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 - } + if e.isMergeOperatorFinished(req) { + e.RemoveMergeOperator(mergedID) + return + } + if e.hasMergedDispatcher(req) { + return } log.Info("cleanup merge operator because merged dispatcher not found", zap.Stringer("changefeedID", e.changefeedID), @@ -62,6 +55,79 @@ func (e *DispatcherManager) MaybeCleanupMergeOperator(req *heartbeatpb.MergeDisp e.RemoveMergeOperator(mergedID) } +func (e *DispatcherManager) cleanupFinishedMergeOperators() { + e.mergeOperatorMap.Range(func(_, value any) bool { + req, ok := value.(*heartbeatpb.MergeDispatcherRequest) + if !ok || req == nil || req.MergedDispatcherID == nil { + return true + } + if !e.isMergeOperatorFinished(req) { + return true + } + mergedID := common.NewDispatcherIDFromPB(req.MergedDispatcherID) + log.Info("cleanup finished merge operator", + zap.Stringer("changefeedID", e.changefeedID), + zap.String("dispatcherID", mergedID.String()), + zap.Int64("mode", req.Mode)) + e.RemoveMergeOperator(mergedID) + return true + }) +} + +func (e *DispatcherManager) isMergeOperatorFinished(req *heartbeatpb.MergeDispatcherRequest) bool { + if req == nil || req.MergedDispatcherID == nil || len(req.DispatcherIDs) < 2 { + return true + } + if common.IsRedoMode(req.Mode) { + if !e.IsRedoReady() { + return false + } + return isMergeOperatorFinished(req, e.redoDispatcherMap) + } + return isMergeOperatorFinished(req, e.dispatcherMap) +} + +func isMergeOperatorFinished[T dispatcher.Dispatcher]( + req *heartbeatpb.MergeDispatcherRequest, + dispatcherMap *DispatcherMap[T], +) bool { + for _, idPB := range req.DispatcherIDs { + if idPB == nil { + continue + } + dispatcherID := common.NewDispatcherIDFromPB(idPB) + if _, ok := dispatcherMap.Get(dispatcherID); ok { + // Keep the merge journal while any source dispatcher still exists. A maintainer failover + // in this window must restore the merge intent so late source terminal statuses do not + // recreate spans that are already covered by the merged dispatcher. + return false + } + } + + mergedID := common.NewDispatcherIDFromPB(req.MergedDispatcherID) + mergedDispatcher, ok := dispatcherMap.Get(mergedID) + if !ok { + return true + } + return mergedDispatcher.GetComponentStatus() == heartbeatpb.ComponentState_Working +} + +func (e *DispatcherManager) hasMergedDispatcher(req *heartbeatpb.MergeDispatcherRequest) bool { + if req == nil || req.MergedDispatcherID == nil { + return false + } + mergedID := common.NewDispatcherIDFromPB(req.MergedDispatcherID) + if common.IsRedoMode(req.Mode) { + if !e.IsRedoReady() { + return false + } + _, ok := e.redoDispatcherMap.Get(mergedID) + return ok + } + _, ok := e.dispatcherMap.Get(mergedID) + return ok +} + // GetMergeOperators returns cloned in-flight merge requests for maintainer bootstrap. func (e *DispatcherManager) GetMergeOperators() []*heartbeatpb.MergeDispatcherRequest { operators := make([]*heartbeatpb.MergeDispatcherRequest, 0) diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go index 0d0897ab0e..4ac5160070 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go @@ -976,6 +976,60 @@ func TestDoMerge(t *testing.T) { require.False(t, exists) } +// TestDoMergeKeepsMergeJournalUntilSourcesAreCleaned covers maintainer failover between merged +// dispatcher commit and source dispatcher cleanup. The test tracks a merge request, runs doMerge, +// verifies the journal is still reported while sources are being removed, then marks the merged +// dispatcher Working and expects heartbeat cleanup to drop the finished journal. +func TestDoMergeKeepsMergeJournalUntilSourcesAreCleaned(t *testing.T) { + manager := createTestManager(t) + + dispatcher1 := createTestDispatcher(t, manager, + common.NewDispatcherID(), + 1, + []byte("a"), + []byte("m"), + ) + dispatcher2 := createTestDispatcher(t, manager, + common.NewDispatcherID(), + 1, + []byte("m"), + []byte("z"), + ) + + manager.dispatcherMap.Set(dispatcher1.GetId(), dispatcher1) + manager.dispatcherMap.Set(dispatcher2.GetId(), dispatcher2) + + mergedID := common.NewDispatcherID() + mergeReq := &heartbeatpb.MergeDispatcherRequest{ + ChangefeedID: manager.changefeedID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{dispatcher1.GetId().ToPB(), dispatcher2.GetId().ToPB()}, + MergedDispatcherID: mergedID.ToPB(), + Mode: common.DefaultMode, + } + manager.TrackMergeOperator(mergeReq) + task := manager.mergeEventDispatcher([]common.DispatcherID{ + dispatcher1.GetId(), + dispatcher2.GetId(), + }, mergedID) + require.NotNil(t, task) + + doMerge(task, task.manager.dispatcherMap) + require.Len(t, manager.GetMergeOperators(), 1) + + manager.aggregateDispatcherHeartbeats(false) + require.Len(t, manager.GetMergeOperators(), 1) + _, exists := manager.dispatcherMap.Get(dispatcher1.GetId()) + require.False(t, exists) + _, exists = manager.dispatcherMap.Get(dispatcher2.GetId()) + require.False(t, exists) + + mergedDispatcher, exists := manager.dispatcherMap.Get(mergedID) + require.True(t, exists) + mergedDispatcher.SetComponentStatus(heartbeatpb.ComponentState_Working) + manager.aggregateDispatcherHeartbeats(false) + require.Empty(t, manager.GetMergeOperators()) +} + func TestDoMergeWithThreeDispatchers(t *testing.T) { manager := createTestManager(t) diff --git a/downstreamadapter/dispatchermanager/task.go b/downstreamadapter/dispatchermanager/task.go index 4afad60c56..2d2ec92a29 100644 --- a/downstreamadapter/dispatchermanager/task.go +++ b/downstreamadapter/dispatchermanager/task.go @@ -307,7 +307,6 @@ func doMerge[T dispatcher.Dispatcher](t *MergeCheckTask, dispatcherMap *Dispatch } dispatcher.Remove() } - t.manager.RemoveMergeOperator(t.mergedDispatcher.GetId()) } type mergedStartTsCandidate struct { diff --git a/maintainer/maintainer_controller.go b/maintainer/maintainer_controller.go index f084bf619d..02ba30e341 100644 --- a/maintainer/maintainer_controller.go +++ b/maintainer/maintainer_controller.go @@ -14,6 +14,7 @@ package maintainer import ( + "bytes" "sync" "time" @@ -248,6 +249,9 @@ func (c *Controller) handleStatus(from node.ID, statusList []*heartbeatpb.TableS if status.ComponentStatus == heartbeatpb.ComponentState_Stopped || status.ComponentStatus == heartbeatpb.ComponentState_Removed { if op := operatorController.GetOperator(dispatcherID); op == nil { + if c.removeTerminalSpanCoveredByMergedSpan(spanController, stm) { + continue + } log.Warn("dispatcher becomes non-working without operator, mark span absent for rescheduling", zap.String("changefeed", c.changefeedID.Name()), zap.String("from", from.String()), @@ -259,6 +263,38 @@ func (c *Controller) handleStatus(from node.ID, statusList []*heartbeatpb.TableS } } +func (c *Controller) removeTerminalSpanCoveredByMergedSpan( + spanController *span.Controller, + stm *replica.SpanReplication, +) bool { + if stm == nil || stm.Span == nil { + return false + } + for _, candidate := range spanController.GetTasksByTableID(stm.Span.TableID) { + if candidate == nil || candidate == stm || candidate.ID == stm.ID || candidate.Span == nil { + continue + } + if candidate.GetMode() != stm.GetMode() || !spanController.IsReplicating(candidate) { + continue + } + if bytes.Compare(candidate.Span.StartKey, stm.Span.StartKey) <= 0 && + bytes.Compare(candidate.Span.EndKey, stm.Span.EndKey) >= 0 { + // A successful merge can leave old source dispatchers reporting terminal statuses after + // maintainer failover. When the merged span already covers the source range, the source + // is obsolete desired state and must be removed instead of being marked absent. + log.Info("remove terminal span covered by merged span", + zap.String("changefeed", c.changefeedID.Name()), + zap.String("dispatcherID", stm.ID.String()), + zap.String("coveringDispatcherID", candidate.ID.String()), + zap.String("span", common.FormatTableSpan(stm.Span)), + zap.String("coveringSpan", common.FormatTableSpan(candidate.Span))) + spanController.RemoveReplicatingSpan(stm) + return true + } + } + return false +} + func (c *Controller) GetMinCheckpointTs(minCheckpointTs uint64) uint64 { minCheckpointTsForOperator := c.operatorController.GetMinCheckpointTs(minCheckpointTs) minCheckpointTsForSpan := c.spanController.GetMinCheckpointTsForNonReplicatingSpans(minCheckpointTs) diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index da557e25a4..14a7e26af8 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -1013,23 +1013,32 @@ func (c *Controller) restoreCurrentMergeOperators( zap.String("nodeID", nodeID.String()), zap.String("changefeed", resp.ChangefeedID.String()), zap.String("dispatcher", mergedDispatcherID.String())) - for _, replicaSet := range sourceReplicaSets { - spanController.MarkSpanScheduling(replicaSet) - } if mergedSpanInfo != nil { if mergedReplicaSet == nil { splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[mergedSpanInfo.Span.TableID]) mergedReplicaSet = c.createSpanReplication(mergedSpanInfo, nodeID, splitEnabled) - if mergedSpanInfo.ComponentStatus == heartbeatpb.ComponentState_Working { - spanController.AddReplicatingSpan(mergedReplicaSet) - } else { - spanController.AddSchedulingReplicaSet(mergedReplicaSet, nodeID) - } - } else if mergedSpanInfo.ComponentStatus == heartbeatpb.ComponentState_Working { - spanController.MarkSpanReplicating(mergedReplicaSet) + spanController.AddReplicatingSpan(mergedReplicaSet) } else { - spanController.MarkSpanScheduling(mergedReplicaSet) + spanController.MarkSpanReplicating(mergedReplicaSet) } + // If any source dispatcher is already missing, the dispatcher manager has moved past + // the reversible part of merge cleanup. Keep the existing merged dispatcher as the + // desired span and drop leftover source spans so their late terminal statuses are ignored. + for _, replicaSet := range sourceReplicaSets { + if replicaSet.ID == mergedReplicaSet.ID { + continue + } + spanController.RemoveReplicatingSpan(replicaSet) + } + log.Info("continue merge from existing merged dispatcher after source loss", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", mergedDispatcherID.String()), + zap.Any("status", mergedSpanInfo.ComponentStatus)) + continue + } + for _, replicaSet := range sourceReplicaSets { + spanController.MarkSpanScheduling(replicaSet) } continue } diff --git a/maintainer/maintainer_controller_test.go b/maintainer/maintainer_controller_test.go index 798bc3a2ec..2c9b350a7e 100644 --- a/maintainer/maintainer_controller_test.go +++ b/maintainer/maintainer_controller_test.go @@ -1808,6 +1808,216 @@ func TestFinishBootstrapKeepsOverlapCoveredAfterMergeJournalCleanup(t *testing.T require.NotNil(t, s.spanController.GetTaskByID(mergedDispatcherID)) } +type mergeBootstrapTestEnv struct { + controller *Controller + cfID common.ChangeFeedID + sourceSpan1 *heartbeatpb.TableSpan + sourceSpan2 *heartbeatpb.TableSpan + mergedSpan *heartbeatpb.TableSpan + sourceDispatcherID1 common.DispatcherID + sourceDispatcherID2 common.DispatcherID + mergedDispatcherID common.DispatcherID +} + +func newMergeBootstrapTestEnv(t *testing.T) *mergeBootstrapTestEnv { + t.Helper() + + testutil.SetUpTestServices(t) + nodeManager := appcontext.GetService[*watcher.NodeManager](watcher.NodeManagerName) + nodeManager.GetAliveNodes()["node1"] = &node.Info{ID: "node1"} + + tableTriggerEventDispatcherID := common.NewDispatcherID() + cfID := common.NewChangeFeedIDWithName("test", common.DefaultKeyspaceName) + ddlSpan := replica.NewWorkingSpanReplication(cfID, tableTriggerEventDispatcherID, + common.DDLSpanSchemaID, + common.KeyspaceDDLSpan(common.DefaultKeyspaceID), &heartbeatpb.TableSpanStatus{ + ID: tableTriggerEventDispatcherID.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Working, + CheckpointTs: 1, + }, "node1", false) + + cfg := config.GetDefaultReplicaConfig().Clone() + cfg.Scheduler = &config.ChangefeedSchedulerConfig{ + EnableTableAcrossNodes: util.AddressOf(true), + BalanceScoreThreshold: util.AddressOf(1), + MinTrafficPercentage: util.AddressOf(0.8), + MaxTrafficPercentage: util.AddressOf(1.2), + } + refresher := replica.NewRegionCountRefresher(cfID, time.Minute) + controller := NewController(cfID, 1, &mockThreadPool{}, cfg, ddlSpan, nil, 1000, 0, refresher, common.DefaultKeyspace, false, testBalanceMoveBatchSize) + + schemaStore := eventservice.NewMockSchemaStore() + schemaStore.SetTables([]commonEvent.Table{ + { + TableID: 1, + SchemaID: 1, + Splitable: true, + SchemaTableName: &commonEvent.SchemaTableName{SchemaName: "test", TableName: "t1"}, + }, + }) + appcontext.SetService(appcontext.SchemaStore, schemaStore) + + totalSpan := common.TableIDToComparableSpan(common.DefaultKeyspaceID, 1) + midKey := appendNew(totalSpan.StartKey, 'a') + return &mergeBootstrapTestEnv{ + controller: controller, + cfID: cfID, + sourceSpan1: &heartbeatpb.TableSpan{ + TableID: 1, + StartKey: totalSpan.StartKey, + EndKey: midKey, + KeyspaceID: common.DefaultKeyspaceID, + }, + sourceSpan2: &heartbeatpb.TableSpan{ + TableID: 1, + StartKey: midKey, + EndKey: totalSpan.EndKey, + KeyspaceID: common.DefaultKeyspaceID, + }, + mergedSpan: &heartbeatpb.TableSpan{ + TableID: 1, + StartKey: totalSpan.StartKey, + EndKey: totalSpan.EndKey, + KeyspaceID: common.DefaultKeyspaceID, + }, + sourceDispatcherID1: common.NewDispatcherID(), + sourceDispatcherID2: common.NewDispatcherID(), + mergedDispatcherID: common.NewDispatcherID(), + } +} + +// TestHandleStatusDropsTerminalSourcesCoveredByMergedSpanAfterJournalCleanup covers the post-bootstrap +// merge cleanup window where source dispatchers still report terminal statuses after the merge journal +// is gone. The test bootstraps overlapping source and merged spans, then sends terminal source +// heartbeats and expects the obsolete sources to be removed instead of rescheduled as absent spans. +func TestHandleStatusDropsTerminalSourcesCoveredByMergedSpanAfterJournalCleanup(t *testing.T) { + env := newMergeBootstrapTestEnv(t) + + _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ + "node1": { + ChangefeedID: env.cfID.ToPB(), + Spans: []*heartbeatpb.BootstrapTableSpan{ + { + ID: env.sourceDispatcherID1.ToPB(), + SchemaID: 1, + Span: env.sourceSpan1, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: env.sourceDispatcherID2.ToPB(), + SchemaID: 1, + Span: env.sourceSpan2, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: env.mergedDispatcherID.ToPB(), + SchemaID: 1, + Span: env.mergedSpan, + ComponentStatus: heartbeatpb.ComponentState_Initializing, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }, + CheckpointTs: 10, + }, + }, false) + require.NoError(t, err) + + env.controller.HandleStatus("node1", []*heartbeatpb.TableSpanStatus{ + { + ID: env.sourceDispatcherID1.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Stopped, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: env.sourceDispatcherID2.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Removed, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }) + + require.Zero(t, env.controller.spanController.GetAbsentSize()) + require.Zero(t, env.controller.spanController.GetSchedulingSize()) + require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) + require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID2)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) + require.Len(t, env.controller.spanController.GetTasksByTableID(1), 1) +} + +// TestFinishBootstrapContinuesFromMergedDispatcherWhenMergeSourceMissing covers failover after one +// source dispatcher has already been cleaned up but the persisted merge request is still reported. +// Bootstrap should keep the existing merged dispatcher as the desired span, drop any leftover source +// span, and allow a later Working heartbeat to move normally without an add operator. +func TestFinishBootstrapContinuesFromMergedDispatcherWhenMergeSourceMissing(t *testing.T) { + env := newMergeBootstrapTestEnv(t) + + _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ + "node1": { + ChangefeedID: env.cfID.ToPB(), + Spans: []*heartbeatpb.BootstrapTableSpan{ + { + ID: env.sourceDispatcherID1.ToPB(), + SchemaID: 1, + Span: env.sourceSpan1, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: env.mergedDispatcherID.ToPB(), + SchemaID: 1, + Span: env.mergedSpan, + ComponentStatus: heartbeatpb.ComponentState_Initializing, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }, + MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ + { + ChangefeedID: env.cfID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{ + env.sourceDispatcherID1.ToPB(), + env.sourceDispatcherID2.ToPB(), + }, + MergedDispatcherID: env.mergedDispatcherID.ToPB(), + Mode: common.DefaultMode, + }, + }, + CheckpointTs: 10, + }, + }, false) + require.NoError(t, err) + require.True(t, env.controller.bootstrapped) + require.Zero(t, env.controller.operatorController.OperatorSize()) + require.Zero(t, env.controller.spanController.GetAbsentSize()) + require.Zero(t, env.controller.spanController.GetSchedulingSize()) + require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) + require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID2)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) + + env.controller.HandleStatus("node1", []*heartbeatpb.TableSpanStatus{ + { + ID: env.mergedDispatcherID.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Working, + CheckpointTs: 20, + Mode: common.DefaultMode, + }, + }) + mergedReplicaSet := env.controller.spanController.GetTaskByID(env.mergedDispatcherID) + require.NotNil(t, mergedReplicaSet) + require.Equal(t, heartbeatpb.ComponentState_Working, mergedReplicaSet.GetStatus().ComponentStatus) + require.Zero(t, env.controller.spanController.GetSchedulingSize()) + require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) +} + func TestSplitTableWhenBootstrapFinished(t *testing.T) { testutil.SetUpTestServices(t) nodeManager := appcontext.GetService[*watcher.NodeManager](watcher.NodeManagerName) From 10dfb3139e7946510551585b3d26043cb918170b Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Wed, 17 Jun 2026 13:52:49 +0800 Subject: [PATCH 17/25] maintainer: skip stale merge bootstrap journals --- maintainer/maintainer_controller_bootstrap.go | 117 ++++++++++++++++-- maintainer/maintainer_controller_test.go | 110 ++++++++++++++++ 2 files changed, 220 insertions(+), 7 deletions(-) diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 9598df015c..5662669ed2 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -137,7 +137,13 @@ func (c *Controller) FinishBootstrap( // Restore merge operators after task state is rebuilt from bootstrap spans/operators. // Merge restoration needs the per-dispatcher task map from buildTaskInfo, but must run // before we discard any leftover working tasks as dropped-table artifacts. - if err := c.restoreCurrentMergeOperators(allNodesResp, buildTableSplitMap(tables)); err != nil { + mergeTableSplitMaps := map[int64]map[int64]bool{ + common.DefaultMode: buildTableSplitMap(tables), + } + if c.enableRedo { + mergeTableSplitMaps[common.RedoMode] = buildTableSplitMap(redoTables) + } + if err := c.restoreCurrentMergeOperators(allNodesResp, mergeTableSplitMaps); err != nil { return nil, errors.Trace(err) } @@ -940,7 +946,7 @@ func (c *Controller) handleCurrentWorkingRemove( // remaining stuck in scheduling state or leaking an incomplete merged dispatcher. func (c *Controller) restoreCurrentMergeOperators( allNodesResp map[node.ID]*heartbeatpb.MaintainerBootstrapResponse, - tableSplitMap map[int64]bool, + tableSplitMaps map[int64]map[int64]bool, ) error { for nodeID, resp := range allNodesResp { if len(resp.MergeOperators) == 0 { @@ -958,13 +964,35 @@ func (c *Controller) restoreCurrentMergeOperators( continue } + tableSplitMap, ok := tableSplitMapForMode(mergeReq.Mode, tableSplitMaps) + if !ok { + log.Warn("skip restoring merge operator due to unavailable mode", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.Int64("mode", mergeReq.Mode)) + continue + } spanController := c.getSpanController(mergeReq.Mode) operatorController := c.getOperatorController(mergeReq.Mode) + if spanController == nil || operatorController == nil { + log.Warn("skip restoring merge operator due to uninitialized controller", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.Int64("mode", mergeReq.Mode)) + continue + } spanInfoByID := indexBootstrapSpans(resp.Spans, mergeReq.Mode) mergedDispatcherID := common.NewDispatcherIDFromPB(mergeReq.MergedDispatcherID) sourceReplicaSets := make([]*replica.SpanReplication, 0, len(mergeReq.DispatcherIDs)) + createdSourceReplicaSets := make([]*replica.SpanReplication, 0, len(mergeReq.DispatcherIDs)) + cleanupCreatedSourceReplicaSets := func() { + for _, replicaSet := range createdSourceReplicaSets { + spanController.RemoveReplicatingSpan(replicaSet) + } + } sourceComplete := true + skipMerge := false seenSources := make(map[common.DispatcherID]struct{}, len(mergeReq.DispatcherIDs)) for _, idPB := range mergeReq.DispatcherIDs { if idPB == nil { @@ -980,19 +1008,80 @@ func (c *Controller) restoreCurrentMergeOperators( replicaSet := spanController.GetTaskByID(dispatcherID) if replicaSet == nil { spanInfo := spanInfoByID[dispatcherID] - if spanInfo == nil { + if spanInfo == nil || spanInfo.Span == nil { sourceComplete = false break } - splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[spanInfo.Span.TableID]) + splitable, tableExists := tableSplitMap[spanInfo.Span.TableID] + if !tableExists { + log.Warn("skip restoring merge operator because source table is missing from schema snapshot", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", dispatcherID.String()), + zap.Int64("tableID", spanInfo.Span.TableID), + zap.Int64("mode", mergeReq.Mode)) + skipMerge = true + break + } + splitEnabled := spanController.ShouldEnableSplit(splitable) replicaSet = c.createSpanReplication(spanInfo, nodeID, splitEnabled) spanController.AddReplicatingSpan(replicaSet) + createdSourceReplicaSets = append(createdSourceReplicaSets, replicaSet) + } else if replicaSet.Span == nil { + sourceComplete = false + break + } else if _, tableExists := tableSplitMap[replicaSet.Span.TableID]; !tableExists { + log.Warn("skip restoring merge operator because source table is missing from schema snapshot", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", dispatcherID.String()), + zap.Int64("tableID", replicaSet.Span.TableID), + zap.Int64("mode", mergeReq.Mode)) + skipMerge = true + break } sourceReplicaSets = append(sourceReplicaSets, replicaSet) } + if skipMerge { + cleanupCreatedSourceReplicaSets() + continue + } mergedSpanInfo := spanInfoByID[mergedDispatcherID] mergedReplicaSet := spanController.GetTaskByID(mergedDispatcherID) + if mergedSpanInfo != nil { + if mergedSpanInfo.Span == nil { + log.Warn("skip restoring merge operator because merged span is missing", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", mergedDispatcherID.String()), + zap.Int64("mode", mergeReq.Mode)) + cleanupCreatedSourceReplicaSets() + continue + } + if _, tableExists := tableSplitMap[mergedSpanInfo.Span.TableID]; !tableExists { + log.Warn("skip restoring merge operator because merged table is missing from schema snapshot", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", mergedDispatcherID.String()), + zap.Int64("tableID", mergedSpanInfo.Span.TableID), + zap.Int64("mode", mergeReq.Mode)) + cleanupCreatedSourceReplicaSets() + continue + } + } + if mergedReplicaSet != nil && mergedReplicaSet.Span != nil { + if _, tableExists := tableSplitMap[mergedReplicaSet.Span.TableID]; !tableExists { + log.Warn("skip restoring merge operator because merged table is missing from schema snapshot", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", mergedDispatcherID.String()), + zap.Int64("tableID", mergedReplicaSet.Span.TableID), + zap.Int64("mode", mergeReq.Mode)) + cleanupCreatedSourceReplicaSets() + continue + } + } if mergedSpanInfo != nil && mergedSpanInfo.ComponentStatus == heartbeatpb.ComponentState_Working { if mergedReplicaSet == nil { splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[mergedSpanInfo.Span.TableID]) @@ -1044,9 +1133,10 @@ func (c *Controller) restoreCurrentMergeOperators( zap.Any("status", mergedSpanInfo.ComponentStatus)) continue } - for _, replicaSet := range sourceReplicaSets { - spanController.MarkSpanScheduling(replicaSet) - } + // Without a merged dispatcher snapshot, a merge journal with missing sources is stale + // and cannot be driven by any restored operator. Leave the surviving source spans in + // their bootstrap state so normal scheduling can repair any uncovered table ranges. + cleanupCreatedSourceReplicaSets() continue } @@ -1067,6 +1157,7 @@ func (c *Controller) restoreCurrentMergeOperators( zap.String("nodeID", nodeID.String()), zap.String("changefeed", resp.ChangefeedID.String()), zap.String("dispatcher", mergedDispatcherID.String())) + cleanupCreatedSourceReplicaSets() continue } splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[mergedSpan.TableID]) @@ -1119,6 +1210,18 @@ func (c *Controller) restoreCurrentMergeOperators( return nil } +func tableSplitMapForMode( + mode int64, + tableSplitMaps map[int64]map[int64]bool, +) (map[int64]bool, bool) { + if common.IsRedoMode(mode) { + tableSplitMap, ok := tableSplitMaps[common.RedoMode] + return tableSplitMap, ok + } + tableSplitMap, ok := tableSplitMaps[common.DefaultMode] + return tableSplitMap, ok +} + // buildMergedSpanFromReplicas synthesizes the merged span shape from consecutive source replica sets. func buildMergedSpanFromReplicas( replicaSets []*replica.SpanReplication, diff --git a/maintainer/maintainer_controller_test.go b/maintainer/maintainer_controller_test.go index 2c9b350a7e..6531801944 100644 --- a/maintainer/maintainer_controller_test.go +++ b/maintainer/maintainer_controller_test.go @@ -1886,6 +1886,116 @@ func newMergeBootstrapTestEnv(t *testing.T) *mergeBootstrapTestEnv { } } +// TestFinishBootstrapSkipsMergeOperatorForDroppedTable covers failover after a DROP TABLE +// while dispatcher manager still reports an in-flight merge journal. The test boots from an +// empty schema snapshot, feeds source and merged dispatcher snapshots plus the stale merge +// request, and expects bootstrap to skip restoring ghost table tasks/operators. +func TestFinishBootstrapSkipsMergeOperatorForDroppedTable(t *testing.T) { + env := newMergeBootstrapTestEnv(t) + + schemaStore := eventservice.NewMockSchemaStore() + schemaStore.SetTables(nil) + appcontext.SetService(appcontext.SchemaStore, schemaStore) + + _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ + "node1": { + ChangefeedID: env.cfID.ToPB(), + Spans: []*heartbeatpb.BootstrapTableSpan{ + { + ID: env.sourceDispatcherID1.ToPB(), + SchemaID: 1, + Span: env.sourceSpan1, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: env.sourceDispatcherID2.ToPB(), + SchemaID: 1, + Span: env.sourceSpan2, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: env.mergedDispatcherID.ToPB(), + SchemaID: 1, + Span: env.mergedSpan, + ComponentStatus: heartbeatpb.ComponentState_Preparing, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }, + MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ + { + ChangefeedID: env.cfID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{ + env.sourceDispatcherID1.ToPB(), + env.sourceDispatcherID2.ToPB(), + }, + MergedDispatcherID: env.mergedDispatcherID.ToPB(), + Mode: common.DefaultMode, + }, + }, + CheckpointTs: 10, + }, + }, false) + require.NoError(t, err) + require.True(t, env.controller.bootstrapped) + require.Zero(t, env.controller.operatorController.OperatorSize()) + require.Zero(t, env.controller.spanController.GetAbsentSize()) + require.Zero(t, env.controller.spanController.GetSchedulingSize()) + require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID2)) + require.Nil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) + require.Empty(t, env.controller.spanController.GetTasksByTableID(env.sourceSpan1.TableID)) +} + +// TestFinishBootstrapSkipsIncompleteMergeJournalWithoutMergedDispatcher covers a stale merge +// journal whose source list is incomplete and whose merged dispatcher snapshot is absent. The +// test restores a table with one surviving source span and expects bootstrap to skip the merge +// operator without moving that source into scheduling state. +func TestFinishBootstrapSkipsIncompleteMergeJournalWithoutMergedDispatcher(t *testing.T) { + env := newMergeBootstrapTestEnv(t) + + _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ + "node1": { + ChangefeedID: env.cfID.ToPB(), + Spans: []*heartbeatpb.BootstrapTableSpan{ + { + ID: env.sourceDispatcherID1.ToPB(), + SchemaID: 1, + Span: env.sourceSpan1, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }, + MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ + { + ChangefeedID: env.cfID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{ + env.sourceDispatcherID1.ToPB(), + env.sourceDispatcherID2.ToPB(), + }, + MergedDispatcherID: env.mergedDispatcherID.ToPB(), + Mode: common.DefaultMode, + }, + }, + CheckpointTs: 10, + }, + }, false) + require.NoError(t, err) + require.True(t, env.controller.bootstrapped) + require.Zero(t, env.controller.operatorController.OperatorSize()) + require.Zero(t, env.controller.spanController.GetSchedulingSize()) + + sourceReplicaSet := env.controller.spanController.GetTaskByID(env.sourceDispatcherID1) + require.NotNil(t, sourceReplicaSet) + require.True(t, env.controller.spanController.IsReplicating(sourceReplicaSet)) + require.Nil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) +} + // TestHandleStatusDropsTerminalSourcesCoveredByMergedSpanAfterJournalCleanup covers the post-bootstrap // merge cleanup window where source dispatchers still report terminal statuses after the merge journal // is gone. The test bootstraps overlapping source and merged spans, then sends terminal source From 821c0d8a1fd70f4099e4c9a4279f083aee8ae6ce Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 18 Jun 2026 16:57:24 +0800 Subject: [PATCH 18/25] maintainer: harden merge bootstrap recovery --- .../dispatcher_manager_merge.go | 6 + .../dispatcher_manager_test.go | 14 + maintainer/maintainer_controller_bootstrap.go | 270 +++++++++++++++++- maintainer/maintainer_controller_test.go | 172 +++++++++++ tests/integration_tests/_utils/get_table_id | 7 +- 5 files changed, 457 insertions(+), 12 deletions(-) diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go b/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go index 5d41279ffe..f3b4937a78 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go @@ -27,6 +27,12 @@ func (e *DispatcherManager) TrackMergeOperator(req *heartbeatpb.MergeDispatcherR return } mergedID := common.NewDispatcherIDFromPB(req.MergedDispatcherID) + if mergedID.IsZero() { + log.Warn("ignore merge operator with invalid merged dispatcher ID", + zap.Stringer("changefeedID", e.changefeedID), + zap.Int64("mode", req.Mode)) + return + } e.mergeOperatorMap.Store(mergedID.String(), cloneMergeDispatcherRequest(req)) } diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go index a6f35d1bc3..ec512ec67e 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go @@ -1030,6 +1030,20 @@ func TestDoMergeKeepsMergeJournalUntilSourcesAreCleaned(t *testing.T) { require.Empty(t, manager.GetMergeOperators()) } +// TestTrackMergeOperatorRejectsZeroMergedDispatcherID covers a malformed merge request. +// The test tracks a request with an all-zero merged ID and verifies it cannot occupy the shared +// zero-value map key or appear in later bootstrap responses. +func TestTrackMergeOperatorRejectsZeroMergedDispatcherID(t *testing.T) { + manager := createTestManager(t) + manager.TrackMergeOperator(&heartbeatpb.MergeDispatcherRequest{ + ChangefeedID: manager.changefeedID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{common.NewDispatcherID().ToPB(), common.NewDispatcherID().ToPB()}, + MergedDispatcherID: (&common.DispatcherID{}).ToPB(), + Mode: common.DefaultMode, + }) + require.Empty(t, manager.GetMergeOperators()) +} + func TestDoMergeWithThreeDispatchers(t *testing.T) { manager := createTestManager(t) diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 5662669ed2..64861806e6 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -219,11 +219,11 @@ func (c *Controller) buildWorkingTaskMap( spanController := c.getSpanController(mode) for node, resp := range allNodesResp { for _, spanInfo := range resp.Spans { - if spanInfo.Mode != mode { + if spanInfo == nil || spanInfo.ID == nil || spanInfo.Span == nil || spanInfo.Mode != mode { continue } dispatcherID := common.NewDispatcherIDFromPB(spanInfo.ID) - if spanController.IsDDLDispatcher(dispatcherID) { + if dispatcherID.IsZero() || spanController.IsDDLDispatcher(dispatcherID) { continue } splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[spanInfo.Span.TableID]) @@ -304,7 +304,7 @@ func (c *Controller) processTableSpans( if c.enableTableAcrossNodes { if !isTableWorking && tableSpans == nil { - tableSpans = utils.NewBtreeMap[*heartbeatpb.TableSpan, *replica.SpanReplication](common.LessTableSpan) + tableSpans = utils.NewBtreeMap[*heartbeatpb.TableSpan, *replica.SpanReplication](lessBootstrapTableSpan) } if isTableSpanExists { for _, replicaSet := range replicaSets { @@ -358,6 +358,7 @@ func (c *Controller) buildTaskInfo( if err := c.restoreCurrentWorkingOperators(allNodesResp, tableSplitMap, mode); err != nil { return nil, nil, err } + c.removeUnexpectedBootstrapOverlaps(workingTaskMap, allNodesResp, mode) schemaInfos := c.processTablesAndBuildSchemaInfo(tables, workingTaskMap, isMysqlCompatibleBackend, mode) return workingTaskMap, schemaInfos, nil } @@ -472,12 +473,217 @@ func addToWorkingTaskMap( ) { tableSpans, ok := workingTaskMap[span.TableID] if !ok { - tableSpans = utils.NewBtreeMap[*heartbeatpb.TableSpan, *replica.SpanReplication](common.LessTableSpan) + tableSpans = utils.NewBtreeMap[*heartbeatpb.TableSpan, *replica.SpanReplication](lessBootstrapTableSpan) workingTaskMap[span.TableID] = tableSpans } tableSpans.ReplaceOrInsert(span, spanReplication) } +// lessBootstrapTableSpan keeps spans with the same start key but different end keys distinct. +// Merge bootstrap snapshots can contain a source span and its covering merged span with the same +// start key, so the normal start-key-only comparator would silently replace one of them. +func lessBootstrapTableSpan(left, right *heartbeatpb.TableSpan) bool { + if left.TableID != right.TableID { + return left.TableID < right.TableID + } + if cmp := bytes.Compare(left.StartKey, right.StartKey); cmp != 0 { + return cmp < 0 + } + if cmp := bytes.Compare(left.EndKey, right.EndKey); cmp != 0 { + // Put the wider span first so unexpected same-start overlaps retain the covering span. + return cmp > 0 + } + return left.KeyspaceID < right.KeyspaceID +} + +type bootstrapMergeEvidence struct { + sourceToTargets map[common.DispatcherID]map[common.DispatcherID]struct{} +} + +func buildBootstrapMergeEvidence( + allNodesResp map[node.ID]*heartbeatpb.MaintainerBootstrapResponse, + mode int64, +) bootstrapMergeEvidence { + evidence := bootstrapMergeEvidence{ + sourceToTargets: make(map[common.DispatcherID]map[common.DispatcherID]struct{}), + } + for _, resp := range allNodesResp { + if resp == nil { + continue + } + for _, mergeReq := range resp.MergeOperators { + if mergeReq == nil || mergeReq.MergedDispatcherID == nil || mergeReq.Mode != mode { + continue + } + mergedID := common.NewDispatcherIDFromPB(mergeReq.MergedDispatcherID) + if mergedID.IsZero() { + continue + } + + sourceIDs := make(map[common.DispatcherID]struct{}, len(mergeReq.DispatcherIDs)) + for _, idPB := range mergeReq.DispatcherIDs { + if idPB == nil { + continue + } + dispatcherID := common.NewDispatcherIDFromPB(idPB) + if dispatcherID.IsZero() || dispatcherID == mergedID { + continue + } + sourceIDs[dispatcherID] = struct{}{} + } + if len(sourceIDs) < 2 { + continue + } + + for dispatcherID := range sourceIDs { + addBootstrapMergeEvidence(evidence, dispatcherID, mergedID) + } + } + } + return evidence +} + +func addBootstrapMergeEvidence( + evidence bootstrapMergeEvidence, + dispatcherID common.DispatcherID, + mergeID common.DispatcherID, +) { + targets, ok := evidence.sourceToTargets[dispatcherID] + if !ok { + targets = make(map[common.DispatcherID]struct{}) + evidence.sourceToTargets[dispatcherID] = targets + } + targets[mergeID] = struct{}{} +} + +func (e bootstrapMergeEvidence) relates(left, right common.DispatcherID) bool { + if _, ok := e.sourceToTargets[left][right]; ok { + return true + } + _, ok := e.sourceToTargets[right][left] + return ok +} + +func spansOverlap(left, right *heartbeatpb.TableSpan) bool { + if left == nil || right == nil || + left.TableID != right.TableID || + left.KeyspaceID != right.KeyspaceID { + return false + } + return bytes.Compare(left.StartKey, right.EndKey) < 0 && + bytes.Compare(right.StartKey, left.EndKey) < 0 +} + +func isMergeTargetState(status heartbeatpb.ComponentState) bool { + switch status { + case heartbeatpb.ComponentState_Preparing, + heartbeatpb.ComponentState_MergeReady, + heartbeatpb.ComponentState_Initializing, + heartbeatpb.ComponentState_Working: + return true + default: + return false + } +} + +func isWaitingMergeSpanCoveredByTarget( + source, target *replica.SpanReplication, +) bool { + if source == nil || target == nil || source.Span == nil || target.Span == nil { + return false + } + sourceStatus := source.GetStatus() + targetStatus := target.GetStatus() + if sourceStatus == nil || targetStatus == nil || + sourceStatus.ComponentStatus != heartbeatpb.ComponentState_WaitingMerge || + !isMergeTargetState(targetStatus.ComponentStatus) { + return false + } + return source.GetMode() == target.GetMode() && + source.Span.TableID == target.Span.TableID && + source.Span.KeyspaceID == target.Span.KeyspaceID && + bytes.Compare(target.Span.StartKey, source.Span.StartKey) <= 0 && + bytes.Compare(target.Span.EndKey, source.Span.EndKey) >= 0 +} + +func isExpectedBootstrapOverlap( + left, right *replica.SpanReplication, + evidence bootstrapMergeEvidence, +) bool { + if evidence.relates(left.ID, right.ID) { + return true + } + return isWaitingMergeSpanCoveredByTarget(left, right) || + isWaitingMergeSpanCoveredByTarget(right, left) +} + +// removeUnexpectedBootstrapOverlaps rejects overlapping desired spans unless bootstrap state +// proves an in-flight transition. Unproven overlaps would otherwise be registered as independent +// replicating tasks and could duplicate downstream writes indefinitely. +func (c *Controller) removeUnexpectedBootstrapOverlaps( + workingTaskMap map[int64]utils.Map[*heartbeatpb.TableSpan, *replica.SpanReplication], + allNodesResp map[node.ID]*heartbeatpb.MaintainerBootstrapResponse, + mode int64, +) { + evidence := buildBootstrapMergeEvidence(allNodesResp, mode) + operatorController := c.getOperatorController(mode) + for tableID, tableSpans := range workingTaskMap { + accepted := make([]*replica.SpanReplication, 0, tableSpans.Len()) + rejectedSpans := make([]*heartbeatpb.TableSpan, 0) + tableSpans.Ascend(func(span *heartbeatpb.TableSpan, candidate *replica.SpanReplication) bool { + for _, existing := range accepted { + if !spansOverlap(existing.Span, candidate.Span) { + continue + } + // Ordinary bootstrap operators also prove that the overlap is already converging. + if operatorController.GetOperator(existing.ID) != nil || + operatorController.GetOperator(candidate.ID) != nil || + isExpectedBootstrapOverlap(existing, candidate, evidence) { + continue + } + + log.Warn("remove unexpected overlapping dispatcher reported during bootstrap", + zap.Stringer("changefeed", c.changefeedID), + zap.Int64("tableID", tableID), + zap.String("keptDispatcherID", existing.ID.String()), + zap.String("removedDispatcherID", candidate.ID.String()), + zap.String("keptSpan", common.FormatTableSpan(existing.Span)), + zap.String("removedSpan", common.FormatTableSpan(candidate.Span)), + zap.Int64("mode", mode)) + rejectedSpans = append(rejectedSpans, span) + c.removeUnexpectedBootstrapDispatcher(candidate) + return true + } + accepted = append(accepted, candidate) + return true + }) + for _, span := range rejectedSpans { + tableSpans.Delete(span) + } + } +} + +func (c *Controller) removeUnexpectedBootstrapDispatcher(replicaSet *replica.SpanReplication) { + if replicaSet == nil || replicaSet.ID.IsZero() || replicaSet.GetNodeID() == "" { + return + } + err := c.messageCenter.SendCommand(replica.NewRemoveDispatcherMessage( + replicaSet.GetNodeID(), + c.changefeedID, + replicaSet.ID.ToPB(), + nil, + replicaSet.GetMode(), + heartbeatpb.OperatorType_O_Remove, + )) + if err != nil { + log.Warn("failed to remove unexpected overlapping dispatcher during bootstrap", + zap.Stringer("changefeed", c.changefeedID), + zap.String("dispatcherID", replicaSet.ID.String()), + zap.String("nodeID", replicaSet.GetNodeID().String()), + zap.Error(errors.Trace(err))) + } +} + // findHoles returns the uncovered sub-spans in totalSpan. // // Bootstrap snapshots can temporarily contain overlapping spans during in-flight merge recovery: @@ -983,6 +1189,13 @@ func (c *Controller) restoreCurrentMergeOperators( } spanInfoByID := indexBootstrapSpans(resp.Spans, mergeReq.Mode) mergedDispatcherID := common.NewDispatcherIDFromPB(mergeReq.MergedDispatcherID) + if mergedDispatcherID.IsZero() { + log.Warn("skip restoring merge operator due to invalid merged dispatcher ID", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.Int64("mode", mergeReq.Mode)) + continue + } sourceReplicaSets := make([]*replica.SpanReplication, 0, len(mergeReq.DispatcherIDs)) createdSourceReplicaSets := make([]*replica.SpanReplication, 0, len(mergeReq.DispatcherIDs)) @@ -1000,6 +1213,10 @@ func (c *Controller) restoreCurrentMergeOperators( break } dispatcherID := common.NewDispatcherIDFromPB(idPB) + if dispatcherID.IsZero() { + sourceComplete = false + break + } if _, ok := seenSources[dispatcherID]; ok { continue } @@ -1082,6 +1299,24 @@ func (c *Controller) restoreCurrentMergeOperators( continue } } + + conflictingDispatcherID, conflictingOperatorType, hasConflict := + findBootstrapMergeOperatorConflict(operatorController, sourceReplicaSets, mergedDispatcherID) + if hasConflict { + // Regular create/remove recovery has higher priority than a merge journal because it + // represents a later concrete action for the same dispatcher. Treat the merge record + // as stale instead of failing the entire bootstrap. + log.Warn("skip restoring stale merge operator due to conflicting bootstrap operator", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", conflictingDispatcherID.String()), + zap.String("operatorType", conflictingOperatorType), + zap.String("mergedDispatcher", mergedDispatcherID.String()), + zap.Int64("mode", mergeReq.Mode)) + cleanupCreatedSourceReplicaSets() + continue + } + if mergedSpanInfo != nil && mergedSpanInfo.ComponentStatus == heartbeatpb.ComponentState_Working { if mergedReplicaSet == nil { splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[mergedSpanInfo.Span.TableID]) @@ -1189,11 +1424,9 @@ func (c *Controller) restoreCurrentMergeOperators( continue } - spanController.MarkSpanScheduling(mergedReplicaSet) - mergeOp := operatorController.AddRestoredMergeOperator(sourceReplicaSets, mergedReplicaSet) if mergeOp == nil { - log.Error("restore merge operator failed", + log.Warn("skip stale merge operator that cannot be restored", zap.String("nodeID", nodeID.String()), zap.String("changefeed", resp.ChangefeedID.String()), zap.String("dispatcher", mergedDispatcherID.String()), @@ -1202,14 +1435,35 @@ func (c *Controller) restoreCurrentMergeOperators( if createdMerged { spanController.RemoveReplicatingSpan(mergedReplicaSet) } - return errors.ErrOperatorIsNil.GenWithStack("restore merge operator failed when bootstrap") + cleanupCreatedSourceReplicaSets() + continue } + spanController.MarkSpanScheduling(mergedReplicaSet) mergeOp.Start() } } return nil } +func findBootstrapMergeOperatorConflict( + operatorController *operator.Controller, + sourceReplicaSets []*replica.SpanReplication, + mergedDispatcherID common.DispatcherID, +) (common.DispatcherID, string, bool) { + if op := operatorController.GetOperator(mergedDispatcherID); op != nil { + return mergedDispatcherID, op.Type(), true + } + for _, replicaSet := range sourceReplicaSets { + if replicaSet == nil { + continue + } + if op := operatorController.GetOperator(replicaSet.ID); op != nil { + return replicaSet.ID, op.Type(), true + } + } + return common.DispatcherID{}, "", false +} + func tableSplitMapForMode( mode int64, tableSplitMaps map[int64]map[int64]bool, diff --git a/maintainer/maintainer_controller_test.go b/maintainer/maintainer_controller_test.go index 6531801944..c34e8b14ac 100644 --- a/maintainer/maintainer_controller_test.go +++ b/maintainer/maintainer_controller_test.go @@ -1808,6 +1808,72 @@ func TestFinishBootstrapKeepsOverlapCoveredAfterMergeJournalCleanup(t *testing.T require.NotNil(t, s.spanController.GetTaskByID(mergedDispatcherID)) } +// TestFinishBootstrapRemovesUnexpectedOverlappingWorkingSpan covers a corrupt bootstrap snapshot +// with two partially overlapping Working dispatchers and no operator or merge evidence. The test +// keeps the earlier span, excludes the conflicting dispatcher from desired state, and creates an +// absent task for the uncovered tail so normal scheduling can repair coverage without duplication. +func TestFinishBootstrapRemovesUnexpectedOverlappingWorkingSpan(t *testing.T) { + env := newMergeBootstrapTestEnv(t) + overlapStart := appendNew(env.mergedSpan.StartKey, 'a') + keptEnd := appendNew(env.mergedSpan.StartKey, 'b') + keptSpan := &heartbeatpb.TableSpan{ + TableID: env.mergedSpan.TableID, + StartKey: env.mergedSpan.StartKey, + EndKey: keptEnd, + KeyspaceID: env.mergedSpan.KeyspaceID, + } + rejectedSpan := &heartbeatpb.TableSpan{ + TableID: env.mergedSpan.TableID, + StartKey: overlapStart, + EndKey: env.mergedSpan.EndKey, + KeyspaceID: env.mergedSpan.KeyspaceID, + } + keptDispatcherID := common.NewDispatcherID() + rejectedDispatcherID := common.NewDispatcherID() + + _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ + "node1": { + ChangefeedID: env.cfID.ToPB(), + Spans: []*heartbeatpb.BootstrapTableSpan{ + { + ID: keptDispatcherID.ToPB(), + SchemaID: 1, + Span: keptSpan, + ComponentStatus: heartbeatpb.ComponentState_Working, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: rejectedDispatcherID.ToPB(), + SchemaID: 1, + Span: rejectedSpan, + ComponentStatus: heartbeatpb.ComponentState_Working, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }, + CheckpointTs: 10, + }, + }, false) + require.NoError(t, err) + require.True(t, env.controller.bootstrapped) + require.NotNil(t, env.controller.spanController.GetTaskByID(keptDispatcherID)) + require.Nil(t, env.controller.spanController.GetTaskByID(rejectedDispatcherID)) + require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) + require.Equal(t, 1, env.controller.spanController.GetAbsentSize()) + + var repairedTail *replica.SpanReplication + for _, task := range env.controller.spanController.GetTasksByTableID(env.mergedSpan.TableID) { + if task.ID != keptDispatcherID { + repairedTail = task + break + } + } + require.NotNil(t, repairedTail) + require.Equal(t, keptEnd, repairedTail.Span.StartKey) + require.Equal(t, env.mergedSpan.EndKey, repairedTail.Span.EndKey) +} + type mergeBootstrapTestEnv struct { controller *Controller cfID common.ChangeFeedID @@ -1996,6 +2062,112 @@ func TestFinishBootstrapSkipsIncompleteMergeJournalWithoutMergedDispatcher(t *te require.Nil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) } +// TestFinishBootstrapSkipsMergeJournalConflictingWithWorkingOperator covers non-atomic bootstrap +// snapshots where a stale merge journal overlaps a newer create or remove request. Each subtest +// restores the regular operator first, then verifies merge recovery yields to it without failing +// FinishBootstrap or installing a merge operator. +func TestFinishBootstrapSkipsMergeJournalConflictingWithWorkingOperator(t *testing.T) { + testCases := []struct { + name string + scheduleAction heartbeatpb.ScheduleAction + operatorType heartbeatpb.OperatorType + includeSourceSnapshot bool + expectedOperatorType string + }{ + { + name: "remove source", + scheduleAction: heartbeatpb.ScheduleAction_Remove, + operatorType: heartbeatpb.OperatorType_O_Remove, + includeSourceSnapshot: true, + expectedOperatorType: "remove", + }, + { + name: "create source", + scheduleAction: heartbeatpb.ScheduleAction_Create, + operatorType: heartbeatpb.OperatorType_O_Add, + expectedOperatorType: "add", + }, + } + + for _, tc := range testCases { + // Scenario: the ordinary operator and merge journal reference the same source dispatcher. + // Steps: restore the ordinary request, process merge snapshots, then ensure the stale journal + // is skipped while the newer create/remove operator remains active. + t.Run(tc.name, func(t *testing.T) { + env := newMergeBootstrapTestEnv(t) + spans := []*heartbeatpb.BootstrapTableSpan{ + { + ID: env.sourceDispatcherID2.ToPB(), + SchemaID: 1, + Span: env.sourceSpan2, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: env.mergedDispatcherID.ToPB(), + SchemaID: 1, + Span: env.mergedSpan, + ComponentStatus: heartbeatpb.ComponentState_Preparing, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + } + if tc.includeSourceSnapshot { + spans = append(spans, &heartbeatpb.BootstrapTableSpan{ + ID: env.sourceDispatcherID1.ToPB(), + SchemaID: 1, + Span: env.sourceSpan1, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }) + } + + _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ + "node1": { + ChangefeedID: env.cfID.ToPB(), + Spans: spans, + Operators: []*heartbeatpb.ScheduleDispatcherRequest{ + { + ChangefeedID: env.cfID.ToPB(), + Config: &heartbeatpb.DispatcherConfig{ + DispatcherID: env.sourceDispatcherID1.ToPB(), + SchemaID: 1, + Span: env.sourceSpan1, + StartTs: 10, + Mode: common.DefaultMode, + }, + ScheduleAction: tc.scheduleAction, + OperatorType: tc.operatorType, + }, + }, + MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ + { + ChangefeedID: env.cfID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{ + env.sourceDispatcherID1.ToPB(), + env.sourceDispatcherID2.ToPB(), + }, + MergedDispatcherID: env.mergedDispatcherID.ToPB(), + Mode: common.DefaultMode, + }, + }, + CheckpointTs: 10, + }, + }, false) + require.NoError(t, err) + require.True(t, env.controller.bootstrapped) + + workingOp := env.controller.operatorController.GetOperator(env.sourceDispatcherID1) + require.NotNil(t, workingOp) + require.Equal(t, tc.expectedOperatorType, workingOp.Type()) + require.Nil(t, env.controller.operatorController.GetOperator(env.mergedDispatcherID)) + require.Equal(t, 1, env.controller.operatorController.OperatorSize()) + }) + } +} + // TestHandleStatusDropsTerminalSourcesCoveredByMergedSpanAfterJournalCleanup covers the post-bootstrap // merge cleanup window where source dispatchers still report terminal statuses after the merge journal // is gone. The test bootstraps overlapping source and merged spans, then sends terminal source diff --git a/tests/integration_tests/_utils/get_table_id b/tests/integration_tests/_utils/get_table_id index a3177b367d..7fd050559c 100755 --- a/tests/integration_tests/_utils/get_table_id +++ b/tests/integration_tests/_utils/get_table_id @@ -6,7 +6,7 @@ # parameter 2: table name # parameter 3: retry count -set -ex +set -exo pipefail dbName=${1} tableName=${2} @@ -16,9 +16,8 @@ retries=0 while [ $retries -lt $MAX_RETRIES ]; do # Follow the configured upstream status endpoint so tests can run against non-default local ports. - id=$(curl "http://${UP_TIDB_HOST:-127.0.0.1}:${UP_TIDB_STATUS:-10080}/schema/${dbName}/${tableName}" | jq .id) - if [ -n "$id" ]; then - echo $id + if id=$(curl -fsS "http://${UP_TIDB_HOST:-127.0.0.1}:${UP_TIDB_STATUS:-10080}/schema/${dbName}/${tableName}" | jq -er '.id'); then + echo "$id" exit 0 fi retries=$((retries + 1)) From d0c1051e78ec022193908a4dee5f40ee9fb3e94a Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Mon, 22 Jun 2026 00:01:14 +0800 Subject: [PATCH 19/25] maintainer: harden bootstrap overlap recovery --- maintainer/maintainer_controller_bootstrap.go | 255 +++++++++++++++--- maintainer/maintainer_controller_test.go | 183 ++++++++++++- 2 files changed, 391 insertions(+), 47 deletions(-) diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 64861806e6..c23b495678 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -490,8 +490,9 @@ func lessBootstrapTableSpan(left, right *heartbeatpb.TableSpan) bool { return cmp < 0 } if cmp := bytes.Compare(left.EndKey, right.EndKey); cmp != 0 { - // Put the wider span first so unexpected same-start overlaps retain the covering span. - return cmp > 0 + // Put the narrower span first. If a merge target is not backed by valid merge evidence, + // preserving the source topology is safer than accepting an abortable covering target. + return cmp < 0 } return left.KeyspaceID < right.KeyspaceID } @@ -511,6 +512,7 @@ func buildBootstrapMergeEvidence( if resp == nil { continue } + spanInfoByID := indexBootstrapSpans(resp.Spans, mode) for _, mergeReq := range resp.MergeOperators { if mergeReq == nil || mergeReq.MergedDispatcherID == nil || mergeReq.Mode != mode { continue @@ -519,19 +521,56 @@ func buildBootstrapMergeEvidence( if mergedID.IsZero() { continue } + mergedSpanInfo := spanInfoByID[mergedID] + if mergedSpanInfo == nil || mergedSpanInfo.Span == nil || + !isMergeTargetState(mergedSpanInfo.ComponentStatus) { + continue + } sourceIDs := make(map[common.DispatcherID]struct{}, len(mergeReq.DispatcherIDs)) + sourceSpans := make([]*heartbeatpb.TableSpan, 0, len(mergeReq.DispatcherIDs)) + valid := true for _, idPB := range mergeReq.DispatcherIDs { if idPB == nil { - continue + valid = false + break } dispatcherID := common.NewDispatcherIDFromPB(idPB) if dispatcherID.IsZero() || dispatcherID == mergedID { + valid = false + break + } + if _, ok := sourceIDs[dispatcherID]; ok { continue } + spanInfo := spanInfoByID[dispatcherID] + if spanInfo == nil || spanInfo.Span == nil || + spanInfo.ComponentStatus != heartbeatpb.ComponentState_WaitingMerge || + spanInfo.Span.TableID != mergedSpanInfo.Span.TableID || + spanInfo.Span.KeyspaceID != mergedSpanInfo.Span.KeyspaceID { + valid = false + break + } sourceIDs[dispatcherID] = struct{}{} + sourceSpans = append(sourceSpans, spanInfo.Span) } - if len(sourceIDs) < 2 { + if !valid || len(sourceIDs) < 2 { + continue + } + sort.Slice(sourceSpans, func(i, j int) bool { + return bytes.Compare(sourceSpans[i].StartKey, sourceSpans[j].StartKey) < 0 + }) + if !bytes.Equal(sourceSpans[0].StartKey, mergedSpanInfo.Span.StartKey) || + !bytes.Equal(sourceSpans[len(sourceSpans)-1].EndKey, mergedSpanInfo.Span.EndKey) { + continue + } + for i := 1; i < len(sourceSpans); i++ { + if !common.IsTableSpanConsecutive(sourceSpans[i-1], sourceSpans[i]) { + valid = false + break + } + } + if !valid { continue } @@ -586,6 +625,11 @@ func isMergeTargetState(status heartbeatpb.ComponentState) bool { } } +func isCommittedMergeTargetState(status heartbeatpb.ComponentState) bool { + return status == heartbeatpb.ComponentState_Initializing || + status == heartbeatpb.ComponentState_Working +} + func isWaitingMergeSpanCoveredByTarget( source, target *replica.SpanReplication, ) bool { @@ -596,7 +640,7 @@ func isWaitingMergeSpanCoveredByTarget( targetStatus := target.GetStatus() if sourceStatus == nil || targetStatus == nil || sourceStatus.ComponentStatus != heartbeatpb.ComponentState_WaitingMerge || - !isMergeTargetState(targetStatus.ComponentStatus) { + !isCommittedMergeTargetState(targetStatus.ComponentStatus) { return false } return source.GetMode() == target.GetMode() && @@ -617,9 +661,9 @@ func isExpectedBootstrapOverlap( isWaitingMergeSpanCoveredByTarget(right, left) } -// removeUnexpectedBootstrapOverlaps rejects overlapping desired spans unless bootstrap state -// proves an in-flight transition. Unproven overlaps would otherwise be registered as independent -// replicating tasks and could duplicate downstream writes indefinitely. +// removeUnexpectedBootstrapOverlaps gives every unproven overlap a cleanup owner. The rejected +// runtime span remains temporary coverage until removal is confirmed, so bootstrap neither trusts +// it as permanent desired state nor schedules a replacement that can race with it. func (c *Controller) removeUnexpectedBootstrapOverlaps( workingTaskMap map[int64]utils.Map[*heartbeatpb.TableSpan, *replica.SpanReplication], allNodesResp map[node.ID]*heartbeatpb.MaintainerBootstrapResponse, @@ -628,9 +672,30 @@ func (c *Controller) removeUnexpectedBootstrapOverlaps( evidence := buildBootstrapMergeEvidence(allNodesResp, mode) operatorController := c.getOperatorController(mode) for tableID, tableSpans := range workingTaskMap { + candidates := make([]*replica.SpanReplication, 0, tableSpans.Len()) + tableSpans.Ascend(func(_ *heartbeatpb.TableSpan, candidate *replica.SpanReplication) bool { + candidates = append(candidates, candidate) + return true + }) + sort.SliceStable(candidates, func(i, j int) bool { + leftStatus := candidates[i].GetStatus() + rightStatus := candidates[j].GetStatus() + leftAbortableTarget := leftStatus != nil && + (leftStatus.ComponentStatus == heartbeatpb.ComponentState_Preparing || + leftStatus.ComponentStatus == heartbeatpb.ComponentState_MergeReady) + rightAbortableTarget := rightStatus != nil && + (rightStatus.ComponentStatus == heartbeatpb.ComponentState_Preparing || + rightStatus.ComponentStatus == heartbeatpb.ComponentState_MergeReady) + if leftAbortableTarget != rightAbortableTarget { + // Sources survive when an unvalidated merge is still abortable. + return !leftAbortableTarget + } + return lessBootstrapTableSpan(candidates[i].Span, candidates[j].Span) + }) + accepted := make([]*replica.SpanReplication, 0, tableSpans.Len()) - rejectedSpans := make([]*heartbeatpb.TableSpan, 0) - tableSpans.Ascend(func(span *heartbeatpb.TableSpan, candidate *replica.SpanReplication) bool { + for _, candidate := range candidates { + rejected := false for _, existing := range accepted { if !spansOverlap(existing.Span, candidate.Span) { continue @@ -650,38 +715,84 @@ func (c *Controller) removeUnexpectedBootstrapOverlaps( zap.String("keptSpan", common.FormatTableSpan(existing.Span)), zap.String("removedSpan", common.FormatTableSpan(candidate.Span)), zap.Int64("mode", mode)) - rejectedSpans = append(rejectedSpans, span) - c.removeUnexpectedBootstrapDispatcher(candidate) - return true + c.addBootstrapCleanupOperator(candidate) + rejected = true + break + } + if !rejected { + accepted = append(accepted, candidate) } - accepted = append(accepted, candidate) - return true - }) - for _, span := range rejectedSpans { - tableSpans.Delete(span) } } } -func (c *Controller) removeUnexpectedBootstrapDispatcher(replicaSet *replica.SpanReplication) { +// addBootstrapCleanupOperator tracks a runtime span until its remove reaches a terminal state. +func (c *Controller) addBootstrapCleanupOperator(replicaSet *replica.SpanReplication) bool { if replicaSet == nil || replicaSet.ID.IsZero() || replicaSet.GetNodeID() == "" { - return + return false } - err := c.messageCenter.SendCommand(replica.NewRemoveDispatcherMessage( - replicaSet.GetNodeID(), - c.changefeedID, - replicaSet.ID.ToPB(), - nil, - replicaSet.GetMode(), + spanController := c.getSpanController(replicaSet.GetMode()) + operatorController := c.getOperatorController(replicaSet.GetMode()) + if spanController == nil || operatorController == nil { + return false + } + if spanController.GetTaskByID(replicaSet.ID) == nil { + // Keep the runtime dispatcher as temporary coverage while its remove operator is active. + // This prevents the scheduler from creating a replacement before removal is confirmed. + spanController.AddReplicatingSpan(replicaSet) + } + op := operator.NewRemoveDispatcherOperator( + spanController, + replicaSet, heartbeatpb.OperatorType_O_Remove, - )) - if err != nil { - log.Warn("failed to remove unexpected overlapping dispatcher during bootstrap", + func() { + spanController.RemoveReplicatingSpan(replicaSet) + c.repairBootstrapTableCoverage(replicaSet) + }, + ) + if !operatorController.AddOperator(op) { + log.Warn("failed to add cleanup operator for unexpected bootstrap dispatcher", zap.Stringer("changefeed", c.changefeedID), zap.String("dispatcherID", replicaSet.ID.String()), zap.String("nodeID", replicaSet.GetNodeID().String()), - zap.Error(errors.Trace(err))) + zap.Int64("mode", replicaSet.GetMode())) + return false } + return true +} + +// repairBootstrapTableCoverage creates absent spans only after temporary runtime coverage is gone. +func (c *Controller) repairBootstrapTableCoverage(removedReplicaSet *replica.SpanReplication) { + if removedReplicaSet == nil || removedReplicaSet.Span == nil { + return + } + spanController := c.getSpanController(removedReplicaSet.GetMode()) + if spanController == nil { + return + } + currentSpans := utils.NewBtreeMap[*heartbeatpb.TableSpan, *replica.SpanReplication](lessBootstrapTableSpan) + for _, replicaSet := range spanController.GetTasksByTableID(removedReplicaSet.Span.TableID) { + if replicaSet == nil || replicaSet.Span == nil { + continue + } + currentSpans.ReplaceOrInsert(replicaSet.Span, replicaSet) + } + totalSpan := common.TableIDToComparableSpan( + removedReplicaSet.Span.KeyspaceID, + removedReplicaSet.Span.TableID, + ) + holes := findHoles(currentSpans, &heartbeatpb.TableSpan{ + TableID: removedReplicaSet.Span.TableID, + StartKey: totalSpan.StartKey, + EndKey: totalSpan.EndKey, + KeyspaceID: removedReplicaSet.Span.KeyspaceID, + }) + spanController.AddNewSpans( + removedReplicaSet.GetSchemaID(), + holes, + c.startTs, + removedReplicaSet.IsSplitEnabled(), + ) } // findHoles returns the uncovered sub-spans in totalSpan. @@ -1313,7 +1424,11 @@ func (c *Controller) restoreCurrentMergeOperators( zap.String("operatorType", conflictingOperatorType), zap.String("mergedDispatcher", mergedDispatcherID.String()), zap.Int64("mode", mergeReq.Mode)) - cleanupCreatedSourceReplicaSets() + c.reconcileUnrestorableBootstrapMerge( + mergedReplicaSet, + mergedSpanInfo, + sourceReplicaSets, + ) continue } @@ -1344,7 +1459,8 @@ func (c *Controller) restoreCurrentMergeOperators( zap.String("nodeID", nodeID.String()), zap.String("changefeed", resp.ChangefeedID.String()), zap.String("dispatcher", mergedDispatcherID.String())) - if mergedSpanInfo != nil { + if mergedSpanInfo != nil && + isCommittedMergeTargetState(mergedSpanInfo.ComponentStatus) { if mergedReplicaSet == nil { splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[mergedSpanInfo.Span.TableID]) mergedReplicaSet = c.createSpanReplication(mergedSpanInfo, nodeID, splitEnabled) @@ -1352,9 +1468,8 @@ func (c *Controller) restoreCurrentMergeOperators( } else { spanController.MarkSpanReplicating(mergedReplicaSet) } - // If any source dispatcher is already missing, the dispatcher manager has moved past - // the reversible part of merge cleanup. Keep the existing merged dispatcher as the - // desired span and drop leftover source spans so their late terminal statuses are ignored. + // Initializing is the merge commit point: the target has a real startTs and sources + // are being removed. Keep the committed target and ignore late source terminals. for _, replicaSet := range sourceReplicaSets { if replicaSet.ID == mergedReplicaSet.ID { continue @@ -1368,6 +1483,20 @@ func (c *Controller) restoreCurrentMergeOperators( zap.Any("status", mergedSpanInfo.ComponentStatus)) continue } + if mergedReplicaSet != nil { + // Preparing and MergeReady are still abortable. Dispatcher manager restores surviving + // sources and removes the target when any source is missing, so maintainer must not + // promote the target into permanent desired state. Keep it only as temporary coverage + // until the cleanup operator observes a terminal status. + c.addBootstrapCleanupOperator(mergedReplicaSet) + targetStatus, _ := bootstrapMergeTargetStatus(mergedSpanInfo, mergedReplicaSet) + log.Info("abort incomplete merge from uncommitted merged dispatcher", + zap.String("nodeID", nodeID.String()), + zap.String("changefeed", resp.ChangefeedID.String()), + zap.String("dispatcher", mergedDispatcherID.String()), + zap.Any("status", targetStatus)) + continue + } // Without a merged dispatcher snapshot, a merge journal with missing sources is stale // and cannot be driven by any restored operator. Leave the surviving source spans in // their bootstrap state so normal scheduling can repair any uncovered table ranges. @@ -1379,7 +1508,6 @@ func (c *Controller) restoreCurrentMergeOperators( return bytes.Compare(sourceReplicaSets[i].Span.StartKey, sourceReplicaSets[j].Span.StartKey) < 0 }) - createdMerged := false if mergedReplicaSet == nil { if mergedSpanInfo != nil { splitEnabled := spanController.ShouldEnableSplit(tableSplitMap[mergedSpanInfo.Span.TableID]) @@ -1412,7 +1540,6 @@ func (c *Controller) restoreCurrentMergeOperators( splitEnabled, ) spanController.AddSchedulingReplicaSet(mergedReplicaSet, nodeID) - createdMerged = true } } @@ -1432,10 +1559,11 @@ func (c *Controller) restoreCurrentMergeOperators( zap.String("dispatcher", mergedDispatcherID.String()), zap.Any("mergedReplicaSet", mergedReplicaSet), zap.Any("toMergedReplicaSets", sourceReplicaSets)) - if createdMerged { - spanController.RemoveReplicatingSpan(mergedReplicaSet) - } - cleanupCreatedSourceReplicaSets() + c.reconcileUnrestorableBootstrapMerge( + mergedReplicaSet, + mergedSpanInfo, + sourceReplicaSets, + ) continue } spanController.MarkSpanScheduling(mergedReplicaSet) @@ -1445,6 +1573,51 @@ func (c *Controller) restoreCurrentMergeOperators( return nil } +// bootstrapMergeTargetStatus reads the most concrete target state available during restoration. +func bootstrapMergeTargetStatus( + mergedSpanInfo *heartbeatpb.BootstrapTableSpan, + mergedReplicaSet *replica.SpanReplication, +) (heartbeatpb.ComponentState, bool) { + if mergedSpanInfo != nil { + return mergedSpanInfo.ComponentStatus, true + } + if mergedReplicaSet != nil && mergedReplicaSet.GetStatus() != nil { + return mergedReplicaSet.GetStatus().ComponentStatus, true + } + return heartbeatpb.ComponentState_Working, false +} + +// reconcileUnrestorableBootstrapMerge selects the survivor according to the merge commit point. +func (c *Controller) reconcileUnrestorableBootstrapMerge( + mergedReplicaSet *replica.SpanReplication, + mergedSpanInfo *heartbeatpb.BootstrapTableSpan, + sourceReplicaSets []*replica.SpanReplication, +) { + if mergedReplicaSet == nil { + return + } + targetStatus, hasStatus := bootstrapMergeTargetStatus(mergedSpanInfo, mergedReplicaSet) + spanController := c.getSpanController(mergedReplicaSet.GetMode()) + if spanController == nil { + return + } + if hasStatus && isCommittedMergeTargetState(targetStatus) { + if spanController.GetTaskByID(mergedReplicaSet.ID) == nil { + spanController.AddReplicatingSpan(mergedReplicaSet) + } else { + spanController.MarkSpanReplicating(mergedReplicaSet) + } + for _, replicaSet := range sourceReplicaSets { + if replicaSet == nil || replicaSet.ID == mergedReplicaSet.ID { + continue + } + spanController.RemoveReplicatingSpan(replicaSet) + } + return + } + c.addBootstrapCleanupOperator(mergedReplicaSet) +} + func findBootstrapMergeOperatorConflict( operatorController *operator.Controller, sourceReplicaSets []*replica.SpanReplication, diff --git a/maintainer/maintainer_controller_test.go b/maintainer/maintainer_controller_test.go index c34e8b14ac..e9ab8c2418 100644 --- a/maintainer/maintainer_controller_test.go +++ b/maintainer/maintainer_controller_test.go @@ -1810,8 +1810,8 @@ func TestFinishBootstrapKeepsOverlapCoveredAfterMergeJournalCleanup(t *testing.T // TestFinishBootstrapRemovesUnexpectedOverlappingWorkingSpan covers a corrupt bootstrap snapshot // with two partially overlapping Working dispatchers and no operator or merge evidence. The test -// keeps the earlier span, excludes the conflicting dispatcher from desired state, and creates an -// absent task for the uncovered tail so normal scheduling can repair coverage without duplication. +// keeps the conflicting dispatcher as temporary coverage under a remove operator, confirms no +// replacement is scheduled early, then repairs the uncovered tail after removal reaches terminal. func TestFinishBootstrapRemovesUnexpectedOverlappingWorkingSpan(t *testing.T) { env := newMergeBootstrapTestEnv(t) overlapStart := appendNew(env.mergedSpan.StartKey, 'a') @@ -1858,6 +1858,28 @@ func TestFinishBootstrapRemovesUnexpectedOverlappingWorkingSpan(t *testing.T) { require.NoError(t, err) require.True(t, env.controller.bootstrapped) require.NotNil(t, env.controller.spanController.GetTaskByID(keptDispatcherID)) + require.NotNil(t, env.controller.spanController.GetTaskByID(rejectedDispatcherID)) + require.Equal(t, 2, env.controller.spanController.GetReplicatingSize()) + require.Zero(t, env.controller.spanController.GetAbsentSize()) + + removeOp := env.controller.operatorController.GetOperator(rejectedDispatcherID) + require.NotNil(t, removeOp) + require.Equal(t, "remove", removeOp.Type()) + env.controller.schedulerController.GetScheduler(scheduler.BasicScheduler).Execute() + require.Zero(t, env.controller.spanController.GetAbsentSize()) + + // The cleanup owner waits for a terminal status before dropping temporary coverage and + // creating the exact replacement range. + removeOp.Check("node1", &heartbeatpb.TableSpanStatus{ + ID: rejectedDispatcherID.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Stopped, + CheckpointTs: 10, + Mode: common.DefaultMode, + }) + require.True(t, removeOp.IsFinished()) + removeOp.PostFinish() + env.controller.operatorController.RemoveOp(rejectedDispatcherID) + require.Nil(t, env.controller.spanController.GetTaskByID(rejectedDispatcherID)) require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) require.Equal(t, 1, env.controller.spanController.GetAbsentSize()) @@ -1874,6 +1896,152 @@ func TestFinishBootstrapRemovesUnexpectedOverlappingWorkingSpan(t *testing.T) { require.Equal(t, env.mergedSpan.EndKey, repairedTail.Span.EndKey) } +// TestFinishBootstrapAbortsUncommittedMergeWhenSourceMissing covers failover before the merge +// commit point. For Preparing and MergeReady targets, dispatcher manager aborts when a source is +// missing; bootstrap must keep the target only as temporary coverage and repair after it stops. +func TestFinishBootstrapAbortsUncommittedMergeWhenSourceMissing(t *testing.T) { + for _, targetStatus := range []heartbeatpb.ComponentState{ + heartbeatpb.ComponentState_Preparing, + heartbeatpb.ComponentState_MergeReady, + } { + t.Run(targetStatus.String(), func(t *testing.T) { + env := newMergeBootstrapTestEnv(t) + + _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ + "node1": { + ChangefeedID: env.cfID.ToPB(), + Spans: []*heartbeatpb.BootstrapTableSpan{ + { + ID: env.sourceDispatcherID1.ToPB(), + SchemaID: 1, + Span: env.sourceSpan1, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: env.mergedDispatcherID.ToPB(), + SchemaID: 1, + Span: env.mergedSpan, + ComponentStatus: targetStatus, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }, + MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ + { + ChangefeedID: env.cfID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{ + env.sourceDispatcherID1.ToPB(), + env.sourceDispatcherID2.ToPB(), + }, + MergedDispatcherID: env.mergedDispatcherID.ToPB(), + Mode: common.DefaultMode, + }, + }, + CheckpointTs: 10, + }, + }, false) + require.NoError(t, err) + require.Zero(t, env.controller.spanController.GetAbsentSize()) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) + + removeOp := env.controller.operatorController.GetOperator(env.mergedDispatcherID) + require.NotNil(t, removeOp) + require.Equal(t, "remove", removeOp.Type()) + removeOp.Check("node1", &heartbeatpb.TableSpanStatus{ + ID: env.mergedDispatcherID.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Stopped, + CheckpointTs: 10, + Mode: common.DefaultMode, + }) + require.True(t, removeOp.IsFinished()) + removeOp.PostFinish() + env.controller.operatorController.RemoveOp(env.mergedDispatcherID) + + require.Nil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) + require.Equal(t, 1, env.controller.spanController.GetAbsentSize()) + }) + } +} + +// TestFinishBootstrapRejectsInvalidMergeJournalGeometry covers a stale journal whose source spans +// are not consecutive. Bootstrap must not use dispatcher IDs alone as overlap proof; it removes the +// uncommitted target and creates only the real source gap after the target reaches terminal. +func TestFinishBootstrapRejectsInvalidMergeJournalGeometry(t *testing.T) { + env := newMergeBootstrapTestEnv(t) + gapEnd := appendNew(env.sourceSpan1.EndKey, 'b') + env.sourceSpan2.StartKey = gapEnd + + _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ + "node1": { + ChangefeedID: env.cfID.ToPB(), + Spans: []*heartbeatpb.BootstrapTableSpan{ + { + ID: env.sourceDispatcherID1.ToPB(), + SchemaID: 1, + Span: env.sourceSpan1, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: env.sourceDispatcherID2.ToPB(), + SchemaID: 1, + Span: env.sourceSpan2, + ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + { + ID: env.mergedDispatcherID.ToPB(), + SchemaID: 1, + Span: env.mergedSpan, + ComponentStatus: heartbeatpb.ComponentState_Preparing, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }, + MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ + { + ChangefeedID: env.cfID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{ + env.sourceDispatcherID1.ToPB(), + env.sourceDispatcherID2.ToPB(), + }, + MergedDispatcherID: env.mergedDispatcherID.ToPB(), + Mode: common.DefaultMode, + }, + }, + CheckpointTs: 10, + }, + }, false) + require.NoError(t, err) + require.Zero(t, env.controller.spanController.GetAbsentSize()) + + removeOp := env.controller.operatorController.GetOperator(env.mergedDispatcherID) + require.NotNil(t, removeOp) + require.Equal(t, "remove", removeOp.Type()) + removeOp.Check("node1", &heartbeatpb.TableSpanStatus{ + ID: env.mergedDispatcherID.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Removed, + CheckpointTs: 10, + Mode: common.DefaultMode, + }) + require.True(t, removeOp.IsFinished()) + removeOp.PostFinish() + env.controller.operatorController.RemoveOp(env.mergedDispatcherID) + + require.Nil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID2)) + require.Equal(t, 2, env.controller.spanController.GetReplicatingSize()) + require.Equal(t, 1, env.controller.spanController.GetAbsentSize()) +} + type mergeBootstrapTestEnv struct { controller *Controller cfID common.ChangeFeedID @@ -2064,8 +2232,8 @@ func TestFinishBootstrapSkipsIncompleteMergeJournalWithoutMergedDispatcher(t *te // TestFinishBootstrapSkipsMergeJournalConflictingWithWorkingOperator covers non-atomic bootstrap // snapshots where a stale merge journal overlaps a newer create or remove request. Each subtest -// restores the regular operator first, then verifies merge recovery yields to it without failing -// FinishBootstrap or installing a merge operator. +// restores the regular operator first, then verifies merge recovery yields to it and gives the +// uncommitted merged target a cleanup owner instead of leaving unmanaged overlapping desired state. func TestFinishBootstrapSkipsMergeJournalConflictingWithWorkingOperator(t *testing.T) { testCases := []struct { name string @@ -2162,8 +2330,11 @@ func TestFinishBootstrapSkipsMergeJournalConflictingWithWorkingOperator(t *testi workingOp := env.controller.operatorController.GetOperator(env.sourceDispatcherID1) require.NotNil(t, workingOp) require.Equal(t, tc.expectedOperatorType, workingOp.Type()) - require.Nil(t, env.controller.operatorController.GetOperator(env.mergedDispatcherID)) - require.Equal(t, 1, env.controller.operatorController.OperatorSize()) + mergedCleanupOp := env.controller.operatorController.GetOperator(env.mergedDispatcherID) + require.NotNil(t, mergedCleanupOp) + require.Equal(t, "remove", mergedCleanupOp.Type()) + require.Equal(t, 2, env.controller.operatorController.OperatorSize()) + require.Zero(t, env.controller.spanController.GetAbsentSize()) }) } } From 8d17152e7b6e06596df259286f466c72a7bbbcba Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Wed, 8 Jul 2026 19:01:31 +0800 Subject: [PATCH 20/25] maintainer,downstreamadapter: fix merge failover epoch --- .../dispatcher_manager_merge.go | 3 +- .../dispatcher_manager_test.go | 59 +++++++++++++++++++ .../dispatchermanager/heartbeat_collector.go | 5 +- maintainer/operator/operator_controller.go | 8 ++- .../operator/operator_controller_test.go | 39 ++++++++++++ maintainer/operator/operator_merge.go | 3 + 6 files changed, 112 insertions(+), 5 deletions(-) diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go b/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go index f3b4937a78..35565a87d4 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go @@ -153,7 +153,8 @@ func cloneMergeDispatcherRequest(req *heartbeatpb.MergeDispatcherRequest) *heart return nil } clone := &heartbeatpb.MergeDispatcherRequest{ - Mode: req.Mode, + Mode: req.Mode, + MaintainerEpoch: req.MaintainerEpoch, } if req.ChangefeedID != nil { id := *req.ChangefeedID diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go index 22dc33ccbc..e1eff5ef8a 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go @@ -1063,6 +1063,65 @@ func TestDoMergeKeepsMergeJournalUntilSourcesAreCleaned(t *testing.T) { require.Empty(t, manager.GetMergeOperators()) } +func TestMergeDispatcherRequestRecvDoesNotTrackStaleMaintainerEpoch(t *testing.T) { + // Scenario: an old maintainer sends a delayed merge request after dispatcher manager + // ownership has moved to a newer epoch. + // Steps: receive the request through HeartBeatCollector and verify the journal is not + // updated before the dynamic stream handler applies its epoch fence. + manager := createTestManager(t) + require.True(t, manager.TryUpdateMaintainer("current-maintainer", 2)) + + collector := &HeartBeatCollector{ + mergeDispatcherRequestDynamicStream: newMergeDispatcherRequestDynamicStream(), + } + defer collector.mergeDispatcherRequestDynamicStream.Close() + require.NoError(t, collector.mergeDispatcherRequestDynamicStream.AddPath(manager.changefeedID.Id, manager)) + collector.dispatcherManagers.Store(manager.changefeedID.Id, manager) + + mergeReq := &heartbeatpb.MergeDispatcherRequest{ + ChangefeedID: manager.changefeedID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{ + common.NewDispatcherID().ToPB(), + common.NewDispatcherID().ToPB(), + }, + MergedDispatcherID: common.NewDispatcherID().ToPB(), + Mode: common.DefaultMode, + MaintainerEpoch: 1, + } + msg := messaging.NewSingleTargetMessage( + "receiver", + messaging.HeartbeatCollectorTopic, + mergeReq, + ) + msg.From = "old-maintainer" + + require.NoError(t, collector.RecvMessages(context.Background(), msg)) + require.Empty(t, manager.GetMergeOperators()) +} + +func TestTrackMergeOperatorPreservesMaintainerEpoch(t *testing.T) { + // Scenario: bootstrap later reads a cloned in-flight merge request from the journal. + // Steps: track a strict-epoch request, fetch it back, and verify the cloned request + // still carries the epoch needed by downstream admission checks. + manager := createTestManager(t) + mergeReq := &heartbeatpb.MergeDispatcherRequest{ + ChangefeedID: manager.changefeedID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{ + common.NewDispatcherID().ToPB(), + common.NewDispatcherID().ToPB(), + }, + MergedDispatcherID: common.NewDispatcherID().ToPB(), + Mode: common.DefaultMode, + MaintainerEpoch: 7, + } + + manager.TrackMergeOperator(mergeReq) + + operators := manager.GetMergeOperators() + require.Len(t, operators, 1) + require.Equal(t, uint64(7), operators[0].MaintainerEpoch) +} + // TestTrackMergeOperatorRejectsZeroMergedDispatcherID covers a malformed merge request. // The test tracks a request with an all-zero merged ID and verifies it cannot occupy the shared // zero-value map key or appear in later bootstrap responses. diff --git a/downstreamadapter/dispatchermanager/heartbeat_collector.go b/downstreamadapter/dispatchermanager/heartbeat_collector.go index df2c587b02..8c4a637e1f 100644 --- a/downstreamadapter/dispatchermanager/heartbeat_collector.go +++ b/downstreamadapter/dispatchermanager/heartbeat_collector.go @@ -292,9 +292,8 @@ func (c *HeartBeatCollector) RecvMessages(_ context.Context, msg *messaging.Targ NewRedoMetaMessage(msg.From, redoMessage)) case messaging.TypeMergeDispatcherRequest: mergeDispatcherRequest := msg.Message[0].(*heartbeatpb.MergeDispatcherRequest) - if manager, ok := c.dispatcherManagers.Load(common.NewChangefeedGIDFromPB(mergeDispatcherRequest.ChangefeedID)); ok { - manager.(*DispatcherManager).TrackMergeOperator(mergeDispatcherRequest) - } + // The handler owns journaling because it first applies the maintainer fence. + // Tracking here would let stale requests leak into bootstrap recovery. c.mergeDispatcherRequestDynamicStream.Push( common.NewChangefeedGIDFromPB(mergeDispatcherRequest.ChangefeedID), NewMergeDispatcherRequest(msg.From, mergeDispatcherRequest)) diff --git a/maintainer/operator/operator_controller.go b/maintainer/operator/operator_controller.go index 0332dd4d35..a66709d3e1 100644 --- a/maintainer/operator/operator_controller.go +++ b/maintainer/operator/operator_controller.go @@ -657,7 +657,13 @@ func (oc *Controller) AddRestoredMergeOperator( } } - mergeOperator := NewRestoredMergeDispatcherOperator(oc.spanController, affectedReplicaSets, mergedReplicaSet, operators) + mergeOperator := NewRestoredMergeDispatcherOperator( + oc.spanController, + affectedReplicaSets, + mergedReplicaSet, + operators, + oc.MaintainerEpoch(), + ) ret := oc.AddOperator(mergeOperator) if !ret { log.Error("failed to add merge dispatcher operator when restoring merge", diff --git a/maintainer/operator/operator_controller_test.go b/maintainer/operator/operator_controller_test.go index 32f9a77f3f..c299af907a 100644 --- a/maintainer/operator/operator_controller_test.go +++ b/maintainer/operator/operator_controller_test.go @@ -337,6 +337,45 @@ func TestMergeDispatcherOperatorScheduleMaintainerEpoch(t *testing.T) { require.Equal(t, uint64(7), req.MaintainerEpoch) } +func TestControllerRestoredMergeOperatorScheduleMaintainerEpoch(t *testing.T) { + // Scenario: bootstrap restores an in-flight merge after maintainer failover. + // Steps: restore the merge through the controller, schedule it, and verify the request + // carries the controller epoch instead of the zero value. + messageCenter, _, _ := messaging.NewMessageCenterForTest(t) + appcontext.SetService(appcontext.MessageCenter, messageCenter) + + spanController, toMergedReplicaSets, _, nodeA := setupMergeTestEnvironment(t) + nodeManager := appcontext.GetService[*watcher.NodeManager](watcher.NodeManagerName) + setAliveNodes(nodeManager, map[node.ID]*node.Info{nodeA: {ID: nodeA}}) + + oc := NewOperatorController(toMergedReplicaSets[0].ChangefeedID, spanController, 1, common.DefaultMode) + oc.SetMaintainerEpoch(7) + + mergedSpan := &heartbeatpb.TableSpan{ + TableID: toMergedReplicaSets[0].Span.TableID, + StartKey: toMergedReplicaSets[0].Span.StartKey, + EndKey: toMergedReplicaSets[len(toMergedReplicaSets)-1].Span.EndKey, + } + mergedReplicaSet := replica.NewSpanReplication( + toMergedReplicaSets[0].ChangefeedID, + common.NewDispatcherID(), + toMergedReplicaSets[0].GetSchemaID(), + mergedSpan, + toMergedReplicaSets[0].GetStatus().CheckpointTs, + common.DefaultMode, + toMergedReplicaSets[0].IsSplitEnabled(), + ) + spanController.AddSchedulingReplicaSet(mergedReplicaSet, nodeA) + + op := oc.AddRestoredMergeOperator(toMergedReplicaSets, mergedReplicaSet) + require.NotNil(t, op) + msg := op.Schedule() + require.NotNil(t, msg) + + req := msg.Message[0].(*heartbeatpb.MergeDispatcherRequest) + require.Equal(t, uint64(7), req.MaintainerEpoch) +} + func TestController_RemoveReplicaSet_ReplacesRemoveOperatorOnTaskRemoved(t *testing.T) { // Scenario: the barrier can enqueue the same remove task multiple times during failover/bootstrap. // Steps: diff --git a/maintainer/operator/operator_merge.go b/maintainer/operator/operator_merge.go index 585548dc2c..39e4afa1fc 100644 --- a/maintainer/operator/operator_merge.go +++ b/maintainer/operator/operator_merge.go @@ -154,11 +154,13 @@ func NewMergeDispatcherOperator( } // NewRestoredMergeDispatcherOperator builds a merge operator whose occupy sub-operators were restored from bootstrap. +// The restored operator must keep the current maintainer epoch so dispatcher-manager fences accept its requests. func NewRestoredMergeDispatcherOperator( spanController *span.Controller, toMergedReplicaSets []*replica.SpanReplication, mergedReplicaSet *replica.SpanReplication, occupyOperators []operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus], + maintainerEpoch uint64, ) *MergeDispatcherOperator { toMergedSpans := make([]*heartbeatpb.TableSpan, 0, len(toMergedReplicaSets)) for _, replicaSet := range toMergedReplicaSets { @@ -173,6 +175,7 @@ func NewRestoredMergeDispatcherOperator( originNode: toMergedReplicaSets[0].GetNodeID(), id: mergedReplicaSet.ID, dispatcherIDs: dispatcherIDs, + maintainerEpoch: maintainerEpoch, toMergedReplicaSets: toMergedReplicaSets, checkpointTs: 0, mergedSpanInfo: spansInfo, From 0fb11444f7e98c1882f5c72f5c2f92cbf38dd672 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 16 Jul 2026 14:35:33 +0800 Subject: [PATCH 21/25] maintainer,downstreamadapter: simplify merge recovery code --- .../dispatcher_manager_merge.go | 34 +------ .../dispatcher_manager_test.go | 22 +++-- .../dispatchermanager/heartbeat_collector.go | 4 - maintainer/maintainer_controller_bootstrap.go | 4 +- maintainer/operator/operator_controller.go | 78 ++++++++-------- maintainer/operator/operator_merge.go | 93 ++++++++----------- 6 files changed, 98 insertions(+), 137 deletions(-) diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go b/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go index 35565a87d4..b2921c1b1f 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_merge.go @@ -14,6 +14,7 @@ package dispatchermanager import ( + "github.com/gogo/protobuf/proto" "github.com/pingcap/log" "github.com/pingcap/ticdc/downstreamadapter/dispatcher" "github.com/pingcap/ticdc/heartbeatpb" @@ -33,7 +34,7 @@ func (e *DispatcherManager) TrackMergeOperator(req *heartbeatpb.MergeDispatcherR zap.Int64("mode", req.Mode)) return } - e.mergeOperatorMap.Store(mergedID.String(), cloneMergeDispatcherRequest(req)) + e.mergeOperatorMap.Store(mergedID.String(), proto.Clone(req).(*heartbeatpb.MergeDispatcherRequest)) } // RemoveMergeOperator drops a persisted merge request that no longer needs bootstrap recovery. @@ -142,37 +143,8 @@ func (e *DispatcherManager) GetMergeOperators() []*heartbeatpb.MergeDispatcherRe if !ok || req == nil { return true } - operators = append(operators, cloneMergeDispatcherRequest(req)) + operators = append(operators, proto.Clone(req).(*heartbeatpb.MergeDispatcherRequest)) return true }) return operators } - -func cloneMergeDispatcherRequest(req *heartbeatpb.MergeDispatcherRequest) *heartbeatpb.MergeDispatcherRequest { - if req == nil { - return nil - } - clone := &heartbeatpb.MergeDispatcherRequest{ - Mode: req.Mode, - MaintainerEpoch: req.MaintainerEpoch, - } - 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 -} diff --git a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go index e1eff5ef8a..d53dafc213 100644 --- a/downstreamadapter/dispatchermanager/dispatcher_manager_test.go +++ b/downstreamadapter/dispatchermanager/dispatcher_manager_test.go @@ -1076,7 +1076,6 @@ func TestMergeDispatcherRequestRecvDoesNotTrackStaleMaintainerEpoch(t *testing.T } defer collector.mergeDispatcherRequestDynamicStream.Close() require.NoError(t, collector.mergeDispatcherRequestDynamicStream.AddPath(manager.changefeedID.Id, manager)) - collector.dispatcherManagers.Store(manager.changefeedID.Id, manager) mergeReq := &heartbeatpb.MergeDispatcherRequest{ ChangefeedID: manager.changefeedID.ToPB(), @@ -1099,15 +1098,16 @@ func TestMergeDispatcherRequestRecvDoesNotTrackStaleMaintainerEpoch(t *testing.T require.Empty(t, manager.GetMergeOperators()) } -func TestTrackMergeOperatorPreservesMaintainerEpoch(t *testing.T) { - // Scenario: bootstrap later reads a cloned in-flight merge request from the journal. - // Steps: track a strict-epoch request, fetch it back, and verify the cloned request - // still carries the epoch needed by downstream admission checks. +// TestTrackMergeOperatorClonesRequest verifies that the merge journal owns its request data. +// It mutates the original request and one returned snapshot, then confirms later reads retain +// the tracked epoch and nested dispatcher IDs. +func TestTrackMergeOperatorClonesRequest(t *testing.T) { manager := createTestManager(t) + sourceDispatcherID := common.NewDispatcherID() mergeReq := &heartbeatpb.MergeDispatcherRequest{ ChangefeedID: manager.changefeedID.ToPB(), DispatcherIDs: []*heartbeatpb.DispatcherID{ - common.NewDispatcherID().ToPB(), + sourceDispatcherID.ToPB(), common.NewDispatcherID().ToPB(), }, MergedDispatcherID: common.NewDispatcherID().ToPB(), @@ -1116,10 +1116,20 @@ func TestTrackMergeOperatorPreservesMaintainerEpoch(t *testing.T) { } manager.TrackMergeOperator(mergeReq) + mergeReq.MaintainerEpoch = 8 + mergeReq.DispatcherIDs[0].Low ^= 1 operators := manager.GetMergeOperators() require.Len(t, operators, 1) require.Equal(t, uint64(7), operators[0].MaintainerEpoch) + require.Equal(t, sourceDispatcherID.ToPB(), operators[0].DispatcherIDs[0]) + + operators[0].MaintainerEpoch = 9 + operators[0].DispatcherIDs[0].Low ^= 1 + operators = manager.GetMergeOperators() + require.Len(t, operators, 1) + require.Equal(t, uint64(7), operators[0].MaintainerEpoch) + require.Equal(t, sourceDispatcherID.ToPB(), operators[0].DispatcherIDs[0]) } // TestTrackMergeOperatorRejectsZeroMergedDispatcherID covers a malformed merge request. diff --git a/downstreamadapter/dispatchermanager/heartbeat_collector.go b/downstreamadapter/dispatchermanager/heartbeat_collector.go index 8c4a637e1f..2d23b741b0 100644 --- a/downstreamadapter/dispatchermanager/heartbeat_collector.go +++ b/downstreamadapter/dispatchermanager/heartbeat_collector.go @@ -60,8 +60,6 @@ type HeartBeatCollector struct { mergeDispatcherRequestDynamicStream dynstream.DynamicStream[int, common.GID, MergeDispatcherRequest, *DispatcherManager, *MergeDispatcherRequestHandler] mc messaging.MessageCenter - dispatcherManagers sync.Map // map[common.GID]*DispatcherManager - wg sync.WaitGroup cancel context.CancelFunc isClosed atomic.Bool @@ -130,7 +128,6 @@ func (c *HeartBeatCollector) RegisterDispatcherManager(m *DispatcherManager) err if err != nil { return errors.Trace(err) } - c.dispatcherManagers.Store(m.changefeedID.Id, m) return nil } @@ -173,7 +170,6 @@ func (c *HeartBeatCollector) RemoveDispatcherManager(id common.ChangeFeedID) err if err != nil { return errors.Trace(err) } - c.dispatcherManagers.Delete(id.Id) return nil } diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 8a822e5b7f..39ab831a3a 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -1561,8 +1561,7 @@ func (c *Controller) restoreCurrentMergeOperators( continue } - mergeOp := operatorController.AddRestoredMergeOperator(sourceReplicaSets, mergedReplicaSet) - if mergeOp == nil { + if operatorController.AddRestoredMergeOperator(sourceReplicaSets, mergedReplicaSet) == nil { log.Warn("skip stale merge operator that cannot be restored", zap.String("nodeID", nodeID.String()), zap.String("changefeed", resp.ChangefeedID.String()), @@ -1577,7 +1576,6 @@ func (c *Controller) restoreCurrentMergeOperators( continue } spanController.MarkSpanScheduling(mergedReplicaSet) - mergeOp.Start() } } return nil diff --git a/maintainer/operator/operator_controller.go b/maintainer/operator/operator_controller.go index a66709d3e1..46287450a5 100644 --- a/maintainer/operator/operator_controller.go +++ b/maintainer/operator/operator_controller.go @@ -576,6 +576,36 @@ func checkMergeOperator(affectedReplicaSets []*replica.SpanReplication) bool { return true } +// addMergeOccupyOperators reserves every source replica or rolls back the partial reservation. +func (oc *Controller) addMergeOccupyOperators( + affectedReplicaSets []*replica.SpanReplication, +) ([]operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus], bool) { + operators := make([]operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus], 0, len(affectedReplicaSets)) + for _, replicaSet := range affectedReplicaSets { + occupyOperator := NewOccupyDispatcherOperator(oc.spanController, replicaSet) + if oc.AddOperator(occupyOperator) { + operators = append(operators, occupyOperator) + continue + } + log.Error("failed to add occupy dispatcher operator", + zap.Stringer("changefeedID", oc.changefeedID), + zap.Int64("group", replicaSet.GetGroupID()), + zap.String("span", common.FormatTableSpan(replicaSet.Span)), + zap.String("operator", occupyOperator.String())) + oc.cancelMergeOccupyOperators(operators) + return nil, false + } + return operators, true +} + +func (oc *Controller) cancelMergeOccupyOperators( + operators []operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus], +) { + for _, op := range operators { + oc.cancelOperator(op.ID()) + } +} + // AddMergeOperator creates a merge operator, which merge consecutive replica sets. // We need create a mergeOperator for the new replicaset, and create len(affectedReplicaSets) empty operator // to occupy these replica set not evolve other scheduling among merging. @@ -586,23 +616,9 @@ func (oc *Controller) AddMergeOperator( return nil } - operators := make([]operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus], 0, len(affectedReplicaSets)) - for _, replicaSet := range affectedReplicaSets { - operator := NewOccupyDispatcherOperator(oc.spanController, replicaSet) - ret := oc.AddOperator(operator) - if ret { - operators = append(operators, operator) - } else { - log.Error("failed to add occupy dispatcher operator", - zap.Stringer("changefeedID", oc.changefeedID), - zap.Int64("group", replicaSet.GetGroupID()), - zap.String("span", common.FormatTableSpan(replicaSet.Span)), - zap.String("operator", operator.String())) - for _, op := range operators { - oc.cancelOperator(op.ID()) - } - return nil - } + operators, ok := oc.addMergeOccupyOperators(affectedReplicaSets) + if !ok { + return nil } mergeOperator := NewMergeDispatcherOperator(oc.spanController, affectedReplicaSets, operators, oc.MaintainerEpoch()) @@ -612,9 +628,7 @@ func (oc *Controller) AddMergeOperator( zap.Stringer("changefeedID", oc.changefeedID), zap.Any("mergeSpans", affectedReplicaSets), zap.String("operator", mergeOperator.String())) - for _, op := range operators { - oc.cancelOperator(op.ID()) - } + oc.cancelMergeOccupyOperators(operators) oc.spanController.RemoveReplicatingSpan(mergeOperator.newReplicaSet) return nil } @@ -638,23 +652,9 @@ func (oc *Controller) AddRestoredMergeOperator( return nil } - operators := make([]operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus], 0, len(affectedReplicaSets)) - for _, replicaSet := range affectedReplicaSets { - operator := NewOccupyDispatcherOperator(oc.spanController, replicaSet) - ret := oc.AddOperator(operator) - if ret { - operators = append(operators, operator) - } else { - log.Error("failed to add occupy dispatcher operator when restoring merge", - zap.Stringer("changefeedID", oc.changefeedID), - zap.Int64("group", replicaSet.GetGroupID()), - zap.String("span", common.FormatTableSpan(replicaSet.Span)), - zap.String("operator", operator.String())) - for _, op := range operators { - oc.cancelOperator(op.ID()) - } - return nil - } + operators, ok := oc.addMergeOccupyOperators(affectedReplicaSets) + if !ok { + return nil } mergeOperator := NewRestoredMergeDispatcherOperator( @@ -670,9 +670,7 @@ func (oc *Controller) AddRestoredMergeOperator( zap.Stringer("changefeedID", oc.changefeedID), zap.Any("mergeSpans", affectedReplicaSets), zap.String("operator", mergeOperator.String())) - for _, op := range operators { - oc.cancelOperator(op.ID()) - } + oc.cancelMergeOccupyOperators(operators) return nil } log.Info("restore merge operator", diff --git a/maintainer/operator/operator_merge.go b/maintainer/operator/operator_merge.go index 39e4afa1fc..e31e05cd74 100644 --- a/maintainer/operator/operator_merge.go +++ b/maintainer/operator/operator_merge.go @@ -63,9 +63,10 @@ type MergeDispatcherOperator struct { sendThrottler sendThrottler } -func buildMergedSpanInfo(toMergedSpans []*heartbeatpb.TableSpan) string { +func buildMergedSpanInfo(toMergedReplicaSets []*replica.SpanReplication) string { var spansInfo strings.Builder - for _, span := range toMergedSpans { + for _, replicaSet := range toMergedReplicaSets { + span := replicaSet.Span fmt.Fprintf(&spansInfo, "[%s,%s,%d]", hex.EncodeToString(span.StartKey), hex.EncodeToString(span.EndKey), span.TableID) } @@ -98,59 +99,64 @@ func minCheckpointTs(toMergedReplicaSets []*replica.SpanReplication) uint64 { return checkpointTs } -func NewMergeDispatcherOperator( +// newMergeDispatcherOperator initializes state shared by newly scheduled and restored merges. +// Callers remain responsible for creating and registering the merged replica set. +func newMergeDispatcherOperator( spanController *span.Controller, toMergedReplicaSets []*replica.SpanReplication, + mergedReplicaSet *replica.SpanReplication, occupyOperators []operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus], maintainerEpoch uint64, ) *MergeDispatcherOperator { - toMergedSpans := make([]*heartbeatpb.TableSpan, 0, len(toMergedReplicaSets)) - for _, replicaSet := range toMergedReplicaSets { - toMergedSpans = append(toMergedSpans, replicaSet.Span) + return &MergeDispatcherOperator{ + spanController: spanController, + originNode: toMergedReplicaSets[0].GetNodeID(), + id: mergedReplicaSet.ID, + dispatcherIDs: buildDispatcherIDs(toMergedReplicaSets), + maintainerEpoch: maintainerEpoch, + toMergedReplicaSets: toMergedReplicaSets, + mergedSpanInfo: buildMergedSpanInfo(toMergedReplicaSets), + occupyOperators: occupyOperators, + newReplicaSet: mergedReplicaSet, + sendThrottler: newSendThrottler(), } +} - nodeID := toMergedReplicaSets[0].GetNodeID() +// NewMergeDispatcherOperator creates a merge operator and registers its new target as scheduling. +func NewMergeDispatcherOperator( + spanController *span.Controller, + toMergedReplicaSets []*replica.SpanReplication, + occupyOperators []operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus], + maintainerEpoch uint64, +) *MergeDispatcherOperator { + firstReplicaSet := toMergedReplicaSets[0] + lastReplicaSet := toMergedReplicaSets[len(toMergedReplicaSets)-1] + nodeID := firstReplicaSet.GetNodeID() newDispatcherID := common.NewDispatcherID() - dispatcherIDs := buildDispatcherIDs(toMergedReplicaSets) - spansInfo := buildMergedSpanInfo(toMergedSpans) - // bind the new replica set to the node. mergeTableSpan := &heartbeatpb.TableSpan{ - TableID: toMergedSpans[0].TableID, - StartKey: toMergedSpans[0].StartKey, - EndKey: toMergedSpans[len(toMergedSpans)-1].EndKey, + TableID: firstReplicaSet.Span.TableID, + StartKey: firstReplicaSet.Span.StartKey, + EndKey: lastReplicaSet.Span.EndKey, KeyspaceID: spanController.GetkeyspaceID(), } checkpointTs := minCheckpointTs(toMergedReplicaSets) newReplicaSet := replica.NewSpanReplication( - toMergedReplicaSets[0].ChangefeedID, + firstReplicaSet.ChangefeedID, newDispatcherID, - toMergedReplicaSets[0].GetSchemaID(), + firstReplicaSet.GetSchemaID(), mergeTableSpan, checkpointTs, - toMergedReplicaSets[0].GetMode(), - toMergedReplicaSets[0].IsSplitEnabled()) + firstReplicaSet.GetMode(), + firstReplicaSet.IsSplitEnabled()) spanController.AddSchedulingReplicaSet(newReplicaSet, nodeID) - - op := &MergeDispatcherOperator{ - spanController: spanController, - originNode: nodeID, - id: newDispatcherID, - dispatcherIDs: dispatcherIDs, - maintainerEpoch: maintainerEpoch, - toMergedReplicaSets: toMergedReplicaSets, - checkpointTs: 0, - mergedSpanInfo: spansInfo, - occupyOperators: occupyOperators, - newReplicaSet: newReplicaSet, - sendThrottler: newSendThrottler(), - } - return op + return newMergeDispatcherOperator( + spanController, toMergedReplicaSets, newReplicaSet, occupyOperators, maintainerEpoch) } // NewRestoredMergeDispatcherOperator builds a merge operator whose occupy sub-operators were restored from bootstrap. @@ -162,27 +168,8 @@ func NewRestoredMergeDispatcherOperator( occupyOperators []operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus], maintainerEpoch uint64, ) *MergeDispatcherOperator { - toMergedSpans := make([]*heartbeatpb.TableSpan, 0, len(toMergedReplicaSets)) - for _, replicaSet := range toMergedReplicaSets { - toMergedSpans = append(toMergedSpans, replicaSet.Span) - } - - dispatcherIDs := buildDispatcherIDs(toMergedReplicaSets) - spansInfo := buildMergedSpanInfo(toMergedSpans) - - return &MergeDispatcherOperator{ - spanController: spanController, - originNode: toMergedReplicaSets[0].GetNodeID(), - id: mergedReplicaSet.ID, - dispatcherIDs: dispatcherIDs, - maintainerEpoch: maintainerEpoch, - toMergedReplicaSets: toMergedReplicaSets, - checkpointTs: 0, - mergedSpanInfo: spansInfo, - occupyOperators: occupyOperators, - newReplicaSet: mergedReplicaSet, - sendThrottler: newSendThrottler(), - } + return newMergeDispatcherOperator( + spanController, toMergedReplicaSets, mergedReplicaSet, occupyOperators, maintainerEpoch) } func setOccupyOperatorsFinished(occupyOperators []operator.Operator[common.DispatcherID, *heartbeatpb.TableSpanStatus]) { From 791c9aa4b09058565e3ea2e9551aa4307a6b5386 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 16 Jul 2026 14:46:43 +0800 Subject: [PATCH 22/25] maintainer: apply bootstrap formatting --- maintainer/maintainer_controller_bootstrap.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 39ab831a3a..62d7911d44 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -1421,8 +1421,7 @@ func (c *Controller) restoreCurrentMergeOperators( } } - conflictingDispatcherID, conflictingOperatorType, hasConflict := - findBootstrapMergeOperatorConflict(operatorController, sourceReplicaSets, mergedDispatcherID) + conflictingDispatcherID, conflictingOperatorType, hasConflict := findBootstrapMergeOperatorConflict(operatorController, sourceReplicaSets, mergedDispatcherID) if hasConflict { // Regular create/remove recovery has higher priority than a merge journal because it // represents a later concrete action for the same dispatcher. Treat the merge record From 0a30573366f1d8277c3bcc5610e47b7e2fda223c Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 16 Jul 2026 17:40:55 +0800 Subject: [PATCH 23/25] maintainer: simplify merge bootstrap tests Centralize repeated bootstrap fixtures while preserving scenario coverage. --- maintainer/maintainer_controller_test.go | 823 +++++++---------------- 1 file changed, 240 insertions(+), 583 deletions(-) diff --git a/maintainer/maintainer_controller_test.go b/maintainer/maintainer_controller_test.go index 7d18e94f4e..af99e84373 100644 --- a/maintainer/maintainer_controller_test.go +++ b/maintainer/maintainer_controller_test.go @@ -1620,120 +1620,28 @@ func TestFinishBootstrapSkipsStaleCreateOperatorForDroppedTable(t *testing.T) { // create a fresh absent table task; instead it should rebuild the merge-related tasks/operators // from the bootstrap snapshot. func TestFinishBootstrapRestoresInFlightMergeWithoutDuplicateCoverage(t *testing.T) { - testutil.SetUpTestServices(t) - nodeManager := appcontext.GetService[*watcher.NodeManager](watcher.NodeManagerName) - nodeManager.GetAliveNodes()["node1"] = &node.Info{ID: "node1"} - - tableTriggerEventDispatcherID := common.NewDispatcherID() - cfID := common.NewChangeFeedIDWithName("test", common.DefaultKeyspaceName) - ddlSpan := replica.NewWorkingSpanReplication(cfID, tableTriggerEventDispatcherID, - common.DDLSpanSchemaID, - common.KeyspaceDDLSpan(common.DefaultKeyspaceID), &heartbeatpb.TableSpanStatus{ - ID: tableTriggerEventDispatcherID.ToPB(), - ComponentStatus: heartbeatpb.ComponentState_Working, - CheckpointTs: 1, - }, "node1", false) - - cfg := config.GetDefaultReplicaConfig().Clone() - cfg.Scheduler = &config.ChangefeedSchedulerConfig{ - EnableTableAcrossNodes: util.AddressOf(true), - BalanceScoreThreshold: util.AddressOf(1), - MinTrafficPercentage: util.AddressOf(0.8), - MaxTrafficPercentage: util.AddressOf(1.2), - } - refresher := replica.NewRegionCountRefresher(cfID, time.Minute) - s := NewController(cfID, 1, &mockThreadPool{}, cfg, ddlSpan, nil, 1000, 0, refresher, common.DefaultKeyspace, false, testBalanceMoveBatchSize, 0) - - schemaStore := eventservice.NewMockSchemaStore() - schemaStore.SetTables([]commonEvent.Table{ - { - TableID: 1, - SchemaID: 1, - Splitable: true, - SchemaTableName: &commonEvent.SchemaTableName{SchemaName: "test", TableName: "t1"}, - }, - }) - appcontext.SetService(appcontext.SchemaStore, schemaStore) - - totalSpan := common.TableIDToComparableSpan(common.DefaultKeyspaceID, 1) - midKey := appendNew(totalSpan.StartKey, 'a') - sourceSpan1 := &heartbeatpb.TableSpan{ - TableID: 1, - StartKey: totalSpan.StartKey, - EndKey: midKey, - KeyspaceID: common.DefaultKeyspaceID, - } - sourceSpan2 := &heartbeatpb.TableSpan{ - TableID: 1, - StartKey: midKey, - EndKey: totalSpan.EndKey, - KeyspaceID: common.DefaultKeyspaceID, - } - mergedSpan := &heartbeatpb.TableSpan{ - TableID: 1, - StartKey: totalSpan.StartKey, - EndKey: totalSpan.EndKey, - KeyspaceID: common.DefaultKeyspaceID, - } - - sourceDispatcherID1 := common.NewDispatcherID() - sourceDispatcherID2 := common.NewDispatcherID() - mergedDispatcherID := common.NewDispatcherID() + env := newMergeBootstrapTestEnv(t) - _, err := s.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ - "node1": { - ChangefeedID: cfID.ToPB(), - Spans: []*heartbeatpb.BootstrapTableSpan{ - { - ID: sourceDispatcherID1.ToPB(), - SchemaID: 1, - Span: sourceSpan1, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: sourceDispatcherID2.ToPB(), - SchemaID: 1, - Span: sourceSpan2, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: mergedDispatcherID.ToPB(), - SchemaID: 1, - Span: mergedSpan, - ComponentStatus: heartbeatpb.ComponentState_Preparing, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - }, - MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ - { - ChangefeedID: cfID.ToPB(), - DispatcherIDs: []*heartbeatpb.DispatcherID{sourceDispatcherID1.ToPB(), sourceDispatcherID2.ToPB()}, - MergedDispatcherID: mergedDispatcherID.ToPB(), - Mode: common.DefaultMode, - }, - }, - CheckpointTs: 10, - }, - }, false) + _, err := env.controller.FinishBootstrap(env.bootstrapResponses( + []*heartbeatpb.MergeDispatcherRequest{env.mergeRequest()}, + env.bootstrapSpan(env.sourceDispatcherID1, env.sourceSpan1, heartbeatpb.ComponentState_WaitingMerge), + env.bootstrapSpan(env.sourceDispatcherID2, env.sourceSpan2, heartbeatpb.ComponentState_WaitingMerge), + env.bootstrapSpan(env.mergedDispatcherID, env.mergedSpan, heartbeatpb.ComponentState_Preparing), + ), false) require.NoError(t, err) - require.True(t, s.bootstrapped) + require.True(t, env.controller.bootstrapped) // No extra absent table span should be created during bootstrap; only the two source spans and // the restored merged target should exist. - require.Zero(t, s.spanController.GetAbsentSize()) - require.Equal(t, 3, len(s.spanController.GetTasksByTableID(1))) - require.Equal(t, 3, s.spanController.GetSchedulingSize()) - require.Zero(t, s.spanController.GetReplicatingSize()) - require.NotNil(t, s.spanController.GetTaskByID(sourceDispatcherID1)) - require.NotNil(t, s.spanController.GetTaskByID(sourceDispatcherID2)) - require.NotNil(t, s.spanController.GetTaskByID(mergedDispatcherID)) - - mergeOp := s.operatorController.GetOperator(mergedDispatcherID) + require.Zero(t, env.controller.spanController.GetAbsentSize()) + require.Equal(t, 3, len(env.controller.spanController.GetTasksByTableID(1))) + require.Equal(t, 3, env.controller.spanController.GetSchedulingSize()) + require.Zero(t, env.controller.spanController.GetReplicatingSize()) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID2)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) + + mergeOp := env.controller.operatorController.GetOperator(env.mergedDispatcherID) require.NotNil(t, mergeOp) _, ok := mergeOp.(*operator.MergeDispatcherOperator) require.True(t, ok) @@ -1744,110 +1652,26 @@ func TestFinishBootstrapRestoresInFlightMergeWithoutDuplicateCoverage(t *testing // journal, but the old source dispatchers are still waiting to be cleaned up. Bootstrap must still // treat the overlapping spans as complete coverage and avoid creating absent hole tasks. func TestFinishBootstrapKeepsOverlapCoveredAfterMergeJournalCleanup(t *testing.T) { - testutil.SetUpTestServices(t) - nodeManager := appcontext.GetService[*watcher.NodeManager](watcher.NodeManagerName) - nodeManager.GetAliveNodes()["node1"] = &node.Info{ID: "node1"} - - tableTriggerEventDispatcherID := common.NewDispatcherID() - cfID := common.NewChangeFeedIDWithName("test", common.DefaultKeyspaceName) - ddlSpan := replica.NewWorkingSpanReplication(cfID, tableTriggerEventDispatcherID, - common.DDLSpanSchemaID, - common.KeyspaceDDLSpan(common.DefaultKeyspaceID), &heartbeatpb.TableSpanStatus{ - ID: tableTriggerEventDispatcherID.ToPB(), - ComponentStatus: heartbeatpb.ComponentState_Working, - CheckpointTs: 1, - }, "node1", false) - - cfg := config.GetDefaultReplicaConfig().Clone() - cfg.Scheduler = &config.ChangefeedSchedulerConfig{ - EnableTableAcrossNodes: util.AddressOf(true), - BalanceScoreThreshold: util.AddressOf(1), - MinTrafficPercentage: util.AddressOf(0.8), - MaxTrafficPercentage: util.AddressOf(1.2), - } - refresher := replica.NewRegionCountRefresher(cfID, time.Minute) - s := NewController(cfID, 1, &mockThreadPool{}, cfg, ddlSpan, nil, 1000, 0, refresher, common.DefaultKeyspace, false, testBalanceMoveBatchSize, 0) - - schemaStore := eventservice.NewMockSchemaStore() - schemaStore.SetTables([]commonEvent.Table{ - { - TableID: 1, - SchemaID: 1, - Splitable: true, - SchemaTableName: &commonEvent.SchemaTableName{SchemaName: "test", TableName: "t1"}, - }, - }) - appcontext.SetService(appcontext.SchemaStore, schemaStore) - - totalSpan := common.TableIDToComparableSpan(common.DefaultKeyspaceID, 1) - midKey := appendNew(totalSpan.StartKey, 'a') - sourceSpan1 := &heartbeatpb.TableSpan{ - TableID: 1, - StartKey: totalSpan.StartKey, - EndKey: midKey, - KeyspaceID: common.DefaultKeyspaceID, - } - sourceSpan2 := &heartbeatpb.TableSpan{ - TableID: 1, - StartKey: midKey, - EndKey: totalSpan.EndKey, - KeyspaceID: common.DefaultKeyspaceID, - } - mergedSpan := &heartbeatpb.TableSpan{ - TableID: 1, - StartKey: totalSpan.StartKey, - EndKey: totalSpan.EndKey, - KeyspaceID: common.DefaultKeyspaceID, - } - - sourceDispatcherID1 := common.NewDispatcherID() - sourceDispatcherID2 := common.NewDispatcherID() - mergedDispatcherID := common.NewDispatcherID() + env := newMergeBootstrapTestEnv(t) // Scenario: // 1. Source dispatchers are already in WaitingMerge and still present in bootstrap spans. // 2. The merged dispatcher is committed and visible as Initializing. // 3. The persisted merge operator is already gone, so bootstrap only has overlapping coverage. // Expectation: FinishBootstrap succeeds without adding absent spans for fake holes. - _, err := s.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ - "node1": { - ChangefeedID: cfID.ToPB(), - Spans: []*heartbeatpb.BootstrapTableSpan{ - { - ID: sourceDispatcherID1.ToPB(), - SchemaID: 1, - Span: sourceSpan1, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: sourceDispatcherID2.ToPB(), - SchemaID: 1, - Span: sourceSpan2, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: mergedDispatcherID.ToPB(), - SchemaID: 1, - Span: mergedSpan, - ComponentStatus: heartbeatpb.ComponentState_Initializing, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - }, - CheckpointTs: 10, - }, - }, false) + _, err := env.controller.FinishBootstrap(env.bootstrapResponses( + nil, + env.bootstrapSpan(env.sourceDispatcherID1, env.sourceSpan1, heartbeatpb.ComponentState_WaitingMerge), + env.bootstrapSpan(env.sourceDispatcherID2, env.sourceSpan2, heartbeatpb.ComponentState_WaitingMerge), + env.bootstrapSpan(env.mergedDispatcherID, env.mergedSpan, heartbeatpb.ComponentState_Initializing), + ), false) require.NoError(t, err) - require.True(t, s.bootstrapped) - require.Zero(t, s.spanController.GetAbsentSize()) - require.GreaterOrEqual(t, len(s.spanController.GetTasksByTableID(1)), 2) - require.GreaterOrEqual(t, s.spanController.GetReplicatingSize(), 2) - require.Zero(t, s.spanController.GetSchedulingSize()) - require.NotNil(t, s.spanController.GetTaskByID(mergedDispatcherID)) + require.True(t, env.controller.bootstrapped) + require.Zero(t, env.controller.spanController.GetAbsentSize()) + require.GreaterOrEqual(t, len(env.controller.spanController.GetTasksByTableID(1)), 2) + require.GreaterOrEqual(t, env.controller.spanController.GetReplicatingSize(), 2) + require.Zero(t, env.controller.spanController.GetSchedulingSize()) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) } // TestFinishBootstrapRemovesUnexpectedOverlappingWorkingSpan covers a corrupt bootstrap snapshot @@ -1873,30 +1697,11 @@ func TestFinishBootstrapRemovesUnexpectedOverlappingWorkingSpan(t *testing.T) { keptDispatcherID := common.NewDispatcherID() rejectedDispatcherID := common.NewDispatcherID() - _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ - "node1": { - ChangefeedID: env.cfID.ToPB(), - Spans: []*heartbeatpb.BootstrapTableSpan{ - { - ID: keptDispatcherID.ToPB(), - SchemaID: 1, - Span: keptSpan, - ComponentStatus: heartbeatpb.ComponentState_Working, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: rejectedDispatcherID.ToPB(), - SchemaID: 1, - Span: rejectedSpan, - ComponentStatus: heartbeatpb.ComponentState_Working, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - }, - CheckpointTs: 10, - }, - }, false) + _, err := env.controller.FinishBootstrap(env.bootstrapResponses( + nil, + env.bootstrapSpan(keptDispatcherID, keptSpan, heartbeatpb.ComponentState_Working), + env.bootstrapSpan(rejectedDispatcherID, rejectedSpan, heartbeatpb.ComponentState_Working), + ), false) require.NoError(t, err) require.True(t, env.controller.bootstrapped) require.NotNil(t, env.controller.spanController.GetTaskByID(keptDispatcherID)) @@ -1912,7 +1717,7 @@ func TestFinishBootstrapRemovesUnexpectedOverlappingWorkingSpan(t *testing.T) { // The cleanup owner waits for a terminal status before dropping temporary coverage and // creating the exact replacement range. - removeOp.Check("node1", &heartbeatpb.TableSpanStatus{ + removeOp.Check(env.nodeID, &heartbeatpb.TableSpanStatus{ ID: rejectedDispatcherID.ToPB(), ComponentStatus: heartbeatpb.ComponentState_Stopped, CheckpointTs: 10, @@ -1938,74 +1743,121 @@ func TestFinishBootstrapRemovesUnexpectedOverlappingWorkingSpan(t *testing.T) { require.Equal(t, env.mergedSpan.EndKey, repairedTail.Span.EndKey) } -// TestFinishBootstrapAbortsUncommittedMergeWhenSourceMissing covers failover before the merge -// commit point. For Preparing and MergeReady targets, dispatcher manager aborts when a source is -// missing; bootstrap must keep the target only as temporary coverage and repair after it stops. -func TestFinishBootstrapAbortsUncommittedMergeWhenSourceMissing(t *testing.T) { - for _, targetStatus := range []heartbeatpb.ComponentState{ - heartbeatpb.ComponentState_Preparing, - heartbeatpb.ComponentState_MergeReady, - } { - t.Run(targetStatus.String(), func(t *testing.T) { +// TestFinishBootstrapHandlesMissingMergeSource covers failover after one source disappears. +// Each subtest reports the surviving source and merge journal, optionally reports a target, +// runs bootstrap, and verifies that the merge commit point selects the correct survivor or owner. +func TestFinishBootstrapHandlesMissingMergeSource(t *testing.T) { + type recoveryOutcome int + const ( + skipStaleJournal recoveryOutcome = iota + abortUncommittedTarget + continueCommittedTarget + ) + testCases := []struct { + name string + includeTarget bool + targetStatus heartbeatpb.ComponentState + outcome recoveryOutcome + }{ + // With no target snapshot, the stale journal cannot drive recovery and the surviving source stays active. + {name: "target absent", outcome: skipStaleJournal}, + // Preparing and MergeReady are before the commit point, so the target remains temporary coverage until terminal. + { + name: heartbeatpb.ComponentState_Preparing.String(), + includeTarget: true, + targetStatus: heartbeatpb.ComponentState_Preparing, + outcome: abortUncommittedTarget, + }, + { + name: heartbeatpb.ComponentState_MergeReady.String(), + includeTarget: true, + targetStatus: heartbeatpb.ComponentState_MergeReady, + outcome: abortUncommittedTarget, + }, + // Initializing is the commit point, so bootstrap keeps the target and discards the surviving source. + { + name: heartbeatpb.ComponentState_Initializing.String(), + includeTarget: true, + targetStatus: heartbeatpb.ComponentState_Initializing, + outcome: continueCommittedTarget, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { env := newMergeBootstrapTestEnv(t) + spans := []*heartbeatpb.BootstrapTableSpan{ + env.bootstrapSpan(env.sourceDispatcherID1, env.sourceSpan1, heartbeatpb.ComponentState_WaitingMerge), + } + if tc.includeTarget { + spans = append(spans, env.bootstrapSpan(env.mergedDispatcherID, env.mergedSpan, tc.targetStatus)) + } - _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ - "node1": { - ChangefeedID: env.cfID.ToPB(), - Spans: []*heartbeatpb.BootstrapTableSpan{ - { - ID: env.sourceDispatcherID1.ToPB(), - SchemaID: 1, - Span: env.sourceSpan1, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: env.mergedDispatcherID.ToPB(), - SchemaID: 1, - Span: env.mergedSpan, - ComponentStatus: targetStatus, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - }, - MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ - { - ChangefeedID: env.cfID.ToPB(), - DispatcherIDs: []*heartbeatpb.DispatcherID{ - env.sourceDispatcherID1.ToPB(), - env.sourceDispatcherID2.ToPB(), - }, - MergedDispatcherID: env.mergedDispatcherID.ToPB(), - Mode: common.DefaultMode, - }, - }, - CheckpointTs: 10, - }, - }, false) + _, err := env.controller.FinishBootstrap(env.bootstrapResponses( + []*heartbeatpb.MergeDispatcherRequest{env.mergeRequest()}, + spans..., + ), false) require.NoError(t, err) - require.Zero(t, env.controller.spanController.GetAbsentSize()) - require.NotNil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) - require.NotNil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) - - removeOp := env.controller.operatorController.GetOperator(env.mergedDispatcherID) - require.NotNil(t, removeOp) - require.Equal(t, "remove", removeOp.Type()) - removeOp.Check("node1", &heartbeatpb.TableSpanStatus{ - ID: env.mergedDispatcherID.ToPB(), - ComponentStatus: heartbeatpb.ComponentState_Stopped, - CheckpointTs: 10, - Mode: common.DefaultMode, - }) - require.True(t, removeOp.IsFinished()) - removeOp.PostFinish() - env.controller.operatorController.RemoveOp(env.mergedDispatcherID) - - require.Nil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) - require.NotNil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) - require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) - require.Equal(t, 1, env.controller.spanController.GetAbsentSize()) + require.True(t, env.controller.bootstrapped) + + switch tc.outcome { + case skipStaleJournal: + require.Zero(t, env.controller.operatorController.OperatorSize()) + require.Zero(t, env.controller.spanController.GetSchedulingSize()) + sourceReplicaSet := env.controller.spanController.GetTaskByID(env.sourceDispatcherID1) + require.NotNil(t, sourceReplicaSet) + require.True(t, env.controller.spanController.IsReplicating(sourceReplicaSet)) + require.Nil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) + case abortUncommittedTarget: + require.Zero(t, env.controller.spanController.GetAbsentSize()) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) + + // Dispatcher manager aborts pre-commit merges, so terminal target cleanup must + // release temporary coverage before span repair creates the missing range. + removeOp := env.controller.operatorController.GetOperator(env.mergedDispatcherID) + require.NotNil(t, removeOp) + require.Equal(t, "remove", removeOp.Type()) + removeOp.Check(env.nodeID, &heartbeatpb.TableSpanStatus{ + ID: env.mergedDispatcherID.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Stopped, + CheckpointTs: 10, + Mode: common.DefaultMode, + }) + require.True(t, removeOp.IsFinished()) + removeOp.PostFinish() + env.controller.operatorController.RemoveOp(env.mergedDispatcherID) + + require.Nil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) + require.Equal(t, 1, env.controller.spanController.GetAbsentSize()) + case continueCommittedTarget: + require.Zero(t, env.controller.operatorController.OperatorSize()) + require.Zero(t, env.controller.spanController.GetAbsentSize()) + require.Zero(t, env.controller.spanController.GetSchedulingSize()) + require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) + require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID2)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) + + // A later target heartbeat should update the committed replica directly without an add operator. + env.controller.HandleStatus(env.nodeID, []*heartbeatpb.TableSpanStatus{ + { + ID: env.mergedDispatcherID.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Working, + CheckpointTs: 20, + Mode: common.DefaultMode, + }, + }) + mergedReplicaSet := env.controller.spanController.GetTaskByID(env.mergedDispatcherID) + require.NotNil(t, mergedReplicaSet) + require.Equal(t, heartbeatpb.ComponentState_Working, mergedReplicaSet.GetStatus().ComponentStatus) + require.Zero(t, env.controller.spanController.GetSchedulingSize()) + require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) + default: + require.FailNow(t, "unknown recovery outcome") + } }) } } @@ -2018,56 +1870,19 @@ func TestFinishBootstrapRejectsInvalidMergeJournalGeometry(t *testing.T) { gapEnd := appendNew(env.sourceSpan1.EndKey, 'b') env.sourceSpan2.StartKey = gapEnd - _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ - "node1": { - ChangefeedID: env.cfID.ToPB(), - Spans: []*heartbeatpb.BootstrapTableSpan{ - { - ID: env.sourceDispatcherID1.ToPB(), - SchemaID: 1, - Span: env.sourceSpan1, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: env.sourceDispatcherID2.ToPB(), - SchemaID: 1, - Span: env.sourceSpan2, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: env.mergedDispatcherID.ToPB(), - SchemaID: 1, - Span: env.mergedSpan, - ComponentStatus: heartbeatpb.ComponentState_Preparing, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - }, - MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ - { - ChangefeedID: env.cfID.ToPB(), - DispatcherIDs: []*heartbeatpb.DispatcherID{ - env.sourceDispatcherID1.ToPB(), - env.sourceDispatcherID2.ToPB(), - }, - MergedDispatcherID: env.mergedDispatcherID.ToPB(), - Mode: common.DefaultMode, - }, - }, - CheckpointTs: 10, - }, - }, false) + _, err := env.controller.FinishBootstrap(env.bootstrapResponses( + []*heartbeatpb.MergeDispatcherRequest{env.mergeRequest()}, + env.bootstrapSpan(env.sourceDispatcherID1, env.sourceSpan1, heartbeatpb.ComponentState_WaitingMerge), + env.bootstrapSpan(env.sourceDispatcherID2, env.sourceSpan2, heartbeatpb.ComponentState_WaitingMerge), + env.bootstrapSpan(env.mergedDispatcherID, env.mergedSpan, heartbeatpb.ComponentState_Preparing), + ), false) require.NoError(t, err) require.Zero(t, env.controller.spanController.GetAbsentSize()) removeOp := env.controller.operatorController.GetOperator(env.mergedDispatcherID) require.NotNil(t, removeOp) require.Equal(t, "remove", removeOp.Type()) - removeOp.Check("node1", &heartbeatpb.TableSpanStatus{ + removeOp.Check(env.nodeID, &heartbeatpb.TableSpanStatus{ ID: env.mergedDispatcherID.ToPB(), ComponentStatus: heartbeatpb.ComponentState_Removed, CheckpointTs: 10, @@ -2087,6 +1902,7 @@ func TestFinishBootstrapRejectsInvalidMergeJournalGeometry(t *testing.T) { type mergeBootstrapTestEnv struct { controller *Controller cfID common.ChangeFeedID + nodeID node.ID sourceSpan1 *heartbeatpb.TableSpan sourceSpan2 *heartbeatpb.TableSpan mergedSpan *heartbeatpb.TableSpan @@ -2100,7 +1916,8 @@ func newMergeBootstrapTestEnv(t *testing.T) *mergeBootstrapTestEnv { testutil.SetUpTestServices(t) nodeManager := appcontext.GetService[*watcher.NodeManager](watcher.NodeManagerName) - nodeManager.GetAliveNodes()["node1"] = &node.Info{ID: "node1"} + nodeID := node.ID("node1") + nodeManager.GetAliveNodes()[nodeID] = &node.Info{ID: nodeID} tableTriggerEventDispatcherID := common.NewDispatcherID() cfID := common.NewChangeFeedIDWithName("test", common.DefaultKeyspaceName) @@ -2110,7 +1927,7 @@ func newMergeBootstrapTestEnv(t *testing.T) *mergeBootstrapTestEnv { ID: tableTriggerEventDispatcherID.ToPB(), ComponentStatus: heartbeatpb.ComponentState_Working, CheckpointTs: 1, - }, "node1", false) + }, nodeID, false) cfg := config.GetDefaultReplicaConfig().Clone() cfg.Scheduler = &config.ChangefeedSchedulerConfig{ @@ -2138,6 +1955,7 @@ func newMergeBootstrapTestEnv(t *testing.T) *mergeBootstrapTestEnv { return &mergeBootstrapTestEnv{ controller: controller, cfID: cfID, + nodeID: nodeID, sourceSpan1: &heartbeatpb.TableSpan{ TableID: 1, StartKey: totalSpan.StartKey, @@ -2162,6 +1980,52 @@ func newMergeBootstrapTestEnv(t *testing.T) *mergeBootstrapTestEnv { } } +// bootstrapSpan keeps the invariant schema, checkpoint, and mode fields out of +// individual scenarios while leaving the dispatcher, range, and state explicit. +func (env *mergeBootstrapTestEnv) bootstrapSpan( + dispatcherID common.DispatcherID, + span *heartbeatpb.TableSpan, + state heartbeatpb.ComponentState, +) *heartbeatpb.BootstrapTableSpan { + return &heartbeatpb.BootstrapTableSpan{ + ID: dispatcherID.ToPB(), + SchemaID: 1, + Span: span, + ComponentStatus: state, + CheckpointTs: 10, + Mode: common.DefaultMode, + } +} + +// mergeRequest builds the canonical two-source merge journal used by recovery scenarios. +func (env *mergeBootstrapTestEnv) mergeRequest() *heartbeatpb.MergeDispatcherRequest { + return &heartbeatpb.MergeDispatcherRequest{ + ChangefeedID: env.cfID.ToPB(), + DispatcherIDs: []*heartbeatpb.DispatcherID{ + env.sourceDispatcherID1.ToPB(), + env.sourceDispatcherID2.ToPB(), + }, + MergedDispatcherID: env.mergedDispatcherID.ToPB(), + Mode: common.DefaultMode, + } +} + +// bootstrapResponses builds the single-node snapshot while keeping merge-journal +// presence explicit at each call site because it changes the recovery path. +func (env *mergeBootstrapTestEnv) bootstrapResponses( + mergeOperators []*heartbeatpb.MergeDispatcherRequest, + spans ...*heartbeatpb.BootstrapTableSpan, +) map[node.ID]*heartbeatpb.MaintainerBootstrapResponse { + return map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ + env.nodeID: { + ChangefeedID: env.cfID.ToPB(), + Spans: spans, + MergeOperators: mergeOperators, + CheckpointTs: 10, + }, + } +} + // TestFinishBootstrapSkipsMergeOperatorForDroppedTable covers failover after a DROP TABLE // while dispatcher manager still reports an in-flight merge journal. The test boots from an // empty schema snapshot, feeds source and merged dispatcher snapshots plus the stale merge @@ -2173,49 +2037,12 @@ func TestFinishBootstrapSkipsMergeOperatorForDroppedTable(t *testing.T) { schemaStore.SetTables(nil) appcontext.SetService(appcontext.SchemaStore, schemaStore) - _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ - "node1": { - ChangefeedID: env.cfID.ToPB(), - Spans: []*heartbeatpb.BootstrapTableSpan{ - { - ID: env.sourceDispatcherID1.ToPB(), - SchemaID: 1, - Span: env.sourceSpan1, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: env.sourceDispatcherID2.ToPB(), - SchemaID: 1, - Span: env.sourceSpan2, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: env.mergedDispatcherID.ToPB(), - SchemaID: 1, - Span: env.mergedSpan, - ComponentStatus: heartbeatpb.ComponentState_Preparing, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - }, - MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ - { - ChangefeedID: env.cfID.ToPB(), - DispatcherIDs: []*heartbeatpb.DispatcherID{ - env.sourceDispatcherID1.ToPB(), - env.sourceDispatcherID2.ToPB(), - }, - MergedDispatcherID: env.mergedDispatcherID.ToPB(), - Mode: common.DefaultMode, - }, - }, - CheckpointTs: 10, - }, - }, false) + _, err := env.controller.FinishBootstrap(env.bootstrapResponses( + []*heartbeatpb.MergeDispatcherRequest{env.mergeRequest()}, + env.bootstrapSpan(env.sourceDispatcherID1, env.sourceSpan1, heartbeatpb.ComponentState_WaitingMerge), + env.bootstrapSpan(env.sourceDispatcherID2, env.sourceSpan2, heartbeatpb.ComponentState_WaitingMerge), + env.bootstrapSpan(env.mergedDispatcherID, env.mergedSpan, heartbeatpb.ComponentState_Preparing), + ), false) require.NoError(t, err) require.True(t, env.controller.bootstrapped) require.Zero(t, env.controller.operatorController.OperatorSize()) @@ -2227,51 +2054,6 @@ func TestFinishBootstrapSkipsMergeOperatorForDroppedTable(t *testing.T) { require.Empty(t, env.controller.spanController.GetTasksByTableID(env.sourceSpan1.TableID)) } -// TestFinishBootstrapSkipsIncompleteMergeJournalWithoutMergedDispatcher covers a stale merge -// journal whose source list is incomplete and whose merged dispatcher snapshot is absent. The -// test restores a table with one surviving source span and expects bootstrap to skip the merge -// operator without moving that source into scheduling state. -func TestFinishBootstrapSkipsIncompleteMergeJournalWithoutMergedDispatcher(t *testing.T) { - env := newMergeBootstrapTestEnv(t) - - _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ - "node1": { - ChangefeedID: env.cfID.ToPB(), - Spans: []*heartbeatpb.BootstrapTableSpan{ - { - ID: env.sourceDispatcherID1.ToPB(), - SchemaID: 1, - Span: env.sourceSpan1, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - }, - MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ - { - ChangefeedID: env.cfID.ToPB(), - DispatcherIDs: []*heartbeatpb.DispatcherID{ - env.sourceDispatcherID1.ToPB(), - env.sourceDispatcherID2.ToPB(), - }, - MergedDispatcherID: env.mergedDispatcherID.ToPB(), - Mode: common.DefaultMode, - }, - }, - CheckpointTs: 10, - }, - }, false) - require.NoError(t, err) - require.True(t, env.controller.bootstrapped) - require.Zero(t, env.controller.operatorController.OperatorSize()) - require.Zero(t, env.controller.spanController.GetSchedulingSize()) - - sourceReplicaSet := env.controller.spanController.GetTaskByID(env.sourceDispatcherID1) - require.NotNil(t, sourceReplicaSet) - require.True(t, env.controller.spanController.IsReplicating(sourceReplicaSet)) - require.Nil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) -} - // TestFinishBootstrapSkipsMergeJournalConflictingWithWorkingOperator covers non-atomic bootstrap // snapshots where a stale merge journal overlaps a newer create or remove request. Each subtest // restores the regular operator first, then verifies merge recovery yields to it and gives the @@ -2306,66 +2088,34 @@ func TestFinishBootstrapSkipsMergeJournalConflictingWithWorkingOperator(t *testi t.Run(tc.name, func(t *testing.T) { env := newMergeBootstrapTestEnv(t) spans := []*heartbeatpb.BootstrapTableSpan{ - { - ID: env.sourceDispatcherID2.ToPB(), - SchemaID: 1, - Span: env.sourceSpan2, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: env.mergedDispatcherID.ToPB(), - SchemaID: 1, - Span: env.mergedSpan, - ComponentStatus: heartbeatpb.ComponentState_Preparing, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, + env.bootstrapSpan(env.sourceDispatcherID2, env.sourceSpan2, heartbeatpb.ComponentState_WaitingMerge), + env.bootstrapSpan(env.mergedDispatcherID, env.mergedSpan, heartbeatpb.ComponentState_Preparing), } if tc.includeSourceSnapshot { - spans = append(spans, &heartbeatpb.BootstrapTableSpan{ - ID: env.sourceDispatcherID1.ToPB(), - SchemaID: 1, - Span: env.sourceSpan1, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }) + spans = append(spans, env.bootstrapSpan( + env.sourceDispatcherID1, + env.sourceSpan1, + heartbeatpb.ComponentState_WaitingMerge, + )) } - _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ - "node1": { + responses := env.bootstrapResponses([]*heartbeatpb.MergeDispatcherRequest{env.mergeRequest()}, spans...) + responses[env.nodeID].Operators = []*heartbeatpb.ScheduleDispatcherRequest{ + { ChangefeedID: env.cfID.ToPB(), - Spans: spans, - Operators: []*heartbeatpb.ScheduleDispatcherRequest{ - { - ChangefeedID: env.cfID.ToPB(), - Config: &heartbeatpb.DispatcherConfig{ - DispatcherID: env.sourceDispatcherID1.ToPB(), - SchemaID: 1, - Span: env.sourceSpan1, - StartTs: 10, - Mode: common.DefaultMode, - }, - ScheduleAction: tc.scheduleAction, - OperatorType: tc.operatorType, - }, - }, - MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ - { - ChangefeedID: env.cfID.ToPB(), - DispatcherIDs: []*heartbeatpb.DispatcherID{ - env.sourceDispatcherID1.ToPB(), - env.sourceDispatcherID2.ToPB(), - }, - MergedDispatcherID: env.mergedDispatcherID.ToPB(), - Mode: common.DefaultMode, - }, + Config: &heartbeatpb.DispatcherConfig{ + DispatcherID: env.sourceDispatcherID1.ToPB(), + SchemaID: 1, + Span: env.sourceSpan1, + StartTs: 10, + Mode: common.DefaultMode, }, - CheckpointTs: 10, + ScheduleAction: tc.scheduleAction, + OperatorType: tc.operatorType, }, - }, false) + } + + _, err := env.controller.FinishBootstrap(responses, false) require.NoError(t, err) require.True(t, env.controller.bootstrapped) @@ -2388,41 +2138,15 @@ func TestFinishBootstrapSkipsMergeJournalConflictingWithWorkingOperator(t *testi func TestHandleStatusDropsTerminalSourcesCoveredByMergedSpanAfterJournalCleanup(t *testing.T) { env := newMergeBootstrapTestEnv(t) - _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ - "node1": { - ChangefeedID: env.cfID.ToPB(), - Spans: []*heartbeatpb.BootstrapTableSpan{ - { - ID: env.sourceDispatcherID1.ToPB(), - SchemaID: 1, - Span: env.sourceSpan1, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: env.sourceDispatcherID2.ToPB(), - SchemaID: 1, - Span: env.sourceSpan2, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: env.mergedDispatcherID.ToPB(), - SchemaID: 1, - Span: env.mergedSpan, - ComponentStatus: heartbeatpb.ComponentState_Initializing, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - }, - CheckpointTs: 10, - }, - }, false) + _, err := env.controller.FinishBootstrap(env.bootstrapResponses( + nil, + env.bootstrapSpan(env.sourceDispatcherID1, env.sourceSpan1, heartbeatpb.ComponentState_WaitingMerge), + env.bootstrapSpan(env.sourceDispatcherID2, env.sourceSpan2, heartbeatpb.ComponentState_WaitingMerge), + env.bootstrapSpan(env.mergedDispatcherID, env.mergedSpan, heartbeatpb.ComponentState_Initializing), + ), false) require.NoError(t, err) - env.controller.HandleStatus("node1", []*heartbeatpb.TableSpanStatus{ + env.controller.HandleStatus(env.nodeID, []*heartbeatpb.TableSpanStatus{ { ID: env.sourceDispatcherID1.ToPB(), ComponentStatus: heartbeatpb.ComponentState_Stopped, @@ -2446,73 +2170,6 @@ func TestHandleStatusDropsTerminalSourcesCoveredByMergedSpanAfterJournalCleanup( require.Len(t, env.controller.spanController.GetTasksByTableID(1), 1) } -// TestFinishBootstrapContinuesFromMergedDispatcherWhenMergeSourceMissing covers failover after one -// source dispatcher has already been cleaned up but the persisted merge request is still reported. -// Bootstrap should keep the existing merged dispatcher as the desired span, drop any leftover source -// span, and allow a later Working heartbeat to move normally without an add operator. -func TestFinishBootstrapContinuesFromMergedDispatcherWhenMergeSourceMissing(t *testing.T) { - env := newMergeBootstrapTestEnv(t) - - _, err := env.controller.FinishBootstrap(map[node.ID]*heartbeatpb.MaintainerBootstrapResponse{ - "node1": { - ChangefeedID: env.cfID.ToPB(), - Spans: []*heartbeatpb.BootstrapTableSpan{ - { - ID: env.sourceDispatcherID1.ToPB(), - SchemaID: 1, - Span: env.sourceSpan1, - ComponentStatus: heartbeatpb.ComponentState_WaitingMerge, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - { - ID: env.mergedDispatcherID.ToPB(), - SchemaID: 1, - Span: env.mergedSpan, - ComponentStatus: heartbeatpb.ComponentState_Initializing, - CheckpointTs: 10, - Mode: common.DefaultMode, - }, - }, - MergeOperators: []*heartbeatpb.MergeDispatcherRequest{ - { - ChangefeedID: env.cfID.ToPB(), - DispatcherIDs: []*heartbeatpb.DispatcherID{ - env.sourceDispatcherID1.ToPB(), - env.sourceDispatcherID2.ToPB(), - }, - MergedDispatcherID: env.mergedDispatcherID.ToPB(), - Mode: common.DefaultMode, - }, - }, - CheckpointTs: 10, - }, - }, false) - require.NoError(t, err) - require.True(t, env.controller.bootstrapped) - require.Zero(t, env.controller.operatorController.OperatorSize()) - require.Zero(t, env.controller.spanController.GetAbsentSize()) - require.Zero(t, env.controller.spanController.GetSchedulingSize()) - require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) - require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) - require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID2)) - require.NotNil(t, env.controller.spanController.GetTaskByID(env.mergedDispatcherID)) - - env.controller.HandleStatus("node1", []*heartbeatpb.TableSpanStatus{ - { - ID: env.mergedDispatcherID.ToPB(), - ComponentStatus: heartbeatpb.ComponentState_Working, - CheckpointTs: 20, - Mode: common.DefaultMode, - }, - }) - mergedReplicaSet := env.controller.spanController.GetTaskByID(env.mergedDispatcherID) - require.NotNil(t, mergedReplicaSet) - require.Equal(t, heartbeatpb.ComponentState_Working, mergedReplicaSet.GetStatus().ComponentStatus) - require.Zero(t, env.controller.spanController.GetSchedulingSize()) - require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) -} - func TestSplitTableWhenBootstrapFinished(t *testing.T) { testutil.SetUpTestServices(t) nodeManager := appcontext.GetService[*watcher.NodeManager](watcher.NodeManagerName) From b0ebc07e0d80db1889190b2209d428298a8913e9 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Wed, 22 Jul 2026 16:08:27 +0800 Subject: [PATCH 24/25] maintainer: repair coverage after restored remove --- maintainer/maintainer_controller_bootstrap.go | 18 ++- maintainer/maintainer_controller_test.go | 130 ++++++++++++++++++ 2 files changed, 145 insertions(+), 3 deletions(-) diff --git a/maintainer/maintainer_controller_bootstrap.go b/maintainer/maintainer_controller_bootstrap.go index 62d7911d44..8271142e55 100644 --- a/maintainer/maintainer_controller_bootstrap.go +++ b/maintainer/maintainer_controller_bootstrap.go @@ -1139,14 +1139,15 @@ func (c *Controller) restoreCurrentWorkingRemoveAction( replicaSet.SetNodeID(nodeID) } - if err := c.handleCurrentWorkingRemove(req, spanController, replicaSet, nodeID, resp); err != nil { + _, tableExists := tableSplitMap[span.TableID] + if err := c.handleCurrentWorkingRemove(req, spanController, replicaSet, nodeID, resp, tableExists); err != nil { return err } // If the table is already dropped (not present in schema store at startTs), keep the remove operator so the // runtime dispatcher can be cleaned up, but remove the task to avoid rescheduling a table that no longer exists. if req.OperatorType == heartbeatpb.OperatorType_O_Remove { - if _, ok := tableSplitMap[span.TableID]; !ok { + if !tableExists { spanController.RemoveReplicatingSpan(replicaSet) } } @@ -1203,6 +1204,7 @@ func (c *Controller) handleCurrentWorkingRemove( replicaSet *replica.SpanReplication, node node.ID, resp *heartbeatpb.MaintainerBootstrapResponse, + tableExists bool, ) error { operatorController := c.getOperatorController(req.Config.Mode) // handleCurrentWorkingRemove translates a bootstrap Remove request back into a maintainer-side operator. @@ -1216,12 +1218,22 @@ func (c *Controller) handleCurrentWorkingRemove( switch req.OperatorType { // 1. If the original operator is remove, just finish it directly by adding a new remove operator. case heartbeatpb.OperatorType_O_Remove: + var postFinish func() + if tableExists { + // The reported dispatcher is temporary coverage while its restored remove is active. A terminal + // status is consumed by this operator, so its finalizer must remove that stale coverage and create + // absent replicas for only the ranges that are no longer covered by other bootstrap spans. + postFinish = func() { + spanController.RemoveReplicatingSpan(replicaSet) + c.repairBootstrapTableCoverage(replicaSet) + } + } op := operator.NewRemoveDispatcherOperator( spanController, replicaSet, heartbeatpb.OperatorType_O_Remove, operatorController.MaintainerEpoch(), - nil, + postFinish, ) if ok := operatorController.AddOperator(op); !ok { log.Error("add operator failed when dealing current working operators in bootstrap, should not happen", diff --git a/maintainer/maintainer_controller_test.go b/maintainer/maintainer_controller_test.go index af99e84373..28316c2ea2 100644 --- a/maintainer/maintainer_controller_test.go +++ b/maintainer/maintainer_controller_test.go @@ -1614,6 +1614,117 @@ func TestFinishBootstrapSkipsStaleCreateOperatorForDroppedTable(t *testing.T) { } } +// TestFinishBootstrapRepairsCoverageAfterRestoredStandaloneRemove covers failover after an +// orphan Working dispatcher has already been journaled under a standalone remove request. The +// test restores that request alongside adjacent live coverage, reports one terminal status, and +// finalizes the operator. The removed range must become an exact absent span that the basic +// scheduler can schedule again, while the adjacent dispatcher remains untouched. +func TestFinishBootstrapRepairsCoverageAfterRestoredStandaloneRemove(t *testing.T) { + env := newMergeBootstrapTestEnv(t) + responses := env.bootstrapResponses( + nil, + env.bootstrapSpan(env.sourceDispatcherID1, env.sourceSpan1, heartbeatpb.ComponentState_Working), + env.bootstrapSpan(env.sourceDispatcherID2, env.sourceSpan2, heartbeatpb.ComponentState_Working), + ) + responses[env.nodeID].Operators = []*heartbeatpb.ScheduleDispatcherRequest{ + env.standaloneRemoveRequest(env.sourceDispatcherID1, env.sourceSpan1), + } + + _, err := env.controller.FinishBootstrap(responses, false) + require.NoError(t, err) + require.Equal(t, 2, env.controller.spanController.GetReplicatingSize()) + require.Zero(t, env.controller.spanController.GetAbsentSize()) + + restoredRemove := env.controller.operatorController.GetOperator(env.sourceDispatcherID1) + require.NotNil(t, restoredRemove) + require.Equal(t, "remove", restoredRemove.Type()) + + // A single terminal status finishes the restored operator. The same HandleStatus call still + // sees the operator, so coverage repair must happen when the controller finalizes it. + env.controller.HandleStatus(env.nodeID, []*heartbeatpb.TableSpanStatus{ + { + ID: env.sourceDispatcherID1.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Stopped, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }) + require.True(t, restoredRemove.IsFinished()) + require.NotNil(t, env.controller.operatorController.GetOperator(env.sourceDispatcherID1)) + require.Zero(t, env.controller.spanController.GetAbsentSize()) + + env.controller.operatorController.Execute() + + require.Nil(t, env.controller.operatorController.GetOperator(env.sourceDispatcherID1)) + require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.NotNil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID2)) + require.Equal(t, 1, env.controller.spanController.GetReplicatingSize()) + require.Equal(t, 1, env.controller.spanController.GetAbsentSize()) + + var repairedSpan *replica.SpanReplication + for _, task := range env.controller.spanController.GetTasksByTableID(env.sourceSpan1.TableID) { + if task.ID != env.sourceDispatcherID2 { + repairedSpan = task + break + } + } + require.NotNil(t, repairedSpan) + require.Equal(t, env.sourceSpan1.StartKey, repairedSpan.Span.StartKey) + require.Equal(t, env.sourceSpan1.EndKey, repairedSpan.Span.EndKey) + + env.controller.schedulerController.GetScheduler(scheduler.BasicScheduler).Execute() + require.Zero(t, env.controller.spanController.GetAbsentSize()) + require.Equal(t, 1, env.controller.spanController.GetSchedulingSize()) + addOp := env.controller.operatorController.GetOperator(repairedSpan.ID) + require.NotNil(t, addOp) + require.Equal(t, "add", addOp.Type()) +} + +// TestFinishBootstrapDoesNotRepairDroppedTableAfterRestoredStandaloneRemove covers the same +// restored remove lifecycle after the table has disappeared from the schema snapshot. The test +// reports the stale runtime dispatcher and its remove journal, finishes that operator with one +// terminal status, and verifies finalization never recreates desired state for the dropped table. +func TestFinishBootstrapDoesNotRepairDroppedTableAfterRestoredStandaloneRemove(t *testing.T) { + env := newMergeBootstrapTestEnv(t) + schemaStore := eventservice.NewMockSchemaStore() + schemaStore.SetTables(nil) + appcontext.SetService(appcontext.SchemaStore, schemaStore) + + responses := env.bootstrapResponses( + nil, + env.bootstrapSpan(env.sourceDispatcherID1, env.sourceSpan1, heartbeatpb.ComponentState_Working), + ) + responses[env.nodeID].Operators = []*heartbeatpb.ScheduleDispatcherRequest{ + env.standaloneRemoveRequest(env.sourceDispatcherID1, env.sourceSpan1), + } + + _, err := env.controller.FinishBootstrap(responses, false) + require.NoError(t, err) + require.Nil(t, env.controller.spanController.GetTaskByID(env.sourceDispatcherID1)) + require.Zero(t, env.controller.spanController.GetReplicatingSize()) + require.Zero(t, env.controller.spanController.GetAbsentSize()) + + restoredRemove := env.controller.operatorController.GetOperator(env.sourceDispatcherID1) + require.NotNil(t, restoredRemove) + env.controller.HandleStatus(env.nodeID, []*heartbeatpb.TableSpanStatus{ + { + ID: env.sourceDispatcherID1.ToPB(), + ComponentStatus: heartbeatpb.ComponentState_Removed, + CheckpointTs: 10, + Mode: common.DefaultMode, + }, + }) + require.True(t, restoredRemove.IsFinished()) + + env.controller.operatorController.Execute() + + require.Nil(t, env.controller.operatorController.GetOperator(env.sourceDispatcherID1)) + require.Empty(t, env.controller.spanController.GetTasksByTableID(env.sourceSpan1.TableID)) + require.Zero(t, env.controller.spanController.GetReplicatingSize()) + require.Zero(t, env.controller.spanController.GetSchedulingSize()) + require.Zero(t, env.controller.spanController.GetAbsentSize()) +} + // TestFinishBootstrapRestoresInFlightMergeWithoutDuplicateCoverage covers maintainer failover in // the middle of a merge. The bootstrap snapshot contains two source spans in WaitingMerge and the // overlapping merged target span in Preparing. FinishBootstrap must not panic in findHoles or @@ -2010,6 +2121,25 @@ func (env *mergeBootstrapTestEnv) mergeRequest() *heartbeatpb.MergeDispatcherReq } } +// standaloneRemoveRequest builds the canonical remove journal used by bootstrap recovery tests. +func (env *mergeBootstrapTestEnv) standaloneRemoveRequest( + dispatcherID common.DispatcherID, + span *heartbeatpb.TableSpan, +) *heartbeatpb.ScheduleDispatcherRequest { + return &heartbeatpb.ScheduleDispatcherRequest{ + ChangefeedID: env.cfID.ToPB(), + Config: &heartbeatpb.DispatcherConfig{ + DispatcherID: dispatcherID.ToPB(), + SchemaID: 1, + Span: span, + StartTs: 10, + Mode: common.DefaultMode, + }, + ScheduleAction: heartbeatpb.ScheduleAction_Remove, + OperatorType: heartbeatpb.OperatorType_O_Remove, + } +} + // bootstrapResponses builds the single-node snapshot while keeping merge-journal // presence explicit at each call site because it changes the recovery path. func (env *mergeBootstrapTestEnv) bootstrapResponses( From f65ded057d3875db5ef32c301d220e8e3de55500 Mon Sep 17 00:00:00 2001 From: wlwilliamx Date: Thu, 23 Jul 2026 18:17:23 +0800 Subject: [PATCH 25/25] tests: propagate CDC server to retry helpers --- .../maintainer_failover_when_operator/run.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/integration_tests/maintainer_failover_when_operator/run.sh b/tests/integration_tests/maintainer_failover_when_operator/run.sh index d759d64243..8be0f7020d 100755 --- a/tests/integration_tests/maintainer_failover_when_operator/run.sh +++ b/tests/integration_tests/maintainer_failover_when_operator/run.sh @@ -33,10 +33,11 @@ if [ "${#CDC_ADDRS[@]}" -ne 3 ]; then exit 1 fi # Keep CLI-based helpers (changefeed create/query and move/split/merge operations) pointed at the same -# first capture when the case overrides the CDC addresses for isolated local reruns. +# first capture when the case overrides the CDC addresses for isolated local reruns. The retry helpers +# are separate Bash processes, so export both the server and wrapper functions for them. export CDC_HOST=${CDC_ADDRS[0]%:*} export CDC_PORT=${CDC_ADDRS[0]#*:} -CDC_API_SERVER="http://${CDC_ADDRS[0]}" +export CDC_API_SERVER="http://${CDC_ADDRS[0]}" function cdc_cli_changefeed() { command cdc_cli_changefeed "$@" --server "$CDC_API_SERVER" @@ -45,6 +46,8 @@ function cdc_cli_changefeed() { function run_cdc_cli() { command run_cdc_cli "$@" --server "$CDC_API_SERVER" } +export -f cdc_cli_changefeed run_cdc_cli + FAILPOINT_NOT_READY_TO_CLOSE_DISPATCHER="github.com/pingcap/ticdc/downstreamadapter/dispatcher/NotReadyToCloseDispatcher" FAILPOINT_BLOCK_CREATE_DISPATCHER="github.com/pingcap/ticdc/downstreamadapter/dispatchermanager/BlockCreateDispatcher"