From c55ac2e0f081db018b16f3b3eb3019608fa0fbf6 Mon Sep 17 00:00:00 2001 From: Neil Shen Date: Tue, 17 May 2022 18:20:10 +0800 Subject: [PATCH] cdc: implement replication set (#5450) Signed-off-by: Neil Shen --- .../internal/tp/balance_scheduler.go | 1 + cdc/scheduler/internal/tp/coordinator.go | 5 +- cdc/scheduler/internal/tp/replication_set.go | 554 +++++++++++++++-- .../internal/tp/replication_set_test.go | 574 ++++++++++++++++++ .../tp/schedulepb/TableSchedule.pb.go | 246 +++++--- pkg/errors/errors.go | 10 + proto/TableSchedule.proto | 50 +- 7 files changed, 1289 insertions(+), 151 deletions(-) create mode 100644 cdc/scheduler/internal/tp/replication_set_test.go diff --git a/cdc/scheduler/internal/tp/balance_scheduler.go b/cdc/scheduler/internal/tp/balance_scheduler.go index 7b4a4e77e30..906874ff645 100644 --- a/cdc/scheduler/internal/tp/balance_scheduler.go +++ b/cdc/scheduler/internal/tp/balance_scheduler.go @@ -28,6 +28,7 @@ func (b *balancer) Name() string { } func (b *balancer) Schedule( + checkpointTs model.Ts, currentTables []model.TableID, captures map[model.CaptureID]*model.CaptureInfo, captureTables map[model.CaptureID]captureStatus, diff --git a/cdc/scheduler/internal/tp/coordinator.go b/cdc/scheduler/internal/tp/coordinator.go index d3b8a6f77be..cf7785c1e7e 100644 --- a/cdc/scheduler/internal/tp/coordinator.go +++ b/cdc/scheduler/internal/tp/coordinator.go @@ -25,6 +25,7 @@ import ( type scheduler interface { Name() string Schedule( + checkpointTs model.Ts, currentTables []model.TableID, aliveCaptures map[model.CaptureID]*model.CaptureInfo, captureTables map[model.CaptureID]captureStatus, @@ -71,7 +72,7 @@ func (c *coordinator) poll( captureTables := c.manager.captureTableSets() allTasks := make([]*scheduleTask, 0) for _, sched := range c.scheduler { - tasks := sched.Schedule(currentTables, aliveCaptures, captureTables) + tasks := sched.Schedule(checkpointTs, currentTables, aliveCaptures, captureTables) allTasks = append(allTasks, tasks...) } recvMsgs := c.recvMessages() @@ -81,6 +82,8 @@ func (c *coordinator) poll( return errors.Trace(err) } c.sendMessages(sentMsgs) + + // checkpoint calcuation return nil } diff --git a/cdc/scheduler/internal/tp/replication_set.go b/cdc/scheduler/internal/tp/replication_set.go index f47c8e14aae..554f2d508e6 100644 --- a/cdc/scheduler/internal/tp/replication_set.go +++ b/cdc/scheduler/internal/tp/replication_set.go @@ -16,89 +16,563 @@ package tp import ( "fmt" + "github.com/pingcap/errors" + "github.com/pingcap/log" "github.com/pingcap/tiflow/cdc/model" "github.com/pingcap/tiflow/cdc/scheduler/internal/tp/schedulepb" + cerror "github.com/pingcap/tiflow/pkg/errors" + "go.uber.org/zap" ) // ReplicationSetState is the state of ReplicationSet in owner. // +// AddTable // ┌────────┐ ┌─────────┐ // │ Absent ├─> │ Prepare │ // └────────┘ └──┬──────┘ // ┌──────────┘ ^ -// v │ -// ┌────────┐ ┌──────┴──────┐ -// │ Commit ├──>│ Replicating │<── Move table -// └────────┘ └─────────────┘ +// v │ MoveTable +// ┌────────┐ ┌──────┴──────┐ RemoveTable ┌──────────┐ +// │ Commit ├──>│ Replicating │────────────>│ Removing │ +// └────────┘ └─────────────┘ └──────────┘ type ReplicationSetState int const ( - // Unknown means the replication state is unknown, it should not happen. - Unknown ReplicationSetState = 0 - // Absent means there is no one replicates or prepares it. - Absent ReplicationSetState = 1 - Prepare ReplicationSetState = 2 - Commit ReplicationSetState = 3 - Replicating ReplicationSetState = 4 + // ReplicationSetStateUnknown means the replication state is unknown, + // it should not happen. + ReplicationSetStateUnknown ReplicationSetState = 0 + // ReplicationSetStateAbsent means there is no one replicates or prepares it. + ReplicationSetStateAbsent ReplicationSetState = 1 + // ReplicationSetStatePrepare means it needs to add a secondary. + ReplicationSetStatePrepare ReplicationSetState = 2 + // ReplicationSetStateCommit means it needs to promote secondary to primary. + ReplicationSetStateCommit ReplicationSetState = 3 + // ReplicationSetStateReplicating means there is exactly one capture + // that is replicating the table. + ReplicationSetStateReplicating ReplicationSetState = 4 + // ReplicationSetStateRemoving means all captures need to + // stop replication eventually. + ReplicationSetStateRemoving ReplicationSetState = 5 ) func (r ReplicationSetState) String() string { switch r { - case Absent: + case ReplicationSetStateAbsent: return "Absent" - case Prepare: + case ReplicationSetStatePrepare: return "Prepare" - case Commit: + case ReplicationSetStateCommit: return "Commit" - case Replicating: + case ReplicationSetStateReplicating: return "Replicating" + case ReplicationSetStateRemoving: + return "Removing" default: return fmt.Sprintf("Unknown %d", r) } } +// ReplicationSet is a state machine that manages replication states. type ReplicationSet struct { - TableID model.TableID - State ReplicationSetState - Primary model.CaptureID - Captures map[model.CaptureID]schedulepb.TableState - Checkpoint model.Ts + TableID model.TableID + State ReplicationSetState + Primary model.CaptureID + Secondary model.CaptureID + Captures map[model.CaptureID]struct{} + CheckpointTs model.Ts } func newReplicationSet( - tableStatus map[model.CaptureID]*schedulepb.TableStatus, -) *ReplicationSet { + tableID model.TableID, tableStatus map[model.CaptureID]*schedulepb.TableStatus, +) (*ReplicationSet, error) { + r := &ReplicationSet{TableID: tableID, Captures: make(map[string]struct{})} + committed := false + for captureID, table := range tableStatus { + if r.CheckpointTs <= table.Checkpoint.CheckpointTs { + r.CheckpointTs = table.Checkpoint.CheckpointTs + } + if r.TableID != table.TableID { + return nil, r.inconsistentError(table, captureID, + "tpscheduler: table id inconsistent") + } + + switch table.State { + case schedulepb.TableState_Replicating: + // Recognize primary if it's table is in replicating state. + if len(r.Primary) == 0 { + r.Primary = captureID + r.Captures[captureID] = struct{}{} + } else { + return nil, r.multiplePrimaryError( + table, captureID, "tpscheduler: multiple primary", + zap.Any("status", tableStatus)) + } + case schedulepb.TableState_Preparing: + // Recognize secondary if it's table is in preparing state. + r.Secondary = captureID + r.Captures[captureID] = struct{}{} + case schedulepb.TableState_Prepared: + // Recognize secondary and Commit state if it's table is in prepared state. + committed = true + r.Secondary = captureID + r.Captures[captureID] = struct{}{} + case schedulepb.TableState_Absent, + schedulepb.TableState_Stopping, + schedulepb.TableState_Stopped: + // Ignore stop state. + default: + log.Warn("tpscheduler: unknown table state", + zap.Int64("tableID", table.TableID), + zap.Any("status", tableStatus)) + } + } + + // Build state from primary, secondary and captures. + if len(r.Primary) != 0 { + r.State = ReplicationSetStateReplicating + } + // Move table or add table is in-progress. + if len(r.Secondary) != 0 { + r.State = ReplicationSetStatePrepare + } + // Move table or add table is committed. + if committed { + r.State = ReplicationSetStateCommit + } + if len(r.Captures) == 0 { + r.State = ReplicationSetStateAbsent + } + log.Info("tpscheduler: initialize replication set", + zap.Any("replicationSet", r)) + + return r, nil +} + +func (r *ReplicationSet) inconsistentError( + input *schedulepb.TableStatus, captureID model.CaptureID, msg string, fields ...zap.Field, +) error { + fields = append(fields, []zap.Field{ + zap.String("captureID", captureID), + zap.Stringer("tableState", input), + zap.Any("replicationSet", r)}...) + log.L().WithOptions(zap.AddCallerSkip(1)).Error(msg, fields...) + return cerror.ErrReplicationSetInconsistent.GenWithStackByArgs( + fmt.Sprintf("tableID %d, %s", r.TableID, msg)) +} + +func (r *ReplicationSet) multiplePrimaryError( + input *schedulepb.TableStatus, captureID model.CaptureID, msg string, fields ...zap.Field, +) error { + fields = append(fields, []zap.Field{ + zap.String("captureID", captureID), + zap.Stringer("tableState", input), + zap.Any("replicationSet", r)}...) + log.L().WithOptions(zap.AddCallerSkip(1)).Error(msg, fields...) + return cerror.ErrReplicationSetMultiplePrimaryError.GenWithStackByArgs( + fmt.Sprintf("tableID %d, %s", r.TableID, msg)) +} + +// checkInvariant ensures ReplicationSet invariant is hold. +func (r *ReplicationSet) checkInvariant( + input *schedulepb.TableStatus, captureID model.CaptureID, +) error { + if r.TableID != input.TableID { + return r.inconsistentError(input, captureID, + "tpscheduler: tableID must be the same") + } + if r.Primary == r.Secondary && r.Primary != "" { + return r.inconsistentError(input, captureID, + "tpscheduler: primary and secondary can not be the same") + } + _, okP := r.Captures[r.Primary] + _, okS := r.Captures[r.Secondary] + if (!okP && r.Primary != "") || (!okS && r.Secondary != "") { + return r.inconsistentError(input, captureID, + "tpscheduler: capture inconsistent") + } + if _, ok := r.Captures[captureID]; !ok { + return r.inconsistentError(input, captureID, + fmt.Sprintf("tpscheduler: unknown capture: \"%s\"", captureID)) + } return nil } +func (r *ReplicationSet) isUnknownCapture(captureID model.CaptureID) bool { + if r.State != ReplicationSetStateAbsent { + return false + } + _, ok := r.Captures[captureID] + return !ok +} + // poll transit replication state based on input and the current state. // See ReplicationSetState's comment for the state transition. func (r *ReplicationSet) poll( - input schedulepb.TableState, captureID model.CaptureID, -) []*schedulepb.Message { - return nil + input *schedulepb.TableStatus, captureID model.CaptureID, +) ([]*schedulepb.Message, error) { + err := r.checkInvariant(input, captureID) + if err != nil { + return nil, errors.Trace(err) + } + + if r.isUnknownCapture(captureID) { + log.Warn("tpscheduler: unknown capture, ask for stopping", + zap.String("captureID", captureID), zap.Any("replicationSet", r)) + return []*schedulepb.Message{{ + To: captureID, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + RemoveTable: &schedulepb.RemoveTableRequest{TableID: r.TableID}, + }, + }}, nil + } + + msgBuf := make([]*schedulepb.Message, 0) + stateChanged := true + for stateChanged { + oldState := r.State + var msg *schedulepb.Message + switch r.State { + case ReplicationSetStateAbsent: + msg, stateChanged, err = r.pollOnAbsent(input, captureID) + case ReplicationSetStatePrepare: + msg, stateChanged, err = r.pollOnPrepare(input, captureID) + case ReplicationSetStateCommit: + msg, stateChanged, err = r.pollOnCommit(input, captureID) + case ReplicationSetStateReplicating: + msg, stateChanged, err = r.pollOnReplicating(input, captureID) + case ReplicationSetStateRemoving: + msg, stateChanged, err = r.pollOnRemoving(input, captureID) + default: + return nil, r.inconsistentError( + input, captureID, "tpscheduler: table state unknown") + } + if err != nil { + return nil, errors.Trace(err) + } + if msg != nil { + msgBuf = append(msgBuf, msg) + } + if stateChanged { + log.Info("tpscheduler: replication state transition, poll", + zap.Stringer("tableState", input), + zap.String("captureID", captureID), + zap.Stringer("old", oldState), zap.Stringer("new", r.State)) + } + } + + return msgBuf, nil } -func (r *ReplicationSet) onTableStatus( +func (r *ReplicationSet) pollOnAbsent( + input *schedulepb.TableStatus, captureID model.CaptureID, +) (*schedulepb.Message, bool, error) { + switch input.State { + case schedulepb.TableState_Absent: + if r.Primary != "" || r.Secondary != "" { + return nil, false, r.inconsistentError( + input, captureID, "tpscheduler: there must be no primary or secondary") + } + r.State = ReplicationSetStatePrepare + r.Secondary = captureID + return nil, true, nil + + case schedulepb.TableState_Preparing, + schedulepb.TableState_Prepared, + schedulepb.TableState_Replicating, + schedulepb.TableState_Stopping, + schedulepb.TableState_Stopped: + } + log.Warn("tpscheduler: ingore input, unexpected replication set state", + zap.Stringer("tableState", input), + zap.String("captureID", captureID), + zap.Any("replicationSet", r)) + return nil, false, nil +} + +func (r *ReplicationSet) pollOnPrepare( + input *schedulepb.TableStatus, captureID model.CaptureID, +) (*schedulepb.Message, bool, error) { + switch input.State { + case schedulepb.TableState_Absent, + schedulepb.TableState_Stopping, + schedulepb.TableState_Stopped: + if r.Secondary == captureID { + return &schedulepb.Message{ + To: captureID, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + AddTable: &schedulepb.AddTableRequest{ + TableID: r.TableID, + IsSecondary: true, + Checkpoint: &schedulepb.Checkpoint{CheckpointTs: r.CheckpointTs}, + }, + }, + }, false, nil + } + case schedulepb.TableState_Preparing: + if r.Secondary == captureID { + // Ignore secondary Preparing, it may take a long time. + return nil, false, nil + } + case schedulepb.TableState_Prepared: + if r.Secondary == captureID { + // Secondary is prepared, transit to Commit state. + r.State = ReplicationSetStateCommit + return nil, true, nil + } + case schedulepb.TableState_Replicating: + if r.Primary == captureID { + return nil, false, nil + } + } + log.Warn("tpscheduler: ingore input, unexpected replication set state", + zap.Stringer("tableState", input), + zap.String("captureID", captureID), + zap.Any("replicationSet", r)) + return nil, false, nil +} + +func (r *ReplicationSet) pollOnCommit( + input *schedulepb.TableStatus, captureID model.CaptureID, +) (*schedulepb.Message, bool, error) { + switch input.State { + case schedulepb.TableState_Prepared: + if r.Secondary == captureID { + if r.Primary != "" { + // Secondary capture is prepared and waiting for stopping primary. + // Send message to primary, ask for stopping. + return &schedulepb.Message{ + To: r.Primary, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + RemoveTable: &schedulepb.RemoveTableRequest{TableID: r.TableID}, + }, + }, false, nil + } + // No primary, promote secondary to primary. + original := r.Primary + r.Primary = r.Secondary + r.Secondary = "" + log.Info("tpscheduler: replication state promote secondary", + zap.Stringer("tableState", input), + zap.String("orignial", original), + zap.String("captureID", captureID)) + return &schedulepb.Message{ + To: captureID, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + AddTable: &schedulepb.AddTableRequest{ + TableID: r.TableID, + IsSecondary: false, + Checkpoint: &schedulepb.Checkpoint{CheckpointTs: r.CheckpointTs}, + }, + }, + }, false, nil + } + case schedulepb.TableState_Stopped, schedulepb.TableState_Absent: + if r.Primary == captureID && r.Secondary != "" { + // Primary is stopped, promote secondary to primary. + original := r.Primary + r.Primary = r.Secondary + r.Secondary = "" + log.Info("tpscheduler: replication state promote secondary", + zap.Stringer("tableState", input), + zap.String("orignial", original), + zap.String("captureID", captureID)) + return &schedulepb.Message{ + To: r.Primary, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + AddTable: &schedulepb.AddTableRequest{ + TableID: r.TableID, + IsSecondary: false, + Checkpoint: &schedulepb.Checkpoint{CheckpointTs: r.CheckpointTs}, + }, + }, + }, false, nil + } + + case schedulepb.TableState_Replicating: + if r.Secondary != "" && r.Primary == captureID { + // Original primary is not stopped, ask for stopping. + return &schedulepb.Message{ + To: captureID, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + RemoveTable: &schedulepb.RemoveTableRequest{ + TableID: r.TableID, + }, + }, + }, false, nil + } + if r.Secondary == "" && r.Primary == captureID { + // New primary is replicating, transit to Replicating. + if r.State != ReplicationSetStateReplicating { + r.State = ReplicationSetStateReplicating + return nil, true, nil + } + } + return nil, false, r.multiplePrimaryError( + input, captureID, "tpscheduler: multiple primary") + + case schedulepb.TableState_Stopping: + if r.Primary == captureID && r.Secondary != "" { + return nil, false, nil + } + case schedulepb.TableState_Preparing: + } + log.Warn("tpscheduler: ingore input, unexpected replication set state", + zap.Stringer("tableState", input), + zap.String("captureID", captureID), + zap.Any("replicationSet", r)) + return nil, false, nil +} + +func (r *ReplicationSet) pollOnReplicating( + input *schedulepb.TableStatus, captureID model.CaptureID, +) (*schedulepb.Message, bool, error) { + switch input.State { + case schedulepb.TableState_Replicating: + if r.Primary == captureID { + return nil, false, nil + } + return nil, false, r.multiplePrimaryError( + input, captureID, "tpscheduler: multiple primary") + + case schedulepb.TableState_Absent: + case schedulepb.TableState_Preparing: + case schedulepb.TableState_Prepared: + case schedulepb.TableState_Stopping: + case schedulepb.TableState_Stopped: + } + log.Warn("tpscheduler: ingore input, unexpected replication set state", + zap.Stringer("tableState", input), + zap.String("captureID", captureID), + zap.Any("replicationSet", r)) + return nil, false, nil +} + +func (r *ReplicationSet) pollOnRemoving( + input *schedulepb.TableStatus, captureID model.CaptureID, +) (*schedulepb.Message, bool, error) { + switch input.State { + case schedulepb.TableState_Absent, + schedulepb.TableState_Preparing, + schedulepb.TableState_Prepared, + schedulepb.TableState_Replicating: + return &schedulepb.Message{ + To: captureID, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + RemoveTable: &schedulepb.RemoveTableRequest{TableID: r.TableID}, + }, + }, false, nil + case schedulepb.TableState_Stopped: + if r.Primary == captureID { + r.Primary = "" + } else if r.Secondary == captureID { + r.Secondary = "" + } + delete(r.Captures, captureID) + log.Info("tpscheduler: replication state remove capture", + zap.Stringer("tableState", input), + zap.String("captureID", captureID)) + return nil, false, nil + case schedulepb.TableState_Stopping: + return nil, false, nil + } + log.Warn("tpscheduler: ingore input, unexpected replication set state", + zap.Stringer("tableState", input), + zap.String("captureID", captureID), + zap.Any("replicationSet", r)) + return nil, false, nil +} + +func (r *ReplicationSet) handleTableStatus( from model.CaptureID, status *schedulepb.TableStatus, -) *schedulepb.Message { - return nil +) ([]*schedulepb.Message, error) { + return r.poll(status, from) } -func (r *ReplicationSet) onDispatchTableRequest( - request *schedulepb.DispatchTableRequest, -) *schedulepb.Message { - return nil +func (r *ReplicationSet) handleAddTable( + captureID model.CaptureID, +) ([]*schedulepb.Message, error) { + // Ignore add table if it's not in Absent state. + if r.State != ReplicationSetStateAbsent { + log.Warn("tpscheduler: add table is ignored", + zap.Any("replicationSet", r), zap.Int64("tableID", r.TableID)) + return nil, nil + } + oldState := r.State + r.State = ReplicationSetStateAbsent + log.Info("tpscheduler: replication state transition, add table", + zap.Stringer("old", oldState), zap.Stringer("new", r.State)) + r.Captures[captureID] = struct{}{} + status := &schedulepb.TableStatus{ + TableID: r.TableID, + State: schedulepb.TableState_Absent, + Checkpoint: &schedulepb.Checkpoint{}, + } + return r.poll(status, captureID) } -func (r *ReplicationSet) onDispatchTableResponse( - from model.CaptureID, response *schedulepb.DispatchTableResponse, -) *schedulepb.Message { - return nil +func (r *ReplicationSet) handleMoveTable( + dest model.CaptureID, +) ([]*schedulepb.Message, error) { + // Ignore move table if it has been removed already. + if r.hasRemoved() { + log.Warn("tpscheduler: move table is ignored", + zap.Any("replicationSet", r), zap.Int64("tableID", r.TableID)) + return nil, nil + } + // Ignore move table if it's not in Replicating state. + if r.State != ReplicationSetStateReplicating { + log.Warn("tpscheduler: move table is ignored", + zap.Any("replicationSet", r), zap.Int64("tableID", r.TableID)) + return nil, nil + } + oldState := r.State + r.State = ReplicationSetStatePrepare + log.Info("tpscheduler: replication state transition, move table", + zap.Stringer("old", oldState), zap.Stringer("new", r.State)) + r.Secondary = dest + r.Captures[dest] = struct{}{} + status := &schedulepb.TableStatus{ + TableID: r.TableID, + State: schedulepb.TableState_Absent, + Checkpoint: &schedulepb.Checkpoint{}, + } + return r.poll(status, r.Secondary) } -func (r *ReplicationSet) onCheckpoint( - from model.CaptureID, checkpoint *schedulepb.Checkpoint, -) *schedulepb.Message { - return nil +func (r *ReplicationSet) handleRemoveTable() ([]*schedulepb.Message, error) { + // Ignore remove table if it has been removed already. + if r.hasRemoved() { + log.Warn("tpscheduler: remove table is ignored", + zap.Any("replicationSet", r), zap.Int64("tableID", r.TableID)) + return nil, nil + } + // Ignore remove table if it's not in Replicating state. + if r.State != ReplicationSetStateReplicating { + log.Warn("tpscheduler: remove table is ignored", + zap.Any("replicationSet", r), zap.Int64("tableID", r.TableID)) + return nil, nil + } + oldState := r.State + r.State = ReplicationSetStateRemoving + log.Info("tpscheduler: replication state transition, remove table", + zap.Stringer("old", oldState), zap.Stringer("new", r.State)) + status := &schedulepb.TableStatus{ + TableID: r.TableID, + State: schedulepb.TableState_Replicating, + Checkpoint: &schedulepb.Checkpoint{CheckpointTs: r.CheckpointTs}, + } + return r.poll(status, r.Primary) +} + +func (r *ReplicationSet) hasRemoved() bool { + // It has been removed successfully if it's state is Removing, + // and there is no capture has it. + return r.State == ReplicationSetStateRemoving && len(r.Captures) == 0 } diff --git a/cdc/scheduler/internal/tp/replication_set_test.go b/cdc/scheduler/internal/tp/replication_set_test.go new file mode 100644 index 00000000000..b95386d61a3 --- /dev/null +++ b/cdc/scheduler/internal/tp/replication_set_test.go @@ -0,0 +1,574 @@ +// Copyright 2022 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 tp + +import ( + "math/rand" + "testing" + "time" + + "github.com/pingcap/tiflow/cdc/model" + "github.com/pingcap/tiflow/cdc/scheduler/internal/tp/schedulepb" + "github.com/stretchr/testify/require" +) + +// See https://stackoverflow.com/a/30230552/3920448 for details. +func nextPerm(p []int) { + for i := len(p) - 1; i >= 0; i-- { + if i == 0 || p[i] < len(p)-i-1 { + p[i]++ + return + } + p[i] = 0 + } +} + +func getPerm(orig, p []int) []int { + result := append([]int{}, orig...) + for i, v := range p { + result[i], result[i+v] = result[i+v], result[i] + } + return result +} + +func iterPermutation(sequence []int, fn func(sequence []int)) { + for p := make([]int, len(sequence)); p[0] < len(p); nextPerm(p) { + fn(getPerm(sequence, p)) + } +} + +func TestNewReplicationSet(t *testing.T) { + testcases := []struct { + set *ReplicationSet + tableStatus map[model.CaptureID]*schedulepb.TableStatus + }{ + { + set: &ReplicationSet{ + State: ReplicationSetStateAbsent, + Captures: map[string]struct{}{}, + }, + tableStatus: map[model.CaptureID]*schedulepb.TableStatus{}, + }, + { + set: &ReplicationSet{ + Primary: "1", + State: ReplicationSetStateReplicating, + Captures: map[string]struct{}{"1": {}}, + }, + tableStatus: map[model.CaptureID]*schedulepb.TableStatus{ + "1": {State: schedulepb.TableState_Replicating, + Checkpoint: &schedulepb.Checkpoint{}}, + }, + }, + { + // Rebuild add table state. + set: &ReplicationSet{ + State: ReplicationSetStatePrepare, + Secondary: "1", + Captures: map[string]struct{}{"1": {}}, + }, + tableStatus: map[model.CaptureID]*schedulepb.TableStatus{ + "1": {State: schedulepb.TableState_Preparing, + Checkpoint: &schedulepb.Checkpoint{}}, + }, + }, + { + // Rebuild move table state, Prepare. + set: &ReplicationSet{ + State: ReplicationSetStatePrepare, + Primary: "2", + Secondary: "1", + Captures: map[string]struct{}{"1": {}, "2": {}}, + }, + tableStatus: map[model.CaptureID]*schedulepb.TableStatus{ + "1": {State: schedulepb.TableState_Preparing, + Checkpoint: &schedulepb.Checkpoint{}}, + "2": {State: schedulepb.TableState_Replicating, + Checkpoint: &schedulepb.Checkpoint{}}, + }, + }, + { + // Rebuild move table state, Commit. + set: &ReplicationSet{ + State: ReplicationSetStateCommit, + Primary: "2", + Secondary: "1", + Captures: map[string]struct{}{"1": {}, "2": {}}, + }, + tableStatus: map[model.CaptureID]*schedulepb.TableStatus{ + "1": {State: schedulepb.TableState_Prepared, + Checkpoint: &schedulepb.Checkpoint{}}, + "2": {State: schedulepb.TableState_Replicating, + Checkpoint: &schedulepb.Checkpoint{}}, + }, + }, + { + // Rebuild move table state, Commit, original primary stopping. + set: &ReplicationSet{ + State: ReplicationSetStateCommit, + Secondary: "1", + Captures: map[string]struct{}{"1": {}}, + }, + tableStatus: map[model.CaptureID]*schedulepb.TableStatus{ + "1": {State: schedulepb.TableState_Prepared, + Checkpoint: &schedulepb.Checkpoint{}}, + "2": {State: schedulepb.TableState_Stopping, + Checkpoint: &schedulepb.Checkpoint{}}, + }, + }, + { + // Rebuild move table state, Commit, original primary stopped. + set: &ReplicationSet{ + State: ReplicationSetStateCommit, + Secondary: "1", + Captures: map[string]struct{}{"1": {}}, + }, + tableStatus: map[model.CaptureID]*schedulepb.TableStatus{ + "1": {State: schedulepb.TableState_Prepared, + Checkpoint: &schedulepb.Checkpoint{}}, + "2": {State: schedulepb.TableState_Stopped, + Checkpoint: &schedulepb.Checkpoint{}}, + }, + }, + { + // Rebuild remove table state, Removing. + set: &ReplicationSet{ + State: ReplicationSetStateAbsent, + Captures: map[string]struct{}{}, + }, + tableStatus: map[model.CaptureID]*schedulepb.TableStatus{ + "1": {State: schedulepb.TableState_Stopping, + Checkpoint: &schedulepb.Checkpoint{}}, + "2": {State: schedulepb.TableState_Stopping, + Checkpoint: &schedulepb.Checkpoint{}}, + }, + }, + { + // Multiple primary error. + set: nil, + tableStatus: map[model.CaptureID]*schedulepb.TableStatus{ + "1": {State: schedulepb.TableState_Replicating, + Checkpoint: &schedulepb.Checkpoint{}}, + "2": {State: schedulepb.TableState_Replicating, + Checkpoint: &schedulepb.Checkpoint{}}, + }, + }, + } + for id, tc := range testcases { + set := tc.set + status := tc.tableStatus + + output, err := newReplicationSet(0, status) + if set == nil { + require.Error(t, err) + } else { + require.Nil(t, err) + require.EqualValuesf(t, set, output, "%d", id) + } + } +} + +// Test all table states and replication states. +func TestReplicationSetPoll(t *testing.T) { + var testcases []map[string]schedulepb.TableState + for state1 := range schedulepb.TableState_name { + for state2 := range schedulepb.TableState_name { + if state1 == state2 && state1 == int32(schedulepb.TableState_Replicating) { + continue + } + tc := map[string]schedulepb.TableState{ + "1": schedulepb.TableState(state1), + "2": schedulepb.TableState(state2), + } + testcases = append(testcases, tc) + } + } + seed := time.Now().Unix() + rnd := rand.New(rand.NewSource(seed)) + rnd.Shuffle(len(testcases), func(i, j int) { + testcases[i], testcases[j] = testcases[j], testcases[i] + }) + // It takes minutes to complete all test cases. + // To speed up, we only test the first 2 cases. + testcases = testcases[:2] + + from := "1" + for _, states := range testcases { + status := make(map[string]*schedulepb.TableStatus) + for id, state := range states { + status[id] = &schedulepb.TableStatus{ + TableID: 1, + State: state, + Checkpoint: &schedulepb.Checkpoint{}, + } + } + r, err := newReplicationSet(1, status) + if err != nil { + t.Errorf("fail to new replication set %+v", err) + } + var tableStates []int + for state := range schedulepb.TableState_name { + tableStates = append(tableStates, int(state)) + } + input := &schedulepb.TableStatus{TableID: model.TableID(1)} + iterPermutation(tableStates, func(tableStateSequence []int) { + t.Logf("test %d, %v, %v", seed, status, tableStateSequence) + for _, state := range tableStateSequence { + input.State = schedulepb.TableState(state) + msgs, _ := r.poll(input, from) + for i := range msgs { + if msgs[i] == nil { + t.Errorf("nil messages: %v, input: %v, from: %s, r: %v", + msgs, *input, from, *r) + } + } + // For now, poll() is expected to output at most one message. + if len(msgs) > 1 { + t.Errorf("too many messages: %v, input: %v, from: %s, r: %v", + msgs, *input, from, *r) + } + } + }) + } +} + +func TestReplicationSetAddTable(t *testing.T) { + t.Parallel() + + from := "1" + tableID := model.TableID(1) + r, err := newReplicationSet(tableID, nil) + require.Nil(t, err) + + // Absent -> Prepare + msgs, err := r.handleAddTable(from) + require.Nil(t, err) + require.Len(t, msgs, 1) + require.EqualValues(t, &schedulepb.Message{ + To: from, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + AddTable: &schedulepb.AddTableRequest{ + TableID: r.TableID, + IsSecondary: true, + Checkpoint: &schedulepb.Checkpoint{CheckpointTs: r.CheckpointTs}, + }, + }, + }, msgs[0]) + require.Equal(t, ReplicationSetStatePrepare, r.State) + require.Equal(t, from, r.Secondary) + + // No-op if add table again. + msgs, err = r.handleAddTable(from) + require.Nil(t, err) + require.Len(t, msgs, 0) + + // AddTableRequest is lost somehow, send AddTableRequest again. + msgs, err = r.handleTableStatus(from, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Absent, + }) + require.Nil(t, err) + require.Len(t, msgs, 1) + require.EqualValues(t, &schedulepb.Message{ + To: from, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + AddTable: &schedulepb.AddTableRequest{ + TableID: r.TableID, + IsSecondary: true, + Checkpoint: &schedulepb.Checkpoint{CheckpointTs: r.CheckpointTs}, + }, + }, + }, msgs[0]) + require.Equal(t, ReplicationSetStatePrepare, r.State) + require.Equal(t, from, r.Secondary) + + // Prepare is in-progress. + msgs, err = r.handleTableStatus(from, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Preparing, + }) + require.Nil(t, err) + require.Len(t, msgs, 0) + require.Equal(t, ReplicationSetStatePrepare, r.State) + require.Equal(t, from, r.Secondary) + + // Prepare -> Commit. + msgs, err = r.handleTableStatus(from, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Prepared, + }) + require.Nil(t, err) + require.Len(t, msgs, 1) + require.EqualValues(t, &schedulepb.Message{ + To: from, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + AddTable: &schedulepb.AddTableRequest{ + TableID: r.TableID, + IsSecondary: false, + Checkpoint: &schedulepb.Checkpoint{CheckpointTs: r.CheckpointTs}, + }, + }, + }, msgs[0]) + require.Equal(t, ReplicationSetStateCommit, r.State) + require.Equal(t, from, r.Primary) + require.Equal(t, "", r.Secondary) + + // Commit -> Replicating + msgs, err = r.handleTableStatus(from, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Replicating, + }) + require.Nil(t, err) + require.Len(t, msgs, 0) + require.Equal(t, ReplicationSetStateReplicating, r.State) + require.Equal(t, from, r.Primary) + require.Equal(t, "", r.Secondary) +} + +func TestReplicationSetRemoveTable(t *testing.T) { + t.Parallel() + + from := "1" + tableID := model.TableID(1) + r, err := newReplicationSet(tableID, nil) + require.Nil(t, err) + + // Ignore removing table if it's not in replicating. + msgs, err := r.handleRemoveTable() + require.Nil(t, err) + require.Len(t, msgs, 0) + require.False(t, r.hasRemoved()) + + // Replicating -> Removing + r.Captures[from] = struct{}{} + r.Primary = from + r.State = ReplicationSetStateReplicating + msgs, err = r.handleRemoveTable() + require.Nil(t, err) + require.Len(t, msgs, 1) + require.EqualValues(t, &schedulepb.Message{ + To: from, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + RemoveTable: &schedulepb.RemoveTableRequest{ + TableID: r.TableID, + }, + }, + }, msgs[0]) + require.Equal(t, ReplicationSetStateRemoving, r.State) + require.False(t, r.hasRemoved()) + + // Ignore remove table if it's in-progress. + msgs, err = r.handleRemoveTable() + require.Nil(t, err) + require.Len(t, msgs, 0) + + // Removing is in-progress. + msgs, err = r.handleTableStatus(from, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Stopping, + }) + require.Nil(t, err) + require.Len(t, msgs, 0) + require.Equal(t, ReplicationSetStateRemoving, r.State) + require.False(t, r.hasRemoved()) + + // Removed + msgs, err = r.handleTableStatus(from, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Stopped, + }) + require.Nil(t, err) + require.Len(t, msgs, 0) + require.Equal(t, ReplicationSetStateRemoving, r.State) + require.True(t, r.hasRemoved()) +} + +func TestReplicationSetMoveTable(t *testing.T) { + t.Parallel() + + tableID := model.TableID(1) + r, err := newReplicationSet(tableID, nil) + require.Nil(t, err) + + original := "1" + dest := "2" + // Ignore removing table if it's not in replicating. + r.State = ReplicationSetStatePrepare + r.Secondary = original + r.Captures[original] = struct{}{} + msgs, err := r.handleMoveTable(dest) + require.Nil(t, err) + require.Len(t, msgs, 0) + require.NotContains(t, r.Captures, dest) + + r.State = ReplicationSetStateReplicating + r.Primary = original + r.Secondary = "" + + // Replicating -> Prepare + msgs, err = r.handleMoveTable(dest) + require.Nil(t, err) + require.Len(t, msgs, 1) + require.EqualValues(t, &schedulepb.Message{ + To: dest, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + AddTable: &schedulepb.AddTableRequest{ + TableID: r.TableID, + IsSecondary: true, + Checkpoint: &schedulepb.Checkpoint{CheckpointTs: r.CheckpointTs}, + }, + }, + }, msgs[0]) + require.Equal(t, ReplicationSetStatePrepare, r.State) + require.Equal(t, dest, r.Secondary) + require.Equal(t, original, r.Primary) + + // No-op if add table again. + msgs, err = r.handleAddTable(dest) + require.Nil(t, err) + require.Len(t, msgs, 0) + + // AddTableRequest is lost somehow, send AddTableRequest again. + msgs, err = r.handleTableStatus(dest, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Absent, + }) + require.Nil(t, err) + require.Len(t, msgs, 1) + require.EqualValues(t, &schedulepb.Message{ + To: dest, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + AddTable: &schedulepb.AddTableRequest{ + TableID: r.TableID, + IsSecondary: true, + Checkpoint: &schedulepb.Checkpoint{CheckpointTs: r.CheckpointTs}, + }, + }, + }, msgs[0]) + require.Equal(t, ReplicationSetStatePrepare, r.State) + require.Equal(t, dest, r.Secondary) + + // Prepare -> Commit. + msgs, err = r.handleTableStatus(dest, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Prepared, + }) + require.Nil(t, err) + require.Len(t, msgs, 1) + require.EqualValues(t, &schedulepb.Message{ + To: original, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + RemoveTable: &schedulepb.RemoveTableRequest{ + TableID: r.TableID, + }, + }, + }, msgs[0]) + require.Equal(t, ReplicationSetStateCommit, r.State) + require.Equal(t, original, r.Primary) + require.Equal(t, dest, r.Secondary) + + // Source updates it's table status + msgs, err = r.handleTableStatus(original, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Replicating, + }) + require.Nil(t, err) + require.Len(t, msgs, 1, "%v", r) + require.EqualValues(t, &schedulepb.Message{ + To: original, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + RemoveTable: &schedulepb.RemoveTableRequest{ + TableID: r.TableID, + }, + }, + }, msgs[0]) + require.Equal(t, ReplicationSetStateCommit, r.State) + require.Equal(t, original, r.Primary) + require.Equal(t, dest, r.Secondary) + + // Removing source is in-progress. + msgs, err = r.handleTableStatus(original, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Stopping, + }) + require.Nil(t, err) + require.Len(t, msgs, 0) + require.Equal(t, ReplicationSetStateCommit, r.State) + require.Equal(t, original, r.Primary) + require.Equal(t, dest, r.Secondary) + + // Source is removed. + rSnapshot := *r + msgs, err = r.handleTableStatus(original, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Stopped, + }) + require.Nil(t, err) + require.Len(t, msgs, 1) + require.EqualValues(t, &schedulepb.Message{ + To: dest, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + AddTable: &schedulepb.AddTableRequest{ + TableID: r.TableID, + IsSecondary: false, + Checkpoint: &schedulepb.Checkpoint{CheckpointTs: r.CheckpointTs}, + }, + }, + }, msgs[0]) + require.Equal(t, ReplicationSetStateCommit, r.State) + require.Equal(t, dest, r.Primary) + require.Equal(t, "", r.Secondary) + + // Source stopped message is lost somehow. + msgs, err = rSnapshot.handleTableStatus(original, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Absent, + }) + require.Nil(t, err) + require.Len(t, msgs, 1) + require.EqualValues(t, &schedulepb.Message{ + To: dest, + MsgType: schedulepb.MessageType_MsgDispatchTableRequest, + DispatchTableRequest: &schedulepb.DispatchTableRequest{ + AddTable: &schedulepb.AddTableRequest{ + TableID: r.TableID, + IsSecondary: false, + Checkpoint: &schedulepb.Checkpoint{CheckpointTs: r.CheckpointTs}, + }, + }, + }, msgs[0]) + require.Equal(t, ReplicationSetStateCommit, r.State) + require.Equal(t, dest, r.Primary) + require.Equal(t, "", r.Secondary) + + // Commit -> Replicating + msgs, err = r.handleTableStatus(dest, &schedulepb.TableStatus{ + TableID: tableID, + State: schedulepb.TableState_Replicating, + }) + require.Nil(t, err) + require.Len(t, msgs, 0) + require.Equal(t, ReplicationSetStateReplicating, r.State) + require.Equal(t, dest, r.Primary) + require.Equal(t, "", r.Secondary) +} diff --git a/cdc/scheduler/internal/tp/schedulepb/TableSchedule.pb.go b/cdc/scheduler/internal/tp/schedulepb/TableSchedule.pb.go index 1d48b7fe7d8..43b0b948e93 100644 --- a/cdc/scheduler/internal/tp/schedulepb/TableSchedule.pb.go +++ b/cdc/scheduler/internal/tp/schedulepb/TableSchedule.pb.go @@ -415,10 +415,10 @@ func (m *DispatchTableRequest) GetRemoveTable() *RemoveTableRequest { } type AddTableResponse struct { - TableID github_com_pingcap_tiflow_cdc_model.TableID `protobuf:"varint,1,opt,name=table_id,json=tableId,proto3,casttype=github.com/pingcap/tiflow/cdc/model.TableID" json:"table_id,omitempty"` - IsSecondary bool `protobuf:"varint,2,opt,name=is_secondary,json=isSecondary,proto3" json:"is_secondary,omitempty"` - Checkpoint *Checkpoint `protobuf:"bytes,3,opt,name=checkpoint,proto3" json:"checkpoint,omitempty"` - Reject bool `protobuf:"varint,4,opt,name=reject,proto3" json:"reject,omitempty"` + TableID github_com_pingcap_tiflow_cdc_model.TableID `protobuf:"varint,1,opt,name=table_id,json=tableId,proto3,casttype=github.com/pingcap/tiflow/cdc/model.TableID" json:"table_id,omitempty"` + Status *TableStatus `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` + Checkpoint *Checkpoint `protobuf:"bytes,3,opt,name=checkpoint,proto3" json:"checkpoint,omitempty"` + Reject bool `protobuf:"varint,4,opt,name=reject,proto3" json:"reject,omitempty"` } func (m *AddTableResponse) Reset() { *m = AddTableResponse{} } @@ -461,11 +461,11 @@ func (m *AddTableResponse) GetTableID() github_com_pingcap_tiflow_cdc_model.Tabl return 0 } -func (m *AddTableResponse) GetIsSecondary() bool { +func (m *AddTableResponse) GetStatus() *TableStatus { if m != nil { - return m.IsSecondary + return m.Status } - return false + return nil } func (m *AddTableResponse) GetCheckpoint() *Checkpoint { @@ -484,7 +484,8 @@ func (m *AddTableResponse) GetReject() bool { type RemoveTableResponse struct { TableID github_com_pingcap_tiflow_cdc_model.TableID `protobuf:"varint,1,opt,name=table_id,json=tableId,proto3,casttype=github.com/pingcap/tiflow/cdc/model.TableID" json:"table_id,omitempty"` - Checkpoint *Checkpoint `protobuf:"bytes,2,opt,name=checkpoint,proto3" json:"checkpoint,omitempty"` + Status *TableStatus `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` + Checkpoint *Checkpoint `protobuf:"bytes,3,opt,name=checkpoint,proto3" json:"checkpoint,omitempty"` } func (m *RemoveTableResponse) Reset() { *m = RemoveTableResponse{} } @@ -527,6 +528,13 @@ func (m *RemoveTableResponse) GetTableID() github_com_pingcap_tiflow_cdc_model.T return 0 } +func (m *RemoveTableResponse) GetStatus() *TableStatus { + if m != nil { + return m.Status + } + return nil +} + func (m *RemoveTableResponse) GetCheckpoint() *Checkpoint { if m != nil { return m.Checkpoint @@ -925,68 +933,69 @@ func init() { func init() { proto.RegisterFile("TableSchedule.proto", fileDescriptor_5b343da219629f69) } var fileDescriptor_5b343da219629f69 = []byte{ - // 973 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0x3a, 0xfe, 0xfb, 0x36, 0x71, 0x96, 0x69, 0xda, 0x5a, 0x01, 0x9c, 0xb2, 0xa0, 0x12, + // 978 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x57, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0x3a, 0xfe, 0xf9, 0x36, 0x76, 0x97, 0x69, 0xda, 0x5a, 0x01, 0x9c, 0xb2, 0xa0, 0x52, 0x5c, 0xba, 0x56, 0x5d, 0x24, 0x24, 0x2e, 0x28, 0x4e, 0x23, 0x11, 0x15, 0xab, 0xd5, 0xd8, 0xe1, - 0xc0, 0x65, 0xb5, 0x9e, 0x99, 0xae, 0x97, 0xd8, 0x3b, 0xcb, 0xce, 0x38, 0x91, 0x3f, 0x02, 0x17, - 0xc4, 0x81, 0x4f, 0xc0, 0x91, 0x2f, 0xc0, 0x57, 0xe0, 0xd8, 0x13, 0xe2, 0x14, 0xa1, 0xe4, 0xc0, - 0x11, 0xce, 0x39, 0xa1, 0x9d, 0x5d, 0x7b, 0xb3, 0x8d, 0x85, 0x1d, 0x4a, 0x38, 0x70, 0x9b, 0xe7, - 0x7d, 0xef, 0xf7, 0xde, 0xfb, 0xcd, 0xef, 0xbd, 0x91, 0xe1, 0x56, 0xcf, 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0xa4, 0xc1, 0xad, 0x0c, 0x2b, 0x37, 0xdb, 0x74, 0xb6, - 0xa3, 0xdc, 0xeb, 0x4c, 0xca, 0xf7, 0x39, 0xb8, 0xfd, 0x8a, 0x78, 0x93, 0xda, 0xbf, 0x80, 0x8d, - 0x60, 0xba, 0xf1, 0xec, 0x74, 0xd3, 0xe9, 0xad, 0x87, 0x0b, 0x32, 0x65, 0xf7, 0x24, 0xae, 0x06, - 0xd9, 0xbd, 0xf9, 0xf9, 0x55, 0x01, 0x37, 0x97, 0x16, 0x70, 0x5c, 0xdb, 0x25, 0x05, 0x1f, 0xce, - 0x55, 0x70, 0xeb, 0x3a, 0x0a, 0x4e, 0x30, 0x33, 0x12, 0xb6, 0xa1, 0xbc, 0xeb, 0xfb, 0x7c, 0xec, - 0x13, 0x76, 0x23, 0x63, 0x6c, 0xfe, 0xa9, 0x81, 0x1e, 0xbf, 0x64, 0xd2, 0x91, 0x63, 0x71, 0x53, - 0x4a, 0xf9, 0x14, 0x0a, 0x42, 0x3a, 0x32, 0x26, 0xba, 0xba, 0x50, 0x24, 0xb3, 0x8a, 0x18, 0x8e, - 0xe3, 0xfe, 0xcd, 0xa5, 0xfc, 0x83, 0x06, 0xf9, 0xee, 0xc4, 0x27, 0x37, 0xa6, 0xac, 0x36, 0x14, - 0x55, 0xdf, 0xd1, 0xb3, 0xb8, 0xba, 0xa3, 0xb7, 0x1a, 0xcb, 0x76, 0x3b, 0x16, 0x38, 0x89, 0x34, - 0x7f, 0x2f, 0x40, 0xa9, 0xc3, 0x84, 0x70, 0x5c, 0x86, 0xf6, 0xa1, 0x38, 0x60, 0x0e, 0x65, 0xe1, - 0x92, 0xe5, 0x25, 0x71, 0xd6, 0x67, 0x2a, 0x08, 0x27, 0xc1, 0x68, 0x1f, 0xca, 0x23, 0xe1, 0xda, - 0x72, 0x12, 0x4c, 0xaf, 0xa1, 0xb1, 0x1c, 0x50, 0x6f, 0x12, 0x30, 0x5c, 0x1a, 0x09, 0x37, 0x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0x16, 0xe4, 0x85, 0x74, 0xe5, 0x58, 0x24, 0x5c, + 0xd4, 0x97, 0xf4, 0xae, 0xa7, 0x87, 0xca, 0xc0, 0x49, 0xe6, 0x1b, 0x14, 0x1e, 0xba, 0x0d, 0xf9, + 0x88, 0x7d, 0xc3, 0x88, 0xac, 0x66, 0x95, 0xc0, 0x93, 0xc8, 0xfe, 0xd3, 0x80, 0x9b, 0x73, 0xb4, + 0xfd, 0x9f, 0x58, 0xb1, 0x7f, 0xc8, 0xc0, 0xad, 0xd7, 0x1c, 0x92, 0x9c, 0xff, 0x2b, 0xb8, 0x11, + 0x4e, 0xc7, 0x6a, 0x2f, 0x1d, 0xa7, 0x66, 0xf3, 0xe1, 0x92, 0x4a, 0xf3, 0xc3, 0x18, 0x57, 0xc2, + 0xf9, 0xe1, 0xfc, 0xe5, 0x65, 0x97, 0x34, 0x56, 0x76, 0x89, 0xee, 0xed, 0x82, 0x4d, 0x0e, 0x16, + 0xda, 0xa4, 0x79, 0x15, 0x9b, 0x24, 0x98, 0x73, 0x3e, 0xe9, 0x41, 0x71, 0x27, 0x08, 0xf8, 0x38, + 0x20, 0xec, 0x5a, 0x66, 0x85, 0xfd, 0x87, 0x01, 0xe6, 0x85, 0xab, 0xbd, 0x2e, 0xb5, 0x7d, 0x0e, + 0xb9, 0x58, 0x33, 0x9a, 0xe8, 0xca, 0x52, 0x91, 0xcc, 0x3a, 0x62, 0x58, 0xe7, 0xbd, 0x49, 0xa9, + 0xfd, 0x68, 0x40, 0xb6, 0x33, 0x09, 0xc8, 0xb5, 0x29, 0xab, 0x05, 0x79, 0x75, 0xee, 0xd8, 0x5a, + 0xeb, 0x57, 0xb5, 0x96, 0xce, 0xb4, 0x7f, 0xcf, 0x41, 0xa1, 0xcd, 0x84, 0x70, 0x3d, 0x86, 0xf6, + 0x20, 0x3f, 0x60, 0x2e, 0x65, 0xd1, 0x8a, 0xed, 0x25, 0x79, 0xce, 0x17, 0x2a, 0x09, 0x27, 0xc9, + 0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9d, 0xbe, 0x60, 0x81, 0xb4, 0x0c, 0x54, 0x86, 0xd2, + 0xf3, 0x88, 0x85, 0x6e, 0xe4, 0x07, 0x9e, 0x95, 0x41, 0x1b, 0x50, 0xd4, 0x21, 0xa3, 0xd6, 0x3a, + 0xba, 0x01, 0x26, 0x66, 0xe1, 0xd0, 0x27, 0xae, 0x8c, 0x3f, 0x67, 0xe3, 0xcf, 0x1d, 0xc9, 0xc3, + 0xb8, 0x51, 0x2b, 0x17, 0x83, 0xaa, 0x88, 0x51, 0x2b, 0x5f, 0xff, 0xce, 0x00, 0xf3, 0x82, 0xb0, + 0x51, 0x05, 0xa0, 0x2d, 0xbc, 0xb4, 0xe8, 0x5b, 0x50, 0x6e, 0x0b, 0x2f, 0xa5, 0xd3, 0x32, 0xd0, + 0xdb, 0x70, 0xa7, 0x2d, 0xbc, 0x45, 0x72, 0xb1, 0x32, 0xe8, 0x1d, 0xa8, 0x5e, 0xfe, 0xa8, 0x2f, + 0x52, 0x77, 0xd6, 0x16, 0xde, 0x94, 0x53, 0x2b, 0x1b, 0xf7, 0xd2, 0x16, 0x5e, 0xcc, 0x91, 0x95, + 0x6b, 0x7d, 0xf0, 0xf3, 0x69, 0xcd, 0x78, 0x75, 0x5a, 0x33, 0x7e, 0x3b, 0xad, 0x19, 0x2f, 0xcf, + 0x6a, 0x6b, 0xaf, 0xce, 0x6a, 0x6b, 0xbf, 0x9e, 0xd5, 0xd6, 0xbe, 0x86, 0x94, 0xd0, 0x7e, 0x5e, + 0xfd, 0x19, 0x79, 0xfc, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x70, 0x7d, 0x36, 0xd8, 0x0c, + 0x00, 0x00, } func (m *OwnerRevision) Marshal() (dAtA []byte, err error) { @@ -1259,15 +1268,17 @@ func (m *AddTableResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if m.IsSecondary { - i-- - if m.IsSecondary { - dAtA[i] = 1 - } else { - dAtA[i] = 0 + if m.Status != nil { + { + size, err := m.Status.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTableSchedule(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x10 + dAtA[i] = 0x12 } if m.TableID != 0 { i = encodeVarintTableSchedule(dAtA, i, uint64(m.TableID)) @@ -1307,6 +1318,18 @@ func (m *RemoveTableResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTableSchedule(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x1a + } + if m.Status != nil { + { + size, err := m.Status.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTableSchedule(dAtA, i, uint64(size)) + } + i-- dAtA[i] = 0x12 } if m.TableID != 0 { @@ -1761,8 +1784,9 @@ func (m *AddTableResponse) Size() (n int) { if m.TableID != 0 { n += 1 + sovTableSchedule(uint64(m.TableID)) } - if m.IsSecondary { - n += 2 + if m.Status != nil { + l = m.Status.Size() + n += 1 + l + sovTableSchedule(uint64(l)) } if m.Checkpoint != nil { l = m.Checkpoint.Size() @@ -1783,6 +1807,10 @@ func (m *RemoveTableResponse) Size() (n int) { if m.TableID != 0 { n += 1 + sovTableSchedule(uint64(m.TableID)) } + if m.Status != nil { + l = m.Status.Size() + n += 1 + l + sovTableSchedule(uint64(l)) + } if m.Checkpoint != nil { l = m.Checkpoint.Size() n += 1 + l + sovTableSchedule(uint64(l)) @@ -2565,10 +2593,10 @@ func (m *AddTableResponse) Unmarshal(dAtA []byte) error { } } case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsSecondary", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } - var v int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTableSchedule @@ -2578,12 +2606,28 @@ func (m *AddTableResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - m.IsSecondary = bool(v != 0) + if msglen < 0 { + return ErrInvalidLengthTableSchedule + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTableSchedule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &TableStatus{} + } + if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Checkpoint", wireType) @@ -2710,6 +2754,42 @@ func (m *RemoveTableResponse) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTableSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTableSchedule + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTableSchedule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &TableStatus{} + } + if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Checkpoint", wireType) } diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go index fd65dbab2bd..73f6e120de0 100644 --- a/pkg/errors/errors.go +++ b/pkg/errors/errors.go @@ -994,4 +994,14 @@ var ( "upstream not found, cluster-id: %d", errors.RFCCodeText("CDC:ErrUpstreamNotFound"), ) + + // ReplicationSet error + ErrReplicationSetInconsistent = errors.Normalize( + "replication set inconsistent: %s", + errors.RFCCodeText("CDC:ErrReplicationSetInconsistent"), + ) + ErrReplicationSetMultiplePrimaryError = errors.Normalize( + "replication set multiple primary: %s", + errors.RFCCodeText("CDC:ErrReplicationSetMultiplePrimaryError"), + ) ) diff --git a/proto/TableSchedule.proto b/proto/TableSchedule.proto index bb8ac660120..000f2901c7f 100644 --- a/proto/TableSchedule.proto +++ b/proto/TableSchedule.proto @@ -29,21 +29,19 @@ message Checkpoint { } message AddTableRequest { - int64 table_id = 1 - [ - (gogoproto.casttype) = "github.com/pingcap/tiflow/cdc/model.TableID", - (gogoproto.customname) = "TableID" - ]; + int64 table_id = 1 [ + (gogoproto.casttype) = "github.com/pingcap/tiflow/cdc/model.TableID", + (gogoproto.customname) = "TableID" + ]; bool is_secondary = 2; Checkpoint checkpoint = 3; } message RemoveTableRequest { - int64 table_id = 1 - [ - (gogoproto.casttype) = "github.com/pingcap/tiflow/cdc/model.TableID", - (gogoproto.customname) = "TableID" - ]; + int64 table_id = 1 [ + (gogoproto.casttype) = "github.com/pingcap/tiflow/cdc/model.TableID", + (gogoproto.customname) = "TableID" + ]; } message DispatchTableRequest { @@ -53,23 +51,22 @@ message DispatchTableRequest { } message AddTableResponse { - int64 table_id = 1 - [ - (gogoproto.casttype) = "github.com/pingcap/tiflow/cdc/model.TableID", - (gogoproto.customname) = "TableID" - ]; - bool is_secondary = 2; + int64 table_id = 1 [ + (gogoproto.casttype) = "github.com/pingcap/tiflow/cdc/model.TableID", + (gogoproto.customname) = "TableID" + ]; + TableStatus status = 2; Checkpoint checkpoint = 3; bool reject = 4; } message RemoveTableResponse { - int64 table_id = 1 - [ - (gogoproto.casttype) = "github.com/pingcap/tiflow/cdc/model.TableID", - (gogoproto.customname) = "TableID" - ]; - Checkpoint checkpoint = 2; + int64 table_id = 1 [ + (gogoproto.casttype) = "github.com/pingcap/tiflow/cdc/model.TableID", + (gogoproto.customname) = "TableID" + ]; + TableStatus status = 2; + Checkpoint checkpoint = 3; } message DispatchTableResponse { @@ -101,11 +98,10 @@ enum TableState { } message TableStatus { - int64 table_id = 1 - [ - (gogoproto.casttype) = "github.com/pingcap/tiflow/cdc/model.TableID", - (gogoproto.customname) = "TableID" - ]; + int64 table_id = 1 [ + (gogoproto.casttype) = "github.com/pingcap/tiflow/cdc/model.TableID", + (gogoproto.customname) = "TableID" + ]; TableState state = 2; Checkpoint checkpoint = 3; }