github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/ctl/master/shard_ddl_lock.go (about)

     1  // Copyright 2021 PingCAP, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package master
    15  
    16  import (
    17  	"github.com/spf13/cobra"
    18  )
    19  
    20  // NewShardDDLLockCmd creates a ShardDDLLock command.
    21  func NewShardDDLLockCmd() *cobra.Command {
    22  	cmd := &cobra.Command{
    23  		Use:   "shard-ddl-lock [task]",
    24  		Short: "maintain or show shard-ddl locks information",
    25  		RunE:  showDDLLocksFunc,
    26  	}
    27  	cmd.AddCommand(
    28  		newDDLLockUnlockCmd(),
    29  	)
    30  
    31  	return cmd
    32  }
    33  
    34  func newDDLLockUnlockCmd() *cobra.Command {
    35  	cmd := &cobra.Command{
    36  		Use:   "unlock <lock-id>",
    37  		Short: "Unlock un-resolved DDL locks forcely",
    38  		RunE:  unlockDDLLockFunc,
    39  	}
    40  	cmd.Flags().StringP("owner", "o", "", "source to replace the default owner")
    41  	cmd.Flags().BoolP("force-remove", "f", false, "force to remove DDL lock")
    42  	cmd.Flags().StringP("action", "a", "skip", "accept skip/exec values which means whether to skip or execute ddls")
    43  	cmd.Flags().StringP("database", "d", "", "database name of the table")
    44  	cmd.Flags().StringP("table", "t", "", "table name")
    45  	return cmd
    46  }