Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

dmctl: fix handle err commands #1746

Merged
merged 35 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f245398
first commit
lichunzhu Jun 2, 2021
4e173c8
merge master and resolve conflicts
lichunzhu Jun 2, 2021
cefdcf6
update tests and ctl code
lichunzhu Jun 3, 2021
bc631b0
Merge branch 'master' into fixHandleErrCommands
lichunzhu Jun 3, 2021
cb9c6f8
try to fix tests
lichunzhu Jun 3, 2021
e32ea81
Merge branch 'master' of https://github.com/pingcap/dm into fixHandle…
lichunzhu Jun 4, 2021
f7616d8
fix help_cnt
lichunzhu Jun 4, 2021
4380557
Merge branch 'master' into fixHandleErrCommands
Ehco1996 Jun 11, 2021
48301b4
resolve conflicts
lichunzhu Jul 30, 2021
5f8ea2f
Merge branch 'fixHandleErrCommands' of https://github.com/lichunzhu/d…
lichunzhu Jul 30, 2021
573e62a
Merge branch 'master' into fixHandleErrCommands
lichunzhu Jul 30, 2021
313f7e7
change output to dir
lichunzhu Jul 30, 2021
2a1f09e
Merge branch 'fixHandleErrCommands' of https://github.com/lichunzhu/d…
lichunzhu Jul 30, 2021
b09a764
try fix
lichunzhu Jul 30, 2021
85b93e3
try fix again
lichunzhu Jul 30, 2021
f1014d3
address comments
lichunzhu Jul 30, 2021
4d555f3
Merge branch 'master' into fixHandleErrCommands
lichunzhu Jul 30, 2021
e3a68f2
address comments
lichunzhu Jul 30, 2021
f3eb01a
Merge branch 'fixHandleErrCommands' of https://github.com/lichunzhu/d…
lichunzhu Jul 30, 2021
7738063
Merge branch 'master' into fixHandleErrCommands
lichunzhu Jul 30, 2021
ce84214
address comments
lichunzhu Jul 30, 2021
0eef9d0
Merge branch 'fixHandleErrCommands' of https://github.com/lichunzhu/d…
lichunzhu Jul 30, 2021
4f3102c
change --dir to --path
lichunzhu Aug 3, 2021
3efd1d4
Merge branch 'master' into fixHandleErrCommands
lichunzhu Aug 3, 2021
ad653f4
revise source-table-schema to binlog-schema
lichunzhu Aug 3, 2021
941a751
fix integration tests
lichunzhu Aug 3, 2021
a6ce2b9
fix it again
lichunzhu Aug 4, 2021
d3cc3df
Merge branch 'master' into fixHandleErrCommands
GMHDBJD Aug 6, 2021
2adbde7
address comments
lichunzhu Aug 6, 2021
12d4c42
address comments
lichunzhu Aug 16, 2021
a38dbaa
merge master and resolve conflicts
lichunzhu Aug 16, 2021
fe19681
fix tests
lichunzhu Aug 16, 2021
8989ba6
Merge branch 'master' of https://github.com/pingcap/dm into fixHandle…
lichunzhu Aug 17, 2021
72226d1
Merge branch 'master' into fixHandleErrCommands
lance6716 Aug 17, 2021
b949151
Merge branch 'master' into fixHandleErrCommands
ti-chi-bot Aug 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions dm/ctl/ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,17 @@ func NewRootCmd() *cobra.Command {
master.NewTransferSourceCmd(),
master.NewStartRelayCmd(),
master.NewStopRelayCmd(),
master.NewBinlogCmd(),
master.NewShardDDLLockCmd(),
master.NewSourceTableSchemaCmd(),
master.NewConfigCmd(),
newDecryptCmd(),
newEncryptCmd(),
)
// copied from (*cobra.Command).InitDefaultHelpCmd
helpCmd := &cobra.Command{
Use: "help [command]",
Short: "Gets help about any command.",
Short: "Gets help about any command",
Long: `Help provides help for any command in the application.
Simply type ` + cmd.Name() + ` help [path to command] for full details.`,

Expand Down Expand Up @@ -236,7 +239,7 @@ func MainStart(args []string) {
func newEncryptCmd() *cobra.Command {
return &cobra.Command{
Use: "encrypt <plain-text>",
Short: "Encrypts plain text to cipher text.",
Short: "Encrypts plain text to cipher text",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return cmd.Help()
Expand Down
101 changes: 101 additions & 0 deletions dm/ctl/master/binlog.go
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\"")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.PersistentFlags().StringP("binlog-pos", "b", "", "position used to match binlog event if matched the binlog 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>...",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use: "inject <task-name> <inject-sql1> <replace-sql2>...",
Use: "inject <task-name> <inject-sql1> <inject-sql2>...",

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
}
2 changes: 1 addition & 1 deletion dm/ctl/master/check_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
func NewCheckTaskCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "check-task <config-file> [--error count] [--warn count]",
Short: "Checks the configuration file of the task.",
Short: "Checks the configuration file of the task",
RunE: checkTaskFunc,
}
cmd.Flags().Int64P("error", "e", common.DefaultErrorCnt, "max count of errors to display")
Expand Down
Loading