Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions go/cmd/mysqlctl/command/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/spf13/cobra"

"vitess.io/vitess/go/vt/mysqlctl"
"vitess.io/vitess/go/vt/utils"
)

var Init = &cobra.Command{
Expand Down Expand Up @@ -64,8 +65,8 @@ func commandInit(cmd *cobra.Command, args []string) error {
}

func init() {
Init.Flags().DurationVar(&initArgs.WaitTime, "wait_time", initArgs.WaitTime, "How long to wait for mysqld startup.")
Init.Flags().StringVar(&initArgs.InitDbSQLFile, "init_db_sql_file", initArgs.InitDbSQLFile, "Path to .sql file to run after mysqld initiliaztion.")
utils.SetFlagDurationVar(Init.Flags(), &initArgs.WaitTime, "wait-time", initArgs.WaitTime, "How long to wait for mysqld startup.")
utils.SetFlagStringVar(Init.Flags(), &initArgs.InitDbSQLFile, "init-db-sql-file", initArgs.InitDbSQLFile, "Path to .sql file to run after mysqld initiliaztion.")

Root.AddCommand(Init)
}
5 changes: 3 additions & 2 deletions go/cmd/mysqlctl/command/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ import (
"github.com/spf13/cobra"

"vitess.io/vitess/go/vt/mysqlctl"
"vitess.io/vitess/go/vt/utils"
)

var Shutdown = &cobra.Command{
Use: "shutdown",
Short: "Shuts down mysqld, without removing any files.",
Long: "Stop a `mysqld` instance that was previously started with `init` or `start`.\n\n" +
"For large `mysqld` instances, you may need to extend the `wait_time` to shutdown cleanly.",
"For large `mysqld` instances, you may need to extend the `wait-time` to shutdown cleanly.",
Example: `mysqlctl --tablet-uid 101 --alsologtostderr shutdown`,
Args: cobra.NoArgs,
RunE: commandShutdown,
Expand Down Expand Up @@ -59,7 +60,7 @@ func commandShutdown(cmd *cobra.Command, args []string) error {
}

func init() {
Shutdown.Flags().DurationVar(&shutdownArgs.WaitTime, "wait_time", shutdownArgs.WaitTime, "How long to wait for mysqld shutdown.")
utils.SetFlagDurationVar(Shutdown.Flags(), &shutdownArgs.WaitTime, "wait-time", shutdownArgs.WaitTime, "How long to wait for mysqld shutdown.")

Root.AddCommand(Shutdown)
}
3 changes: 2 additions & 1 deletion go/cmd/mysqlctl/command/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"vitess.io/vitess/go/flagutil"
"vitess.io/vitess/go/vt/mysqlctl"
"vitess.io/vitess/go/vt/utils"
)

var Start = &cobra.Command{
Expand Down Expand Up @@ -60,7 +61,7 @@ func commandStart(cmd *cobra.Command, args []string) error {
}

func init() {
Start.Flags().DurationVar(&startArgs.WaitTime, "wait_time", startArgs.WaitTime, "How long to wait for mysqld startup.")
utils.SetFlagDurationVar(Start.Flags(), &startArgs.WaitTime, "wait-time", startArgs.WaitTime, "How long to wait for mysqld startup.")
Start.Flags().Var(&startArgs.MySQLdArgs, "mysqld_args", "List of comma-separated flags to pass additionally to mysqld.")

Root.AddCommand(Start)
Expand Down
3 changes: 2 additions & 1 deletion go/cmd/mysqlctl/command/teardown.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/spf13/cobra"

"vitess.io/vitess/go/vt/mysqlctl"
"vitess.io/vitess/go/vt/utils"
)

var Teardown = &cobra.Command{
Expand Down Expand Up @@ -62,7 +63,7 @@ func commandTeardown(cmd *cobra.Command, args []string) error {
}

func init() {
Teardown.Flags().DurationVar(&teardownArgs.WaitTime, "wait_time", teardownArgs.WaitTime, "How long to wait for mysqld shutdown.")
utils.SetFlagDurationVar(Teardown.Flags(), &teardownArgs.WaitTime, "wait-time", teardownArgs.WaitTime, "How long to wait for mysqld shutdown.")
Teardown.Flags().BoolVarP(&teardownArgs.Force, "force", "f", teardownArgs.Force, "Remove the root directory even if mysqld shutdown fails.")

Root.AddCommand(Teardown)
Expand Down
6 changes: 3 additions & 3 deletions go/cmd/mysqlctld/cli/mysqlctld.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var (
--log_dir=${VTDATAROOT}/logs \
--tablet-uid=100 \
--mysql-port=17100 \
--socket_file=/path/to/socket_file`,
--socket-file=/path/to/socket-file`,
Args: cobra.NoArgs,
Version: servenv.AppVersion.String(),
PreRunE: servenv.CobraPreRunE,
Expand Down Expand Up @@ -95,8 +95,8 @@ func init() {
utils.SetFlagIntVar(Main.Flags(), &mysqlPort, "mysql-port", mysqlPort, "MySQL port")
utils.SetFlagUint32Var(Main.Flags(), &tabletUID, "tablet-uid", tabletUID, "Tablet UID")
utils.SetFlagStringVar(Main.Flags(), &mysqlSocket, "mysql-socket", mysqlSocket, "Path to the mysqld socket file")
Main.Flags().DurationVar(&waitTime, "wait_time", waitTime, "How long to wait for mysqld startup")
Main.Flags().StringVar(&initDBSQLFile, "init_db_sql_file", initDBSQLFile, "Path to .sql file to run after mysqld initialization")
utils.SetFlagDurationVar(Main.Flags(), &waitTime, "wait-time", waitTime, "How long to wait for mysqld startup")
utils.SetFlagStringVar(Main.Flags(), &initDBSQLFile, "init-db-sql-file", initDBSQLFile, "Path to .sql file to run after mysqld initialization")
Main.Flags().DurationVar(&shutdownWaitTime, "shutdown-wait-time", shutdownWaitTime, "How long to wait for mysqld shutdown")

acl.RegisterFlags(Main.Flags())
Expand Down
4 changes: 2 additions & 2 deletions go/cmd/vtbackup/cli/vtbackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func init() {
Main.Flags().DurationVar(&minBackupInterval, "min_backup_interval", minBackupInterval, "Only take a new backup if it's been at least this long since the most recent backup.")
Main.Flags().DurationVar(&minRetentionTime, "min_retention_time", minRetentionTime, "Keep each old backup for at least this long before removing it. Set to 0 to disable pruning of old backups.")
Main.Flags().IntVar(&minRetentionCount, "min_retention_count", minRetentionCount, "Always keep at least this many of the most recent backups in this backup storage location, even if some are older than the min_retention_time. This must be at least 1 since a backup must always exist to allow new backups to be made")
Main.Flags().BoolVar(&initialBackup, "initial_backup", initialBackup, "Instead of restoring from backup, initialize an empty database with the provided init_db_sql_file and upload a backup of that for the shard, if the shard has no backups yet. This can be used to seed a brand new shard with an initial, empty backup. If any backups already exist for the shard, this will be considered a successful no-op. This can only be done before the shard exists in topology (i.e. before any tablets are deployed).")
Main.Flags().BoolVar(&initialBackup, "initial_backup", initialBackup, "Instead of restoring from backup, initialize an empty database with the provided init-db-sql-file and upload a backup of that for the shard, if the shard has no backups yet. This can be used to seed a brand new shard with an initial, empty backup. If any backups already exist for the shard, this will be considered a successful no-op. This can only be done before the shard exists in topology (i.e. before any tablets are deployed).")
Main.Flags().BoolVar(&allowFirstBackup, "allow_first_backup", allowFirstBackup, "Allow this job to take the first backup of an existing shard.")
Main.Flags().BoolVar(&restartBeforeBackup, "restart_before_backup", restartBeforeBackup, "Perform a mysqld clean/full restart after applying binlogs, but before taking the backup. Only makes sense to work around xtrabackup bugs.")
Main.Flags().BoolVar(&upgradeSafe, "upgrade-safe", upgradeSafe, "Whether to use innodb_fast_shutdown=0 for the backup so it is safe to use for MySQL upgrades.")
Expand All @@ -221,7 +221,7 @@ func init() {
utils.SetFlagStringVar(Main.Flags(), &mysqlSocket, "mysql-socket", mysqlSocket, "Path to the mysqld socket file")
Main.Flags().DurationVar(&mysqlTimeout, "mysql_timeout", mysqlTimeout, "how long to wait for mysqld startup")
Main.Flags().DurationVar(&mysqlShutdownTimeout, "mysql-shutdown-timeout", mysqlShutdownTimeout, "how long to wait for mysqld shutdown")
Main.Flags().StringVar(&initDBSQLFile, "init_db_sql_file", initDBSQLFile, "path to .sql file to run after mysql_install_db")
utils.SetFlagStringVar(Main.Flags(), &initDBSQLFile, "init-db-sql-file", initDBSQLFile, "path to .sql file to run after mysql_install_db")
Main.Flags().BoolVar(&detachedMode, "detach", detachedMode, "detached mode - run backups detached from the terminal")
Main.Flags().DurationVar(&keepAliveTimeout, "keep-alive-timeout", keepAliveTimeout, "Wait until timeout elapses after a successful backup before shutting down.")
Main.Flags().BoolVar(&disableRedoLog, "disable-redo-log", disableRedoLog, "Disable InnoDB redo log during replication-from-primary phase of backup.")
Expand Down
3 changes: 2 additions & 1 deletion go/cmd/vtctl/vtctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/utils"
"vitess.io/vitess/go/vt/vtctl"
"vitess.io/vitess/go/vt/vtctl/grpcvtctldserver"
"vitess.io/vitess/go/vt/vtctl/localvtctldclient"
Expand Down Expand Up @@ -86,7 +87,7 @@ func init() {
vtctl.PrintAllCommands(logger)
}

fs.DurationVar(&waitTime, "wait-time", waitTime, "time to wait on an action")
utils.SetFlagDurationVar(fs, &waitTime, "wait-time", waitTime, "time to wait on an action")
fs.BoolVar(&detachedMode, "detach", detachedMode, "detached mode - run vtcl detached from the terminal")

acl.RegisterFlags(fs)
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/mysqlctl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Flags:
--replication-connect-retry duration how long to wait in between replica reconnect attempts. Only precise to the second. (default 10s)
--security-policy string the name of a registered security policy to use for controlling access to URLs - empty means allow all for anyone (built-in policies: deny-all, read-only)
--service-map strings comma separated list of services to enable (or disable if prefixed with '-') Example: grpc-queryservice
--socket_file string Local unix socket file to listen on
--socket-file string Local unix socket file to listen on
--stderrthreshold severityFlag logs at or above this threshold go to stderr (default 1)
--table-refresh-interval int interval in milliseconds to refresh tables in status page with refreshRequired class
--tablet-dir string The directory within the vtdataroot to store vttablet/mysql files. Defaults to being generated by the tablet uid.
Expand Down
8 changes: 4 additions & 4 deletions go/flags/endtoend/mysqlctld.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mysqlctld \
--log_dir=${VTDATAROOT}/logs \
--tablet-uid=100 \
--mysql-port=17100 \
--socket_file=/path/to/socket_file
--socket-file=/path/to/socket-file

Flags:
--alsologtostderr log to standard error as well as files
Expand Down Expand Up @@ -89,7 +89,7 @@ Flags:
--grpc-server-keepalive-time duration After a duration of this time, if the server doesn't see any activity, it pings the client to see if the transport is still alive. (default 10s)
--grpc-server-keepalive-timeout duration After having pinged for keepalive check, the server waits for a duration of Timeout and if no activity is seen even after that the connection is closed. (default 10s)
-h, --help help for mysqlctld
--init_db_sql_file string Path to .sql file to run after mysqld initialization
--init-db-sql-file string Path to .sql file to run after mysqld initialization
--keep-logs duration keep logs for this long (using ctime) (zero to keep forever)
--keep-logs-by-mtime duration keep logs for this long (using mtime) (zero to keep forever)
--lameduck-period duration keep running at least this long after SIGTERM before stopping (default 50ms)
Expand All @@ -116,12 +116,12 @@ Flags:
--security-policy string the name of a registered security policy to use for controlling access to URLs - empty means allow all for anyone (built-in policies: deny-all, read-only)
--service-map strings comma separated list of services to enable (or disable if prefixed with '-') Example: grpc-queryservice
--shutdown-wait-time duration How long to wait for mysqld shutdown (default 5m0s)
--socket_file string Local unix socket file to listen on
--socket-file string Local unix socket file to listen on
--stderrthreshold severityFlag logs at or above this threshold go to stderr (default 1)
--table-refresh-interval int interval in milliseconds to refresh tables in status page with refreshRequired class
--tablet-dir string The directory within the vtdataroot to store vttablet/mysql files. Defaults to being generated by the tablet uid.
--tablet-uid uint32 Tablet UID (default 41983)
--v Level log level for V logs
-v, --version print binary version
--vmodule vModuleFlag comma-separated list of pattern=N settings for file-filtered logging
--wait_time duration How long to wait for mysqld startup (default 5m0s)
--wait-time duration How long to wait for mysqld startup (default 5m0s)
4 changes: 2 additions & 2 deletions go/flags/endtoend/vtbackup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ Flags:
-h, --help help for vtbackup
--incremental_from_pos string Position, or name of backup from which to create an incremental backup. Default: empty. If given, then this backup becomes an incremental backup from given position or given backup. If value is 'auto', this backup will be taken from the last successful backup position.
--init-db-name-override string (init parameter) override the name of the db used by vttablet
--init-db-sql-file string path to .sql file to run after mysql_install_db
--init-keyspace string (init parameter) keyspace to use for this tablet
--init-shard string (init parameter) shard to use for this tablet
--init_db_sql_file string path to .sql file to run after mysql_install_db
--initial_backup Instead of restoring from backup, initialize an empty database with the provided init_db_sql_file and upload a backup of that for the shard, if the shard has no backups yet. This can be used to seed a brand new shard with an initial, empty backup. If any backups already exist for the shard, this will be considered a successful no-op. This can only be done before the shard exists in topology (i.e. before any tablets are deployed).
--initial_backup Instead of restoring from backup, initialize an empty database with the provided init-db-sql-file and upload a backup of that for the shard, if the shard has no backups yet. This can be used to seed a brand new shard with an initial, empty backup. If any backups already exist for the shard, this will be considered a successful no-op. This can only be done before the shard exists in topology (i.e. before any tablets are deployed).
--keep-alive-timeout duration Wait until timeout elapses after a successful backup before shutting down.
--keep-logs duration keep logs for this long (using ctime) (zero to keep forever)
--keep-logs-by-mtime duration keep logs for this long (using mtime) (zero to keep forever)
Expand Down
5 changes: 3 additions & 2 deletions go/test/endtoend/cluster/mysqlctl_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type MysqlctlProcess struct {
// InitDb executes mysqlctl command to add cell info
func (mysqlctl *MysqlctlProcess) InitDb() (err error) {
args := []string{"--log_dir", mysqlctl.LogDirectory,
//TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation
//todo: Remove underscore(_) flags in v25, replace them with dashed(-) notation
"--tablet_uid", fmt.Sprintf("%d", mysqlctl.TabletUID),
"--mysql_port", fmt.Sprintf("%d", mysqlctl.MySQLPort),
"init",
Expand All @@ -63,6 +63,7 @@ func (mysqlctl *MysqlctlProcess) InitDb() (err error) {
args = append(args, "--")
}

//TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation
args = append(args, "--init_db_sql_file", mysqlctl.InitDBFile)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the reason we can't change this yet because we run this same code for upgrade / downgrade tests from this version? Or do we then run the code from the older version for this test setup too?

Copy link
Collaborator

@nickvanw nickvanw Sep 3, 2025

Choose a reason for hiding this comment

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

This is a pretty common pattern in the code, I haven't looked at these particular tests. Quite a few in #18280 as well, etc.

I want to check and see if we can bump these or have some sort of logic, it's a smell that we have all of these TODOs imo.

It might be worth doing in a follow-up PR, so that we can get these merged before release?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we run this endtoend code also with the older version, so maybe it's what we have to live with until we branch off v23 and then we clean it up for v24?

Regardless, it's something we can defer then for a later PR as well.

if *isCoverage {
args = append([]string{"--test.coverprofile=" + getCoveragePath("mysql-initdb.out"), "--test.v"}, args...)
Expand Down Expand Up @@ -156,7 +157,7 @@ ssl_key={{.ServerKey}}
if mysqlctl.MajorVersion < 18 {
tmpProcess.Args = append(tmpProcess.Args, "--")
}

//TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation
tmpProcess.Args = append(tmpProcess.Args, "--init_db_sql_file", mysqlctl.InitDBFile)
} else {
tmpProcess.Args = append(tmpProcess.Args, "start")
Expand Down
2 changes: 2 additions & 0 deletions go/test/endtoend/cluster/mysqlctld_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (mysqlctld *MysqlctldProcess) Start() error {
"--mysql_port", fmt.Sprintf("%d", mysqlctld.MySQLPort),
}
if mysqlctld.SocketFile != "" {
//TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation
args = append(args, "--socket_file", mysqlctld.SocketFile)
}
tempProcess := exec.Command(
Expand All @@ -91,6 +92,7 @@ func (mysqlctld *MysqlctldProcess) Start() error {

if mysqlctld.InitMysql {
tempProcess.Args = append(tempProcess.Args,
//TODO: Remove underscore(_) flags in v25, replace them with dashed(-) notation
"--init_db_sql_file", mysqlctld.InitDBFile)
}

Expand Down
3 changes: 2 additions & 1 deletion go/test/endtoend/cluster/vtbackup_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (vtbackup *VtbackupProcess) Setup() (err error) {

//initDBfile is required to run vtbackup
"--mysql-port": fmt.Sprintf("%d", vtbackup.MysqlPort),
"--init_db_sql_file": vtbackup.initDBfile,
"--init-db-sql-file": vtbackup.initDBfile,
"--init-keyspace": vtbackup.Keyspace,
"--init-shard": vtbackup.Shard,

Expand All @@ -78,6 +78,7 @@ func (vtbackup *VtbackupProcess) Setup() (err error) {
utils.SetFlagVariantsForTests(flags, "--topo-global-server-address", vtbackup.TopoGlobalAddress)
utils.SetFlagVariantsForTests(flags, "--topo-global-root", vtbackup.TopoGlobalRoot)
utils.SetFlagVariantsForTests(flags, "--mysql-port", fmt.Sprintf("%d", vtbackup.MysqlPort))
utils.SetFlagVariantsForTests(flags, "--init-db-sql-file", vtbackup.initDBfile)
utils.SetFlagVariantsForTests(flags, "--init-keyspace", vtbackup.Keyspace)
utils.SetFlagVariantsForTests(flags, "--init-shard", vtbackup.Shard)
utils.SetFlagVariantsForTests(flags, "--backup-storage-implementation", vtbackup.BackupStorageImplementation)
Expand Down
6 changes: 3 additions & 3 deletions go/vt/mysqlctl/mysqld.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,15 +802,15 @@ func (mysqld *Mysqld) Init(ctx context.Context, cnf *Mycnf, initDBSQLFile string
// else, user specified an init db file
sqlFile, err := os.Open(initDBSQLFile)
if err != nil {
return fmt.Errorf("can't open init_db_sql_file (%v): %v", initDBSQLFile, err)
return fmt.Errorf("can't open init-db-sql-file (%v): %v", initDBSQLFile, err)
}
defer sqlFile.Close()
script, err := io.ReadAll(sqlFile)
if err != nil {
return fmt.Errorf("can't read init_db_sql_file (%v): %v", initDBSQLFile, err)
return fmt.Errorf("can't read init-db-sql-file (%v): %v", initDBSQLFile, err)
}
if err := mysqld.executeMysqlScript(ctx, params, string(script)); err != nil {
return fmt.Errorf("can't run init_db_sql_file (%v): %v", initDBSQLFile, err)
return fmt.Errorf("can't run init-db-sql-file (%v): %v", initDBSQLFile, err)
}
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion go/vt/servenv/unix_socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/spf13/pflag"

"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

var (
Expand Down Expand Up @@ -59,6 +60,6 @@ func serveSocketFile() {
// to a socket. This needs to be called before flags are parsed.
func RegisterDefaultSocketFileFlags() {
OnParse(func(fs *pflag.FlagSet) {
fs.StringVar(&socketFile, "socket_file", socketFile, "Local unix socket file to listen on")
utils.SetFlagStringVar(fs, &socketFile, "socket-file", socketFile, "Local unix socket file to listen on")
})
}
Loading
Loading