This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 190
dmctl: fix handle err commands #1746
Merged
Merged
Changes from 28 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f245398
first commit
lichunzhu 4e173c8
merge master and resolve conflicts
lichunzhu cefdcf6
update tests and ctl code
lichunzhu bc631b0
Merge branch 'master' into fixHandleErrCommands
lichunzhu cb9c6f8
try to fix tests
lichunzhu e32ea81
Merge branch 'master' of https://github.com/pingcap/dm into fixHandle…
lichunzhu f7616d8
fix help_cnt
lichunzhu 4380557
Merge branch 'master' into fixHandleErrCommands
Ehco1996 48301b4
resolve conflicts
lichunzhu 5f8ea2f
Merge branch 'fixHandleErrCommands' of https://github.com/lichunzhu/d…
lichunzhu 573e62a
Merge branch 'master' into fixHandleErrCommands
lichunzhu 313f7e7
change output to dir
lichunzhu 2a1f09e
Merge branch 'fixHandleErrCommands' of https://github.com/lichunzhu/d…
lichunzhu b09a764
try fix
lichunzhu 85b93e3
try fix again
lichunzhu f1014d3
address comments
lichunzhu 4d555f3
Merge branch 'master' into fixHandleErrCommands
lichunzhu e3a68f2
address comments
lichunzhu f3eb01a
Merge branch 'fixHandleErrCommands' of https://github.com/lichunzhu/d…
lichunzhu 7738063
Merge branch 'master' into fixHandleErrCommands
lichunzhu ce84214
address comments
lichunzhu 0eef9d0
Merge branch 'fixHandleErrCommands' of https://github.com/lichunzhu/d…
lichunzhu 4f3102c
change --dir to --path
lichunzhu 3efd1d4
Merge branch 'master' into fixHandleErrCommands
lichunzhu ad653f4
revise source-table-schema to binlog-schema
lichunzhu 941a751
fix integration tests
lichunzhu a6ce2b9
fix it again
lichunzhu d3cc3df
Merge branch 'master' into fixHandleErrCommands
GMHDBJD 2adbde7
address comments
lichunzhu 12d4c42
address comments
lichunzhu a38dbaa
merge master and resolve conflicts
lichunzhu fe19681
fix tests
lichunzhu 8989ba6
Merge branch 'master' of https://github.com/pingcap/dm into fixHandle…
lichunzhu 72226d1
Merge branch 'master' into fixHandleErrCommands
lance6716 b949151
Merge branch 'master' into fixHandleErrCommands
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,101 @@ | ||||||
// Copyright 2021 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 master | ||||||
|
||||||
import ( | ||||||
"github.com/pingcap/dm/dm/ctl/common" | ||||||
"github.com/pingcap/dm/dm/pb" | ||||||
|
||||||
"github.com/pingcap/errors" | ||||||
"github.com/spf13/cobra" | ||||||
) | ||||||
|
||||||
// NewBinlogCmd creates a binlog command. | ||||||
func NewBinlogCmd() *cobra.Command { | ||||||
cmd := &cobra.Command{ | ||||||
Use: "binlog <command>", | ||||||
Short: "manage upstream binlog operations", | ||||||
} | ||||||
cmd.PersistentFlags().StringP("binlog-pos", "b", "", "position used to match binlog event if matched the handler-error operation will be applied. The format like \"mysql-bin|000001.000003:3270\"") | ||||||
cmd.AddCommand( | ||||||
newBinlogSkipCmd(), | ||||||
newBinlogReplaceCmd(), | ||||||
newBinlogRevertCmd(), | ||||||
newBinlogInjectCmd(), | ||||||
) | ||||||
|
||||||
return cmd | ||||||
} | ||||||
|
||||||
func newBinlogSkipCmd() *cobra.Command { | ||||||
cmd := &cobra.Command{ | ||||||
Use: "skip <task-name>", | ||||||
Short: "skip the current error event or a specific binlog position (binlog-pos) event", | ||||||
RunE: func(cmd *cobra.Command, args []string) error { | ||||||
if len(args) != 1 { | ||||||
return cmd.Help() | ||||||
} | ||||||
taskName := common.GetTaskNameFromArgOrFile(cmd.Flags().Arg(0)) | ||||||
return sendHandleErrorRequest(cmd, pb.ErrorOp_Skip, taskName, nil) | ||||||
}, | ||||||
} | ||||||
return cmd | ||||||
} | ||||||
|
||||||
func newBinlogReplaceCmd() *cobra.Command { | ||||||
cmd := &cobra.Command{ | ||||||
Use: "replace <task-name> <replace-sql1> <replace-sql2>...", | ||||||
Short: "replace the current error event or a specific binlog position (binlog-pos) ddl event with some ddls", | ||||||
RunE: func(cmd *cobra.Command, args []string) error { | ||||||
if len(args) <= 1 { | ||||||
return cmd.Help() | ||||||
} | ||||||
taskName := common.GetTaskNameFromArgOrFile(cmd.Flags().Arg(0)) | ||||||
sqls, err := common.ExtractSQLsFromArgs(cmd.Flags().Args()[1:]) | ||||||
if err != nil { | ||||||
return err | ||||||
} | ||||||
return sendHandleErrorRequest(cmd, pb.ErrorOp_Replace, taskName, sqls) | ||||||
}, | ||||||
} | ||||||
return cmd | ||||||
} | ||||||
|
||||||
func newBinlogRevertCmd() *cobra.Command { | ||||||
cmd := &cobra.Command{ | ||||||
Use: "revert <task-name>", | ||||||
Short: "revert the current binlog operation or a specific binlog position (binlog-pos) operation", | ||||||
RunE: func(cmd *cobra.Command, args []string) error { | ||||||
if len(args) == 0 { | ||||||
return cmd.Help() | ||||||
} | ||||||
taskName := common.GetTaskNameFromArgOrFile(cmd.Flags().Arg(0)) | ||||||
return sendHandleErrorRequest(cmd, pb.ErrorOp_Revert, taskName, nil) | ||||||
}, | ||||||
} | ||||||
return cmd | ||||||
} | ||||||
|
||||||
// FIXME: implement this later. | ||||||
func newBinlogInjectCmd() *cobra.Command { | ||||||
cmd := &cobra.Command{ | ||||||
Use: "inject <task-name> <inject-sql1> <replace-sql2>...", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Short: "inject the current error event or a specific binlog position (binlog-pos) ddl event with some ddls", | ||||||
Hidden: true, | ||||||
RunE: func(cmd *cobra.Command, args []string) error { | ||||||
return errors.Errorf("this function will be supported later") | ||||||
}, | ||||||
} | ||||||
return cmd | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.