diff --git a/.agents/skills/e2e-tests/SKILL.md b/.agents/skills/e2e-tests/SKILL.md index ea00c65f4e9..8127f3610e2 100644 --- a/.agents/skills/e2e-tests/SKILL.md +++ b/.agents/skills/e2e-tests/SKILL.md @@ -56,7 +56,6 @@ $VTDATAROOT/ vtgate-stderr.txt vttablet-stderr.txt mysqlctl-stderr.txt - *.INFO, *.WARNING, *.ERROR # glog files backups/ # backup data ``` @@ -68,7 +67,7 @@ When a test fails, read logs from the tmp directory inside the cluster's VTDATAR $VTDATAROOT/vtroot_/tmp_/ ``` -Look for `*-stderr.txt` files and glog files (`*.INFO`, `*.WARNING`, `*.ERROR`). +Look for `*-stderr.txt` files. ### Clear between runs @@ -90,5 +89,4 @@ Each end-to-end test package starts a `cluster.LocalProcessCluster` (topo, vtctl 2. Rebuild binaries: `make build` 3. Run the failing test with `-v` 4. On failure, read logs from `$VTDATAROOT/vtroot_*/tmp_*/` -5. Check `*-stderr.txt` files first for startup errors -6. Check glog `*.ERROR` and `*.WARNING` files for runtime errors +5. Check the `*-stderr.txt` files for startup and runtime errors. Search for the `ERR` and `WRN` levels. diff --git a/.github/workflows/vitess_tester_vtgate.yml b/.github/workflows/vitess_tester_vtgate.yml index f1d867b3fe0..6da7c99b4d8 100644 --- a/.github/workflows/vitess_tester_vtgate.yml +++ b/.github/workflows/vitess_tester_vtgate.yml @@ -103,7 +103,7 @@ jobs: go install github.com/vitessio/go-junit-report@99fa7f0daf16db969f54a49139a14471e633e6e8 # HEAD # install vitess tester - go install github.com/vitessio/vt/go/vt@e43009309f599378504905d4b804460f47822ac5 + go install github.com/vitessio/vt/go/vt@cee2a0631a4959284967bd5ea1268c1dcf4aa457 - name: Setup launchable dependencies if: github.event_name == 'pull_request' && github.event.pull_request.draft == 'false' && steps.changes.outputs.end_to_end == 'true' && github.base_ref == 'main' diff --git a/changelog/25.0/25.0.0/summary.md b/changelog/25.0/25.0.0/summary.md index 6dc8f68daaa..f2cc144a358 100644 --- a/changelog/25.0/25.0.0/summary.md +++ b/changelog/25.0/25.0.0/summary.md @@ -10,6 +10,7 @@ - **[New Support](#new-support)** - [VTOrc failover of an unreachable primary `vttablet` via replica quorum](#vtorc-quorum-unreachable-primary) - **[Breaking Changes](#breaking-changes)** + - [`glog` logging removed](#glog-removed) - [`--watch-replication-stream` flag removed](#vttablet-watch-replication-stream-removed) - [VRLog feature removed](#vttablet-vrlog-removed) - [Snapshot Topology feature removed](#vtorc-snapshot-topology-removed) @@ -117,6 +118,39 @@ See [#19918](https://github.com/vitessio/vitess/issues/19918). ### Breaking Changes +#### `glog` logging removed + +The `glog` backend and its command-line flags have been removed after their deprecation in +[v24](../../24.0/24.0.0/summary.md#structured-logging). Vitess uses structured logging only. + +This release removes the following `glog` flags from each binary that registered them. + +- `--logtostderr`, `--alsologtostderr`, `--stderrthreshold` +- `--log_dir`, `--log_link`, `--log_backtrace_at` +- `--v`, `--vmodule`, `--logbuflevel` + +The following flags did not show a deprecation warning in v24. This release keeps them as no-ops that show a +deprecation warning. v26 removes them. + +- `--log-structured`, `--log-rotate-max-size`, `--keep-logs`, `--keep-logs-by-mtime`, and `--purge-logs-interval` on + all binaries that registered them +- `--logtostderr` and `--alsologtostderr` on `vtctldclient` and `vtctlclient` + +A binary fails to start with `--log-structured=false`, because that value asks for `glog` log files. + +The other `glog` flags on `vtctldclient` and `vtctlclient` did not show a deprecation warning in v24, but this release +removes them. `vtctldclient` uses `-v` as the shorthand for `--version`, the same as the other binaries. `-v` does not +set a log level. + +The `/debug/flushlogs` HTTP endpoint is deprecated and is a no-op. It responds with success and logs a deprecation +warning. v26 removes it. + +**Migration**: remove the flags above from startup arguments. + +**Impact**: a binary fails to start when it receives a removed flag or `--log-structured=false`. + +See [#21310](https://github.com/vitessio/vitess/issues/21310). + #### `--watch-replication-stream` flag removed The deprecated `--watch-replication-stream` VTTablet flag has been removed. @@ -197,6 +231,14 @@ The vtctld and vtcombo flags `--cell`, `--proxy-tablets`, `--action-timeout`, an **Impact**: Remove any usage of these flags from vtctld and vtcombo startup scripts or configuration. +The logging flags `--log-structured`, `--log-rotate-max-size`, `--keep-logs`, `--keep-logs-by-mtime`, and `--purge-logs-interval`, and the `vtctldclient` and `vtctlclient` flags `--logtostderr` and `--alsologtostderr`, are now deprecated and are no-ops, as the [`glog` backend has been removed](#glog-removed). The flags will be removed entirely in v26. + +**Impact**: Remove any usage of these flags from startup scripts or configuration. + +The `/debug/flushlogs` HTTP endpoint is now deprecated and is a no-op, as the [`glog` backend has been removed](#glog-removed). The endpoint will be removed entirely in v26. + +**Impact**: Remove any calls to `/debug/flushlogs`. + #### Legacy streaming-path plan types in query rules The `SelectStream` query plan type no longer exists: statements served over the streaming path now produce the same plan types as buffered execution (`Select`, `Show`, `SelectLockFunc`, ...), so query rules keyed on those concrete plan names now apply to both execution paths. diff --git a/docker/mini/vtctld-mini-up.sh b/docker/mini/vtctld-mini-up.sh index d9aae44074a..9d31d7a0d3e 100755 --- a/docker/mini/vtctld-mini-up.sh +++ b/docker/mini/vtctld-mini-up.sh @@ -30,7 +30,6 @@ vtctld \ -service-map 'grpc-vtctl' \ -backup-storage-implementation file \ -file-backup-storage-root $VTDATAROOT/backups \ - -log_dir $VTDATAROOT/tmp \ -port $vtctld_web_port \ -grpc-port $grpc_port \ -pid-file $VTDATAROOT/tmp/vtctld.pid \ diff --git a/docker/mini/vttablet-mini-up.sh b/docker/mini/vttablet-mini-up.sh index 1bbd6b6ea6f..cb2b59d30dd 100755 --- a/docker/mini/vttablet-mini-up.sh +++ b/docker/mini/vttablet-mini-up.sh @@ -41,7 +41,6 @@ echo " - Tablet listens on http://$hostname:$port" # shellcheck disable=SC2086 vttablet \ $TOPOLOGY_FLAGS \ - -log_dir $VTDATAROOT/tmp \ -log-queries-to-file $VTDATAROOT/tmp/$tablet_logfile \ -tablet-path $alias \ -tablet-hostname "$hostname" \ diff --git a/examples/common/backup-scripts/mysqlctl-up.sh b/examples/common/backup-scripts/mysqlctl-up.sh index d46b5e1737e..4fd3f964999 100755 --- a/examples/common/backup-scripts/mysqlctl-up.sh +++ b/examples/common/backup-scripts/mysqlctl-up.sh @@ -36,7 +36,6 @@ if [ -d $VTDATAROOT/$tablet_dir ]; then fi mysqlctl \ - --log_dir $VTDATAROOT/tmp \ --tablet-uid $uid \ --mysql-port $mysql_port \ $action diff --git a/examples/common/backup-scripts/vtadmin-up.sh b/examples/common/backup-scripts/vtadmin-up.sh index 613ae246cda..02ce222e07a 100755 --- a/examples/common/backup-scripts/vtadmin-up.sh +++ b/examples/common/backup-scripts/vtadmin-up.sh @@ -39,8 +39,6 @@ vtadmin \ --tracer "opentelemetry" \ --grpc-tracing \ --http-tracing \ - --logtostderr \ - --alsologtostderr \ --rbac \ --rbac-config="${script_dir}/../vtadmin/rbac.yaml" \ --cluster "id=${cluster_name},name=${cluster_name},discovery=staticfile,discovery-staticfile-path=${script_dir}/../vtadmin/discovery.json,tablet-fqdn-tmpl=http://{{ .Tablet.Hostname }}:15{{ .Tablet.Alias.Uid }},schema-cache-default-expiration=1m" \ diff --git a/examples/common/backup-scripts/vtctld-up.sh b/examples/common/backup-scripts/vtctld-up.sh index 614bd41d8f0..0ebbe07ee07 100755 --- a/examples/common/backup-scripts/vtctld-up.sh +++ b/examples/common/backup-scripts/vtctld-up.sh @@ -27,7 +27,6 @@ vtctld \ --service-map 'grpc-vtctl,grpc-vtctld' \ --backup-storage-implementation file \ --file-backup-storage-root $VTDATAROOT/backups \ - --log_dir $VTDATAROOT/tmp \ --port $vtctld_web_port \ --grpc-port $grpc_port \ --pid-file $VTDATAROOT/tmp/vtctld.pid \ diff --git a/examples/common/backup-scripts/vtgate-up.sh b/examples/common/backup-scripts/vtgate-up.sh index ef53b3132ed..2dc80d4b2fd 100755 --- a/examples/common/backup-scripts/vtgate-up.sh +++ b/examples/common/backup-scripts/vtgate-up.sh @@ -28,7 +28,6 @@ echo "Starting vtgate..." # shellcheck disable=SC2086 vtgate \ $TOPOLOGY_FLAGS \ - --log_dir $VTDATAROOT/tmp \ --log-queries-to-file $VTDATAROOT/tmp/vtgate_querylog.txt \ --port $web_port \ --grpc-port $grpc_port \ diff --git a/examples/common/backup-scripts/vtorc-up.sh b/examples/common/backup-scripts/vtorc-up.sh index 9d4a14cec2d..cff14cacb92 100755 --- a/examples/common/backup-scripts/vtorc-up.sh +++ b/examples/common/backup-scripts/vtorc-up.sh @@ -10,8 +10,6 @@ port=16000 echo "Starting vtorc..." vtorc \ $TOPOLOGY_FLAGS \ - --logtostderr \ - --alsologtostderr \ --config-path="${script_dir}/../vtorc/" \ --config-name="config.yaml" \ --config-type="yml" \ diff --git a/examples/common/backup-scripts/vttablet-up.sh b/examples/common/backup-scripts/vttablet-up.sh index a5dba44deea..867f95e2557 100755 --- a/examples/common/backup-scripts/vttablet-up.sh +++ b/examples/common/backup-scripts/vttablet-up.sh @@ -43,7 +43,6 @@ echo "Topology flags at start of backup vttablet, after explicitly setting: $TOP # shellcheck disable=SC2086 vttablet \ $TOPOLOGY_FLAGS \ - --log_dir $VTDATAROOT/tmp \ --log-queries-to-file $VTDATAROOT/tmp/$tablet_logfile \ --tablet-path $alias \ --tablet-hostname "$tablet_hostname" \ diff --git a/examples/common/backup-scripts/zk-down.sh b/examples/common/backup-scripts/zk-down.sh index f244f2b0f05..1337c60e840 100755 --- a/examples/common/backup-scripts/zk-down.sh +++ b/examples/common/backup-scripts/zk-down.sh @@ -21,6 +21,5 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" # Stop ZooKeeper servers. echo "Stopping zk servers..." for zkid in $zkids; do - zkctl --zk.myid $zkid --zk.cfg $zkcfg --log_dir $VTDATAROOT/tmp shutdown + zkctl --zk.myid $zkid --zk.cfg $zkcfg shutdown done - diff --git a/examples/common/backup-scripts/zk-up.sh b/examples/common/backup-scripts/zk-up.sh index 143a704cbb4..22e7eeae32b 100755 --- a/examples/common/backup-scripts/zk-up.sh +++ b/examples/common/backup-scripts/zk-up.sh @@ -31,7 +31,7 @@ for zkid in $zkids; do echo " $VTDATAROOT/$zkdir" action='start' fi - zkctl --zk.myid $zkid --zk.cfg $zkcfg --log_dir $VTDATAROOT/tmp $action \ + zkctl --zk.myid $zkid --zk.cfg $zkcfg $action \ > $VTDATAROOT/tmp/zkctl_$zkid.out 2>&1 & pids[$zkid]=$! done diff --git a/examples/common/scripts/vtadmin-up.sh b/examples/common/scripts/vtadmin-up.sh index 613ae246cda..02ce222e07a 100755 --- a/examples/common/scripts/vtadmin-up.sh +++ b/examples/common/scripts/vtadmin-up.sh @@ -39,8 +39,6 @@ vtadmin \ --tracer "opentelemetry" \ --grpc-tracing \ --http-tracing \ - --logtostderr \ - --alsologtostderr \ --rbac \ --rbac-config="${script_dir}/../vtadmin/rbac.yaml" \ --cluster "id=${cluster_name},name=${cluster_name},discovery=staticfile,discovery-staticfile-path=${script_dir}/../vtadmin/discovery.json,tablet-fqdn-tmpl=http://{{ .Tablet.Hostname }}:15{{ .Tablet.Alias.Uid }},schema-cache-default-expiration=1m" \ diff --git a/examples/common/scripts/vtorc-up.sh b/examples/common/scripts/vtorc-up.sh index 108a2fbc012..a9993829596 100755 --- a/examples/common/scripts/vtorc-up.sh +++ b/examples/common/scripts/vtorc-up.sh @@ -10,8 +10,6 @@ port=16000 echo "Starting vtorc..." vtorc \ $TOPOLOGY_FLAGS \ - --logtostderr \ - --alsologtostderr \ --config-path="${script_dir}/../vtorc/" \ --config-name="config.yaml" \ --config-type="yml" \ diff --git a/examples/operator/README.md b/examples/operator/README.md index ec2cd24e3f1..de616c2b419 100644 --- a/examples/operator/README.md +++ b/examples/operator/README.md @@ -31,7 +31,7 @@ kubectl apply -f 101_initial_cluster.yaml # VTAdmin's UI will be available at http://localhost:14000/ ./pf.sh & alias mysql="mysql -h 127.0.0.1 -P 15306 -u user" -alias vtctldclient="vtctldclient --server localhost:15999 --alsologtostderr" +alias vtctldclient="vtctldclient --server localhost:15999" vtctldclient ApplySchema --sql="$(cat ../common/create_commerce_schema.sql)" commerce vtctldclient ApplyVSchema --vschema="$(cat ../common/vschema_commerce_initial.json)" commerce diff --git a/examples/operator/pf.sh b/examples/operator/pf.sh index e9e949cbb45..536d4a3e80f 100755 --- a/examples/operator/pf.sh +++ b/examples/operator/pf.sh @@ -8,7 +8,7 @@ kubectl port-forward -n example --address localhost "$(kubectl get service -n ex process_id3=$! sleep 2 echo "You may point your browser to http://localhost:15000, use the following aliases as shortcuts:" -echo 'alias vtctldclient="vtctldclient --server=localhost:15999 --logtostderr"' +echo 'alias vtctldclient="vtctldclient --server=localhost:15999"' echo 'alias mysql="mysql -h 127.0.0.1 -P 15306 -u user"' echo "Hit Ctrl-C to stop the port forwards" wait $process_id1 diff --git a/go.mod b/go.mod index c1352c448b8..d6895a951f4 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,6 @@ require ( github.com/gammazero/deque v1.2.1 github.com/go-sql-driver/mysql v1.10.1 github.com/go-viper/mapstructure/v2 v2.5.0 - github.com/golang/glog v1.2.5 github.com/golang/snappy v1.0.0 github.com/google/go-cmp v0.7.0 github.com/google/go-containerregistry v0.22.1 diff --git a/go.sum b/go.sum index f6ece2bad20..f4407b262df 100644 --- a/go.sum +++ b/go.sum @@ -179,8 +179,6 @@ github.com/goccy/go-json v0.11.2 h1:jdZv93Tt4ioR8yW1CoNsvSxrcZlCXAUU1aZXN7gpXUA= github.com/goccy/go-json v0.11.2/go.mod h1:3NdmfEkZlB7YI5UFw/qdFKq8XN1aiWR0YyRPWZNQltY= github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ= github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c= -github.com/golang/glog v1.2.5 h1:DrW6hGnjIhtvhOIiAKT6Psh/Kd/ldepEa81DKeiRJ5I= -github.com/golang/glog v1.2.5/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= diff --git a/go/cmd/mysqlctl/command/init.go b/go/cmd/mysqlctl/command/init.go index 68e2c020b95..a0f85976a6d 100644 --- a/go/cmd/mysqlctl/command/init.go +++ b/go/cmd/mysqlctl/command/init.go @@ -33,7 +33,6 @@ var Init = &cobra.Command{ Long: "Bootstraps a new `mysqld` instance, initializes its data directory, and starts the instance.\n" + "The MySQL version and flavor will be auto-detected, with a minimal configuration file applied.", Example: `mysqlctl \ - --alsologtostderr \ --tablet-uid 101 \ --mysql-port 12345 \ init`, diff --git a/go/cmd/mysqlctl/command/init_config.go b/go/cmd/mysqlctl/command/init_config.go index 39594f93f14..82fc4ecded6 100644 --- a/go/cmd/mysqlctl/command/init_config.go +++ b/go/cmd/mysqlctl/command/init_config.go @@ -30,7 +30,6 @@ var InitConfig = &cobra.Command{ Long: "Bootstraps the configuration for a new `mysqld` instance and initializes its data directory.\n" + "This command is the same as `init` except the `mysqld` server will not be started.", Example: `mysqlctl \ - --alsologtostderr \ --tablet-uid 101 \ --mysql-port 12345 \ init_config`, diff --git a/go/cmd/mysqlctl/command/reinit_config.go b/go/cmd/mysqlctl/command/reinit_config.go index cf718979adf..ba8a1eedef2 100644 --- a/go/cmd/mysqlctl/command/reinit_config.go +++ b/go/cmd/mysqlctl/command/reinit_config.go @@ -31,7 +31,6 @@ var ReinitConfig = &cobra.Command{ Long: "Regenerate new configuration files for an existing `mysqld` instance (generating new server_id and server_uuid values).\n" + "This could be helpful to revert configuration changes, or to pick up changes made to the bundled config in newer Vitess versions.", Example: `mysqlctl \ - --alsologtostderr \ --tablet-uid 101 \ --mysql-port 12345 \ reinit_config`, diff --git a/go/cmd/mysqlctl/command/root.go b/go/cmd/mysqlctl/command/root.go index c8ea8620456..c8ca2aba300 100644 --- a/go/cmd/mysqlctl/command/root.go +++ b/go/cmd/mysqlctl/command/root.go @@ -25,7 +25,6 @@ import ( vtcmd "vitess.io/vitess/go/cmd" "vitess.io/vitess/go/mysql/collations" "vitess.io/vitess/go/vt/dbconfigs" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/utils" ) @@ -54,9 +53,6 @@ var ( return nil }, - PersistentPostRun: func(cmd *cobra.Command, args []string) { - logutil.Flush() - }, Version: servenv.AppVersion.String(), } ) diff --git a/go/cmd/mysqlctl/command/shutdown.go b/go/cmd/mysqlctl/command/shutdown.go index d7ae395c935..0518b33a51e 100644 --- a/go/cmd/mysqlctl/command/shutdown.go +++ b/go/cmd/mysqlctl/command/shutdown.go @@ -32,7 +32,7 @@ var Shutdown = &cobra.Command{ 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.", - Example: `mysqlctl --tablet-uid 101 --alsologtostderr shutdown`, + Example: `mysqlctl --tablet-uid 101 shutdown`, Args: cobra.NoArgs, RunE: commandShutdown, } diff --git a/go/cmd/mysqlctl/command/start.go b/go/cmd/mysqlctl/command/start.go index 8adeb185a35..23f432e3e6a 100644 --- a/go/cmd/mysqlctl/command/start.go +++ b/go/cmd/mysqlctl/command/start.go @@ -32,7 +32,7 @@ var Start = &cobra.Command{ Use: "start", Short: "Starts mysqld on an already 'init'-ed directory.", Long: "Resume an existing `mysqld` instance that was previously bootstrapped with `init` or `init_config`", - Example: `mysqlctl --tablet-uid 101 --alsologtostderr start`, + Example: `mysqlctl --tablet-uid 101 start`, Args: cobra.NoArgs, RunE: commandStart, } diff --git a/go/cmd/mysqlctl/command/teardown.go b/go/cmd/mysqlctl/command/teardown.go index 9f522b28b07..464f932fdf6 100644 --- a/go/cmd/mysqlctl/command/teardown.go +++ b/go/cmd/mysqlctl/command/teardown.go @@ -34,7 +34,7 @@ var Teardown = &cobra.Command{ "This is a destructive operation.\n" + "{{}}\n\n" + "Shuts down a `mysqld` instance and removes its data directory.", - Example: `mysqlctl --tablet-uid 101 --alsologtostderr teardown`, + Example: `mysqlctl --tablet-uid 101 teardown`, Args: cobra.NoArgs, RunE: commandTeardown, } diff --git a/go/cmd/mysqlctld/cli/mysqlctld.go b/go/cmd/mysqlctld/cli/mysqlctld.go index e3fb0b7fb87..a1b1fa32b70 100644 --- a/go/cmd/mysqlctld/cli/mysqlctld.go +++ b/go/cmd/mysqlctld/cli/mysqlctld.go @@ -31,7 +31,6 @@ import ( "vitess.io/vitess/go/mysql/collations" "vitess.io/vitess/go/vt/dbconfigs" "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/mysqlctl" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/utils" @@ -63,7 +62,6 @@ var ( "{{}}\n\n" + "To enable communication with a `vttablet`, the server must be configured to receive gRPC messages on a unix domain socket.", Example: `mysqlctld \ - --log_dir=${VTDATAROOT}/logs \ --tablet-uid=100 \ --mysql-port=17100 \ --socket-file=/path/to/socket-file`, @@ -105,8 +103,6 @@ func init() { } func run(cmd *cobra.Command, args []string) error { - defer logutil.Flush() - // We'll register this OnTerm handler before mysqld starts, so we get notified // if mysqld dies on its own without us (or our RPC client) telling it to. mysqldTerminated := make(chan struct{}) diff --git a/go/cmd/rulesctl/cmd/main.go b/go/cmd/rulesctl/cmd/main.go index dbb5eb988df..6c4a4b34257 100644 --- a/go/cmd/rulesctl/cmd/main.go +++ b/go/cmd/rulesctl/cmd/main.go @@ -19,9 +19,7 @@ package cmd import ( "github.com/spf13/cobra" - _flag "vitess.io/vitess/go/internal/flag" "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/logutil" ) var configFile string @@ -31,14 +29,10 @@ func Main() *cobra.Command { Use: "rulesctl", Args: cobra.NoArgs, PreRunE: func(cmd *cobra.Command, args []string) error { - _flag.TrickGlog() - - if err := log.Init(cmd.Flags()); err != nil { + if err := log.Init(); err != nil { return err } - logutil.PurgeLogs() - return nil }, Run: func(cmd *cobra.Command, _ []string) { cmd.Help() }, diff --git a/go/cmd/rulesctl/main.go b/go/cmd/rulesctl/main.go index 0b9f0c414be..eb799d8b659 100644 --- a/go/cmd/rulesctl/main.go +++ b/go/cmd/rulesctl/main.go @@ -22,7 +22,6 @@ import ( "vitess.io/vitess/go/acl" "vitess.io/vitess/go/cmd/rulesctl/cmd" vtlog "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/utils" ) @@ -31,7 +30,6 @@ func main() { rootCmd := cmd.Main() rootCmd.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes) vtlog.RegisterFlags(rootCmd.PersistentFlags()) - logutil.RegisterFlags(rootCmd.PersistentFlags()) acl.RegisterFlags(rootCmd.PersistentFlags()) servenv.RegisterMySQLServerFlags(rootCmd.PersistentFlags()) if err := rootCmd.Execute(); err != nil { diff --git a/go/cmd/topo2topo/cli/topo2topo.go b/go/cmd/topo2topo/cli/topo2topo.go index 7f35041a7d6..9a67cb12e3b 100644 --- a/go/cmd/topo2topo/cli/topo2topo.go +++ b/go/cmd/topo2topo/cli/topo2topo.go @@ -24,7 +24,6 @@ import ( "vitess.io/vitess/go/acl" "vitess.io/vitess/go/vt/grpccommon" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/sqlparser" "vitess.io/vitess/go/vt/topo" @@ -79,7 +78,6 @@ func init() { } func run(cmd *cobra.Command, args []string) error { - defer logutil.Flush() servenv.Init() fromTS, err := topo.OpenServer(fromImplementation, fromServerAddress, fromRoot) diff --git a/go/cmd/vtaclcheck/cli/vtactlcheck.go b/go/cmd/vtaclcheck/cli/vtactlcheck.go index 36aceb55585..ee7e4f71a2a 100644 --- a/go/cmd/vtaclcheck/cli/vtactlcheck.go +++ b/go/cmd/vtaclcheck/cli/vtactlcheck.go @@ -20,7 +20,6 @@ import ( "github.com/spf13/cobra" "vitess.io/vitess/go/acl" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/utils" "vitess.io/vitess/go/vt/vtaclcheck" @@ -36,10 +35,7 @@ var ( Args: cobra.NoArgs, Version: servenv.AppVersion.String(), PreRunE: servenv.CobraPreRunE, - PostRun: func(cmd *cobra.Command, args []string) { - logutil.Flush() - }, - RunE: run, + RunE: run, } ) diff --git a/go/cmd/vtadmin/main.go b/go/cmd/vtadmin/main.go index cd6516ab8f8..8ea28a233d3 100644 --- a/go/cmd/vtadmin/main.go +++ b/go/cmd/vtadmin/main.go @@ -17,7 +17,6 @@ limitations under the License. package main import ( - "flag" "fmt" "io" "os" @@ -25,10 +24,8 @@ import ( "github.com/spf13/cobra" - _flag "vitess.io/vitess/go/internal/flag" "vitess.io/vitess/go/trace" "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/utils" "vitess.io/vitess/go/vt/vtadmin" @@ -61,14 +58,10 @@ var ( rootCmd = &cobra.Command{ Use: "vtadmin", PreRunE: func(cmd *cobra.Command, args []string) error { - _flag.TrickGlog() - - if err := log.Init(cmd.Flags()); err != nil { + if err := log.Init(); err != nil { return err } - logutil.PurgeLogs() - if opts.EnableTracing || httpOpts.EnableTracing { startTracing(cmd) } @@ -220,23 +213,8 @@ func registerFlags() { "Note: any whitespace characters are replaced with hyphens." rootCmd.Flags().StringVar(&cacheRefreshKey, "cache-refresh-key", "vt-cache-refresh", cacheRefreshHelp) - // Structured logging flags. log.RegisterFlags(rootCmd.Flags()) - // glog flags, no better way to do this - rootCmd.Flags().AddGoFlag(flag.Lookup("v")) - rootCmd.Flags().AddGoFlag(flag.Lookup("logtostderr")) - rootCmd.Flags().AddGoFlag(flag.Lookup("alsologtostderr")) - rootCmd.Flags().AddGoFlag(flag.Lookup("stderrthreshold")) - rootCmd.Flags().AddGoFlag(flag.Lookup("log_dir")) - - const deprecationMsg = "glog and its flags have been deprecated, use the default structured logging instead (\"--log-structured\")" - rootCmd.Flags().MarkDeprecated("v", deprecationMsg) - rootCmd.Flags().MarkDeprecated("logtostderr", deprecationMsg) - rootCmd.Flags().MarkDeprecated("alsologtostderr", deprecationMsg) - rootCmd.Flags().MarkDeprecated("stderrthreshold", deprecationMsg) - rootCmd.Flags().MarkDeprecated("log_dir", deprecationMsg) - servenv.RegisterMySQLServerFlags(rootCmd.Flags()) // Register TLS flags for gRPC connections to vtctld diff --git a/go/cmd/vtbackup/cli/vtbackup.go b/go/cmd/vtbackup/cli/vtbackup.go index 043cfac528b..48dd0a355e7 100644 --- a/go/cmd/vtbackup/cli/vtbackup.go +++ b/go/cmd/vtbackup/cli/vtbackup.go @@ -271,8 +271,6 @@ func run(cc *cobra.Command, args []string) error { cmd.DetachFromTerminalAndExit() } - defer logutil.Flush() - if minRetentionCount < 1 { log.Error("min_retention_count must be at least 1 to allow restores to succeed") exit.Return(1) diff --git a/go/cmd/vtbench/cli/vtbench.go b/go/cmd/vtbench/cli/vtbench.go index b9380801014..b8f142190fe 100644 --- a/go/cmd/vtbench/cli/vtbench.go +++ b/go/cmd/vtbench/cli/vtbench.go @@ -166,7 +166,6 @@ func run(cmd *cobra.Command, args []string) error { writer := logutil.NewLoggerWriter(logger) cmd.SetOut(writer) cmd.SetErr(writer) - _ = cmd.Flags().Set("logtostderr", "true") servenv.Init() diff --git a/go/cmd/vtclient/cli/vtclient.go b/go/cmd/vtclient/cli/vtclient.go index 05eabaa95f9..fa5155c5405 100644 --- a/go/cmd/vtclient/cli/vtclient.go +++ b/go/cmd/vtclient/cli/vtclient.go @@ -37,7 +37,6 @@ import ( "vitess.io/vitess/go/vt/concurrency" "vitess.io/vitess/go/vt/grpccommon" "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/sqlparser" "vitess.io/vitess/go/vt/utils" @@ -151,8 +150,6 @@ func newBindvars(fs *pflag.FlagSet, name, usage string) *bindvars { } func run(cmd *cobra.Command, args []string) error { - defer logutil.Flush() - qr, err := _run(cmd, args) if jsonOutput && qr != nil { data, err := json.MarshalIndent(qr, "", " ") @@ -168,8 +165,6 @@ func run(cmd *cobra.Command, args []string) error { } func _run(cmd *cobra.Command, args []string) (*results, error) { - logutil.PurgeLogs() - if maxSeqID > minSeqID { go func() { if useRandom { diff --git a/go/cmd/vtcombo/cli/main.go b/go/cmd/vtcombo/cli/main.go index 43e1f8a7bad..2844ae8cfc7 100644 --- a/go/cmd/vtcombo/cli/main.go +++ b/go/cmd/vtcombo/cli/main.go @@ -177,10 +177,6 @@ func run(cmd *cobra.Command, args []string) (err error) { cmd.Flags().Set("cells-to-watch", strings.Join(tpb.Cells, ",")) - if f := cmd.Flags().Lookup("log_dir"); f != nil && !f.Changed { - cmd.Flags().Set("log_dir", "$VTDATAROOT/tmp") - } - env, err = vtenv.New(vtenv.Options{ MySQLServerVersion: servenv.MySQLServerVersion(), TruncateUILen: servenv.TruncateUILen, diff --git a/go/cmd/vtctl/vtctl.go b/go/cmd/vtctl/vtctl.go index 5f238170eaf..6b48297e46e 100644 --- a/go/cmd/vtctl/vtctl.go +++ b/go/cmd/vtctl/vtctl.go @@ -109,7 +109,6 @@ func installSignalHandlers(cancel func()) { func main() { defer exit.RecoverAll() - defer logutil.Flush() if detachedMode { // this method will call os.Exit and kill this process diff --git a/go/cmd/vtctlclient/main.go b/go/cmd/vtctlclient/main.go index 35c612908be..130e5b971e2 100644 --- a/go/cmd/vtctlclient/main.go +++ b/go/cmd/vtctlclient/main.go @@ -52,6 +52,7 @@ func init() { fs.StringVar(&server, "server", server, "server to use for connection") acl.RegisterFlags(fs) + log.RegisterRemovedClientFlags(fs) fs.SetNormalizeFunc(utils.NormalizeUnderscoresToDashes) }) diff --git a/go/cmd/vtctldclient/command/root.go b/go/cmd/vtctldclient/command/root.go index 34bc1b3107e..a2931361813 100644 --- a/go/cmd/vtctldclient/command/root.go +++ b/go/cmd/vtctldclient/command/root.go @@ -30,7 +30,6 @@ import ( "vitess.io/vitess/go/trace" "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/topo" "vitess.io/vitess/go/vt/utils" @@ -106,7 +105,7 @@ connect directly to the topo server(s).`, useInternalVtctld), // We use PersistentPreRun to set up the tracer, grpc client, and // command context for every command. PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) { - if err := log.Init(cmd.Flags()); err != nil { + if err := log.Init(); err != nil { return err } @@ -119,7 +118,6 @@ connect directly to the topo server(s).`, useInternalVtctld), return fmt.Errorf("failed to initialize vtenv: %w", err) } - logutil.PurgeLogs() traceCloser = trace.StartTracing("vtctldclient") client, err = getClientForCommand(cmd) ctx := cmd.Context() diff --git a/go/cmd/vtctldclient/main.go b/go/cmd/vtctldclient/main.go index 493dd1798d3..ce8b18b9fd4 100644 --- a/go/cmd/vtctldclient/main.go +++ b/go/cmd/vtctldclient/main.go @@ -17,7 +17,6 @@ limitations under the License. package main import ( - "flag" "fmt" "vitess.io/vitess/go/acl" @@ -26,25 +25,20 @@ import ( "vitess.io/vitess/go/vt/grpcclient" "vitess.io/vitess/go/vt/grpccommon" "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/vtctl/grpcclientcommon" "vitess.io/vitess/go/vt/vtctl/vtctlclient" "vitess.io/vitess/go/vt/vttablet/grpctmclient" "vitess.io/vitess/go/vt/vttablet/tmclient" - _flag "vitess.io/vitess/go/internal/flag" flagUtils "vitess.io/vitess/go/vt/utils" ) func main() { defer exit.Recover() - // Grab all those global flags across the codebase and shove 'em on in. - // (TODO|andrew) remove this line after the migration to pflag is complete. - command.Root.PersistentFlags().AddGoFlagSet(flag.CommandLine) log.RegisterFlags(command.Root.PersistentFlags()) - logutil.RegisterFlags(command.Root.PersistentFlags()) + log.RegisterRemovedClientFlags(command.Root.PersistentFlags()) grpcclient.RegisterFlags(command.Root.PersistentFlags()) grpccommon.RegisterFlags(command.Root.PersistentFlags()) grpcclientcommon.RegisterFlags(command.Root.PersistentFlags()) @@ -54,11 +48,7 @@ func main() { vtctlclient.RegisterFlags(command.Root.PersistentFlags()) acl.RegisterFlags(command.Root.PersistentFlags()) - // hack to get rid of an "ERROR: logging before flag.Parse" - _flag.TrickGlog() - command.Root.SetGlobalNormalizationFunc(flagUtils.NormalizeUnderscoresToDashes) - // back to your regularly scheduled cobra programming if err := command.Root.Execute(); err != nil { log.Error(fmt.Sprint(err)) exit.Return(1) diff --git a/go/cmd/vtexplain/cli/vtexplain.go b/go/cmd/vtexplain/cli/vtexplain.go index 824b0c31f84..89ac17ba943 100644 --- a/go/cmd/vtexplain/cli/vtexplain.go +++ b/go/cmd/vtexplain/cli/vtexplain.go @@ -23,7 +23,6 @@ import ( "vitess.io/vitess/go/acl" "vitess.io/vitess/go/stats" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/topo/memorytopo" "vitess.io/vitess/go/vt/vtenv" @@ -136,8 +135,6 @@ func getFileParam(flag, flagFile, name string, required bool) (string, error) { } func run(cmd *cobra.Command, args []string) error { - defer logutil.Flush() - servenv.Init() return parseAndRun(cmd.Context()) } diff --git a/go/cmd/vtgate/cli/cli.go b/go/cmd/vtgate/cli/cli.go index bf921c96295..37a434dcd0b 100644 --- a/go/cmd/vtgate/cli/cli.go +++ b/go/cmd/vtgate/cli/cli.go @@ -62,7 +62,6 @@ var ( --topo-implementation etcd2 \ --topo-global-server-address localhost:2379 \ --topo-global-root /vitess/global \ - --log_dir $VTDATAROOT/tmp \ --port 15001 \ --grpc-port 15991 \ --mysql-server-port 15306 \ diff --git a/go/cmd/vtorc/cli/cli.go b/go/cmd/vtorc/cli/cli.go index 7e65121c155..7b7591ff81d 100644 --- a/go/cmd/vtorc/cli/cli.go +++ b/go/cmd/vtorc/cli/cli.go @@ -39,11 +39,9 @@ var Main = &cobra.Command{ --topo-implementation etcd2 \ --topo-global-server-address localhost:2379 \ --topo-global-root /vitess/global \ - --log_dir $VTDATAROOT/tmp \ --port 15000 \ --instance-poll-time "1s" \ - --topo-information-refresh-duration "30s" \ - --alsologtostderr`, + --topo-information-refresh-duration "30s"`, Args: cobra.NoArgs, Version: servenv.AppVersion.String(), PreRunE: servenv.CobraPreRunE, diff --git a/go/cmd/vttestserver/cli/main_test.go b/go/cmd/vttestserver/cli/main_test.go index e5cd893c68d..2909ae1ee7e 100644 --- a/go/cmd/vttestserver/cli/main_test.go +++ b/go/cmd/vttestserver/cli/main_test.go @@ -247,7 +247,7 @@ func TestCanGetKeyspaces(t *testing.T) { defer func() { if t.Failed() { - cluster.PrintFiles(t, clusterInstance.Env.Directory(), "vtcombo.INFO", "error.log") + cluster.PrintFiles(t, clusterInstance.Env.Directory(), "error.log") } }() diff --git a/go/cmd/vttlstest/vttlstest.go b/go/cmd/vttlstest/vttlstest.go index 7360c287569..6593fcd912d 100644 --- a/go/cmd/vttlstest/vttlstest.go +++ b/go/cmd/vttlstest/vttlstest.go @@ -21,13 +21,11 @@ import ( "vitess.io/vitess/go/cmd/vttlstest/cli" "vitess.io/vitess/go/exit" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/utils" ) func main() { defer exit.Recover() - defer logutil.Flush() cli.Root.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes) cobra.CheckErr(cli.Root.Execute()) diff --git a/go/cmd/zk/command/root.go b/go/cmd/zk/command/root.go index d1a0bee4144..16c248710f5 100644 --- a/go/cmd/zk/command/root.go +++ b/go/cmd/zk/command/root.go @@ -22,7 +22,6 @@ import ( "vitess.io/vitess/go/acl" "vitess.io/vitess/go/cmd/zk/internal/zkfs" "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/topo/zk2topo" ) @@ -44,12 +43,10 @@ or the file specified in the ZK_CLIENT_CONFIG environment variable. The local cell may be overridden with the ZK_CLIENT_LOCAL_CELL environment variable.`, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - if err := log.Init(cmd.Flags()); err != nil { + if err := log.Init(); err != nil { return err } - logutil.PurgeLogs() - // Connect to the server. fs = &zkfs.FS{ Conn: zk2topo.Connect(server), @@ -57,9 +54,6 @@ variable.`, return nil }, - PersistentPostRun: func(cmd *cobra.Command, args []string) { - logutil.Flush() - }, } ) @@ -67,6 +61,5 @@ func init() { Root.Flags().StringVar(&server, "server", server, "server(s) to connect to") log.RegisterFlags(Root.Flags()) - logutil.RegisterFlags(Root.Flags()) acl.RegisterFlags(Root.Flags()) } diff --git a/go/cmd/zkctl/command/root.go b/go/cmd/zkctl/command/root.go index 3399ed8c4cb..e7a3b3653bd 100644 --- a/go/cmd/zkctl/command/root.go +++ b/go/cmd/zkctl/command/root.go @@ -19,7 +19,6 @@ package command import ( "github.com/spf13/cobra" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/zkctl" ) @@ -45,9 +44,6 @@ var ( return nil }, - PersistentPostRun: func(cmd *cobra.Command, args []string) { - logutil.Flush() - }, } ) diff --git a/go/cmd/zkctld/cli/zkctld.go b/go/cmd/zkctld/cli/zkctld.go index 3865c8a240a..5156aa6d367 100644 --- a/go/cmd/zkctld/cli/zkctld.go +++ b/go/cmd/zkctld/cli/zkctld.go @@ -27,7 +27,6 @@ import ( "vitess.io/vitess/go/acl" "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/zkctl" ) @@ -43,10 +42,7 @@ var ( Args: cobra.NoArgs, Version: servenv.AppVersion.String(), PersistentPreRunE: servenv.CobraPreRunE, - PostRun: func(cmd *cobra.Command, args []string) { - logutil.Flush() - }, - RunE: run, + RunE: run, } ) diff --git a/go/event/syslogger/syslogger.go b/go/event/syslogger/syslogger.go index 1d2b86a1fb8..32dc609c5f9 100644 --- a/go/event/syslogger/syslogger.go +++ b/go/event/syslogger/syslogger.go @@ -147,12 +147,8 @@ func listener(ev Syslogger) { } func init() { - // We only want to init syslog when the app is being initialized - // Some binaries import the syslog package indirectly leading to - // the syslog.New function being called and this might fail if - // running inside Docker without the syslog daemon enabled, leading - // logging the error which will make glog think there are not --log_dir - // flag set as we have not parsed the flags yet. + // Connect to syslog when servenv initializes. The connection fails when no syslog daemon runs, for example in + // Docker. An error logged before servenv initializes ignores the logging flags. // https://github.com/vitessio/vitess/issues/15120 servenv.OnInit(func() { initSyslog() diff --git a/go/flags/endtoend/MIGRATION_CHECKLIST.md b/go/flags/endtoend/MIGRATION_CHECKLIST.md index b915bf45812..8fde6090ed5 100644 --- a/go/flags/endtoend/MIGRATION_CHECKLIST.md +++ b/go/flags/endtoend/MIGRATION_CHECKLIST.md @@ -73,7 +73,6 @@ - [ ] PR created and reviewed ## Notes -- Glog flags (log_dir, log_backtrace_at) come from Go standard library - may not need migration - Some tests use `GetFlagVariantForTestsByVersion` - DO NOT modify these - Utils functions automatically handle deprecation and hiding - no manual work needed - Utils functions work with both pflag.FlagSet and cobra's Flags()/PersistentFlags() @@ -85,4 +84,4 @@ fs.StringVar(&variable, "flag_with_underscore", defaultValue, "description") // After: utils.SetFlagStringVar(fs, &variable, "flag-with-dashes", defaultValue, "description") -``` \ No newline at end of file +``` diff --git a/go/flags/endtoend/find_flag_definitions.py b/go/flags/endtoend/find_flag_definitions.py index 9c0f186ff53..965a3bde47e 100644 --- a/go/flags/endtoend/find_flag_definitions.py +++ b/go/flags/endtoend/find_flag_definitions.py @@ -25,7 +25,6 @@ def find_flag_definitions(): # Group flags by category flag_groups = { - 'logging': [], 'backup_restore': [], 'stats_monitoring': [], 'database': [], @@ -42,11 +41,6 @@ def find_flag_definitions(): # Search for each flag definition for flag in underscore_flags: - # Skip glog flags (they come from standard library) - if flag.startswith('log_'): - flag_groups['logging'].append(flag) - continue - # Try to find the definition cmd = f'grep -r "\\"{flag}\\"" {vtroot}/go --include="*.go" -n | head -5' try: @@ -99,7 +93,6 @@ def print_migration_plan(): # Priority order for groups priority_order = [ - ('logging', 'Logging flags (glog - may not need migration)'), ('timeout', 'Timeout and deadline flags'), ('backup_restore', 'Backup and restore flags'), ('database', 'Database connection flags'), @@ -158,7 +151,6 @@ def print_migration_plan(): print("1. Start with timeout flags (small group, high impact)") print("2. Then backup_restore flags (medium group, isolated)") print("3. Continue with other groups in order") - print("4. Skip logging flags if they're from glog") if __name__ == "__main__": - print_migration_plan() \ No newline at end of file + print_migration_plan() diff --git a/go/flags/endtoend/flags_analysis.json b/go/flags/endtoend/flags_analysis.json deleted file mode 100644 index 50523d0051b..00000000000 --- a/go/flags/endtoend/flags_analysis.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "binary_stats": { - "vtbackup": { - "total_flags": 208, - "underscore_flags": 2, - "dash_flags": 197, - "completion_percentage": 94.7 - }, - "vtctld": { - "total_flags": 158, - "underscore_flags": 2, - "dash_flags": 147, - "completion_percentage": 93.0 - }, - "vtctldclient": { - "total_flags": 43, - "underscore_flags": 3, - "dash_flags": 32, - "completion_percentage": 74.4 - }, - "mysqlctl": { - "total_flags": 73, - "underscore_flags": 2, - "dash_flags": 65, - "completion_percentage": 89.0 - }, - "vtgate": { - "total_flags": 225, - "underscore_flags": 2, - "dash_flags": 214, - "completion_percentage": 95.1 - }, - "vtcombo": { - "total_flags": 437, - "underscore_flags": 2, - "dash_flags": 425, - "completion_percentage": 97.3 - }, - "vtorc": { - "total_flags": 97, - "underscore_flags": 2, - "dash_flags": 88, - "completion_percentage": 90.7 - }, - "vtclient": { - "total_flags": 57, - "underscore_flags": 2, - "dash_flags": 40, - "completion_percentage": 70.2 - }, - "vtbench": { - "total_flags": 54, - "underscore_flags": 2, - "dash_flags": 37, - "completion_percentage": 68.5 - }, - "vttestserver": { - "total_flags": 168, - "underscore_flags": 2, - "dash_flags": 156, - "completion_percentage": 92.9 - }, - "vttablet": { - "total_flags": 393, - "underscore_flags": 2, - "dash_flags": 381, - "completion_percentage": 96.9 - }, - "mysqlctld": { - "total_flags": 104, - "underscore_flags": 2, - "dash_flags": 95, - "completion_percentage": 91.3 - } - }, - "unique_underscore_flags": [ - "log_backtrace_at", - "log_link", - "log_dir" - ], - "flag_to_binaries": { - "log_backtrace_at": [ - "mysqlctl", - "vtgate", - "vtbench", - "vtorc", - "vtctldclient", - "vtctld", - "vtclient", - "vtbackup", - "vttestserver", - "vttablet", - "mysqlctld", - "vtcombo" - ], - "log_dir": [ - "mysqlctl", - "vtgate", - "vtbench", - "vtorc", - "vtctldclient", - "vtctld", - "vtclient", - "vtbackup", - "vttestserver", - "vttablet", - "mysqlctld", - "vtcombo" - ], - "log_link": [ - "vtctldclient" - ] - } -} \ No newline at end of file diff --git a/go/flags/endtoend/migration_plan.json b/go/flags/endtoend/migration_plan.json deleted file mode 100644 index 7170f0e12b6..00000000000 --- a/go/flags/endtoend/migration_plan.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "groups": { - "logging": [ - "log_backtrace_at", - "log_link", - "log_dir" - ] - }, - "definitions": {}, - "priority_order": [ - "logging", - "timeout", - "backup_restore", - "database", - "ddl", - "buffer", - "stats_monitoring", - "topo", - "grpc", - "test", - "other" - ], - "total_flags": 3 -} \ No newline at end of file diff --git a/go/flags/endtoend/mysqlctl.txt b/go/flags/endtoend/mysqlctl.txt index 634a0d53c20..47a7977886c 100644 --- a/go/flags/endtoend/mysqlctl.txt +++ b/go/flags/endtoend/mysqlctl.txt @@ -60,14 +60,10 @@ Flags: --dba-idle-timeout duration Idle timeout for dba connections (default 1m0s) --dba-pool-size int Size of the connection pool for dba connections (default 20) -h, --help help for mysqlctl - --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) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) + --log-level string minimum log level (debug, info, warn, error) (default "info") --max-stack-size int configure the maximum stack size in bytes (default 67108864) --mysql-port int MySQL port. (default 3306) --mysql-server-version string MySQL server version to advertise. (default "8.4.6-Vitess") @@ -81,7 +77,6 @@ Flags: --pool-hostname-resolve-interval duration if set force an update to all hostnames and reconnect if changed, defaults to 0 (disabled) --pprof strings enable profiling --pprof-http enable pprof http endpoints - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --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 diff --git a/go/flags/endtoend/mysqlctld.txt b/go/flags/endtoend/mysqlctld.txt index 803ce3a0739..441feed58a9 100644 --- a/go/flags/endtoend/mysqlctld.txt +++ b/go/flags/endtoend/mysqlctld.txt @@ -13,7 +13,6 @@ Usage: Examples: mysqlctld \ - --log_dir=${VTDATAROOT}/logs \ --tablet-uid=100 \ --mysql-port=17100 \ --socket-file=/path/to/socket-file @@ -89,14 +88,10 @@ Flags: --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 - --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) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) + --log-level string minimum log level (debug, info, warn, error) (default "info") --max-stack-size int configure the maximum stack size in bytes (default 67108864) --mysql-port int MySQL port (default 3306) --mysql-server-version string MySQL server version to advertise. (default "8.4.6-Vitess") @@ -110,7 +105,6 @@ Flags: --port int port for the server --pprof strings enable profiling --pprof-http enable pprof http endpoints - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --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 diff --git a/go/flags/endtoend/topo2topo.txt b/go/flags/endtoend/topo2topo.txt index f8c4fa52da2..fe0cbde48bc 100644 --- a/go/flags/endtoend/topo2topo.txt +++ b/go/flags/endtoend/topo2topo.txt @@ -24,16 +24,11 @@ Flags: --grpc-max-message-size int Maximum allowed RPC message size. Larger messages will be rejected by gRPC with the error 'exceeding the max size'. (default 16777216) --grpc-prometheus Enable gRPC monitoring with Prometheus. -h, --help help for topo2topo - --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) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) + --log-level string minimum log level (debug, info, warn, error) (default "info") --pprof strings enable profiling --pprof-http enable pprof http endpoints - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --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) --to-implementation string topology implementation to copy data to --to-root string topology server root to copy data to diff --git a/go/flags/endtoend/vtaclcheck.txt b/go/flags/endtoend/vtaclcheck.txt index e16144f0e0f..a870a578a92 100644 --- a/go/flags/endtoend/vtaclcheck.txt +++ b/go/flags/endtoend/vtaclcheck.txt @@ -12,16 +12,11 @@ Flags: --config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s) --config-type string Config file type (omit to infer config type from file extension). -h, --help help for vtaclcheck - --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) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) + --log-level string minimum log level (debug, info, warn, error) (default "info") --pprof strings enable profiling --pprof-http enable pprof http endpoints - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --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) --static-auth-file string The path of the auth_server_static JSON file to check -v, --version print binary version diff --git a/go/flags/endtoend/vtbackup.txt b/go/flags/endtoend/vtbackup.txt index 1e4430dbab8..bc34e781b28 100644 --- a/go/flags/endtoend/vtbackup.txt +++ b/go/flags/endtoend/vtbackup.txt @@ -164,14 +164,10 @@ Flags: --init-shard string (init parameter) shard to use for this tablet --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) --lock-timeout duration Maximum time to wait when attempting to acquire a lock from the topo server (default 45s) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) + --log-level string minimum log level (debug, info, warn, error) (default "info") --manifest-external-decompressor string command with arguments to store in the backup manifest when compressing a backup with an external compression engine. --min-backup-interval duration Only take a new backup if it's been at least this long since the most recent backup. --min-retention-count int 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 (default 1) @@ -211,7 +207,6 @@ Flags: --port int port for the server --pprof strings enable profiling --pprof-http enable pprof http endpoints - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --remote-operation-timeout duration time to wait for a remote operation (default 15s) --restart-before-backup Perform a mysqld clean/full restart after applying binlogs, but before taking the backup. Only makes sense to work around xtrabackup bugs. --restore-with-clone (init parameter) will perform the restore phase with MySQL CLONE, requires either --clone-from-primary or --clone-from-tablet diff --git a/go/flags/endtoend/vtbench.txt b/go/flags/endtoend/vtbench.txt index f1449e468e1..0c91332db5c 100644 --- a/go/flags/endtoend/vtbench.txt +++ b/go/flags/endtoend/vtbench.txt @@ -41,7 +41,6 @@ vtbench \ --count 10 Flags: - --alsologtostderr log to standard error as well as files --config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored. --config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn) --config-name string Name of the config file (without extension) to search for. (default "vtconfig") @@ -74,24 +73,16 @@ Flags: --grpc-prometheus Enable gRPC monitoring with Prometheus. -h, --help help for vtbench --host string VTGate host(s) in the form 'host1,host2,...' - --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) --log-err-stacks log stack traces for errors - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log_backtrace_at traceLocations when logging hits line file:N, emit a stack trace - --log_dir string If non-empty, write log files in this directory - --logtostderr log to standard error instead of files --mysql-server-version string MySQL server version to advertise. (default "8.4.6-Vitess") --port int VTGate port --pprof strings enable profiling --pprof-http enable pprof http endpoints --protocol string Client protocol, either mysql (default), grpc-vtgate, or grpc-vttablet (default "mysql") - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --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) --sql string SQL statement to execute --sql-max-length-errors int truncate queries in error logs to the given length (default unlimited) --sql-max-length-ui int truncate queries in debug UIs to the given length (default 512) (default 512) - --stderrthreshold severityFlag logs at or above this threshold go to stderr (default 1) --tablet-grpc-ca string the server ca to use to validate servers when connecting --tablet-grpc-cert string the cert to use to connect --tablet-grpc-crl string the server crl to use to validate server certificates when connecting @@ -100,9 +91,7 @@ Flags: --threads int Number of parallel threads to run (default 2) --unix-socket string VTGate unix socket --user string Username to connect using mysql (password comes from the db-credentials-file) - --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 --vtgate-grpc-ca string the server ca to use to validate servers when connecting --vtgate-grpc-cert string the cert to use to connect --vtgate-grpc-crl string the server crl to use to validate server certificates when connecting diff --git a/go/flags/endtoend/vtclient.txt b/go/flags/endtoend/vtclient.txt index a611dc66874..2dbcf0c675b 100644 --- a/go/flags/endtoend/vtclient.txt +++ b/go/flags/endtoend/vtclient.txt @@ -12,7 +12,6 @@ vtclient --server vtgate:15991 "SELECT * FROM messages" vtclient --server vtgate:15991 --target '@primary' --bind_variables '[ 12345, 1, "msg 12345" ]' "INSERT INTO messages (page,time_created_ns,message) VALUES (:v1, :v2, :v3)" Flags: - --alsologtostderr log to standard error as well as files --bind-variables float bind variables as a json list (default null) --config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored. --config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn) @@ -33,13 +32,7 @@ Flags: --grpc-prometheus Enable gRPC monitoring with Prometheus. -h, --help help for vtclient --json Output JSON instead of human-readable table - --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) --log-err-stacks log stack traces for errors - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log_backtrace_at traceLocations when logging hits line file:N, emit a stack trace - --log_dir string If non-empty, write log files in this directory - --logtostderr log to standard error instead of files --max-sequence-id int max sequence ID. --min-sequence-id int min sequence ID to generate. When max-sequence-id > min-sequence-id, for each query, a number is generated in [min-sequence-id, max-sequence-id) and attached to the end of the bind variables. --mysql-server-version string MySQL server version to advertise. (default "8.4.6-Vitess") @@ -48,11 +41,9 @@ Flags: --parallel int DMLs only: Number of threads executing the same query in parallel. Useful for simple load testing. (default 1) --pprof strings enable profiling --pprof-http enable pprof http endpoints - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --qps int queries per second to throttle each thread at. --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) --server string vtgate server to connect to - --stderrthreshold severityFlag logs at or above this threshold go to stderr (default 1) --streaming use a streaming query --target string keyspace:shard@tablet_type --timeout duration timeout for queries (default 30s) @@ -60,9 +51,7 @@ Flags: --tracing-enable-logging whether to enable logging in the tracing service --tracing-sampling-rate float sampling rate for traces as a probability between 0.0 and 1.0 (default 0.1) --use-random-sequence use random sequence for generating [min-sequence-id, max-sequence-id) - --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 --vtgate-grpc-ca string the server ca to use to validate servers when connecting --vtgate-grpc-cert string the cert to use to connect --vtgate-grpc-crl string the server crl to use to validate server certificates when connecting diff --git a/go/flags/endtoend/vtcombo.txt b/go/flags/endtoend/vtcombo.txt index e687efde00c..15126d8af86 100644 --- a/go/flags/endtoend/vtcombo.txt +++ b/go/flags/endtoend/vtcombo.txt @@ -188,8 +188,6 @@ Flags: --init-tags StringMap (init parameter) comma separated list of key:value pairs used to tag the tablet --init-timeout duration (init parameter) timeout to use for the init phase. (default 1m0s) --json-topo vttest.TopoData vttest proto definition of the topology, encoded in json format. See vttest.proto for more information. - --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) --keyspaces-to-watch strings Specifies which keyspaces this vtgate should have access to while routing queries or accessing the vschema. --lameduck-period duration keep running at least this long after SIGTERM before stopping (default 50ms) --lock-heartbeat-time duration If there is lock function used. This will keep the lock connection active by using this heartbeat (default 5s) @@ -197,10 +195,8 @@ Flags: --lock-timeout duration Maximum time to wait when attempting to acquire a lock from the topo server (default 45s) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") + --log-level string minimum log level (debug, info, warn, error) (default "info") --log-queries-to-file string Enable query logging to the specified file - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) --manifest-external-decompressor string command with arguments to store in the backup manifest when compressing a backup with an external compression engine. --max-concurrent-online-ddl int Maximum number of online DDL changes that may run concurrently (default 256) --max-memory-rows int Maximum number of rows that will be held in memory for intermediate results as well as the final result. (default 300000) @@ -278,7 +274,6 @@ Flags: --proto-topo vttest.TopoData vttest proto definition of the topology, encoded in compact text format. See vttest.proto for more information. --proxy-protocol Enable HAProxy PROXY protocol on MySQL listener socket --publish-retry-interval duration how long vttablet waits to retry publishing the tablet record (default 30s) - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --query-log-stream-handler string URL handler for streaming queries log (default "/debug/querylog") --query-throttler-config-refresh-interval duration How frequently to refresh configuration for the query throttler (default 1m0s) --query-timeout int Sets the default query timeout (in ms). Can be overridden by session variable (query_timeout) or comment directive (QUERY_TIMEOUT_MS) diff --git a/go/flags/endtoend/vtctlclient.txt b/go/flags/endtoend/vtctlclient.txt index 7de45cea63a..e53845bd897 100644 --- a/go/flags/endtoend/vtctlclient.txt +++ b/go/flags/endtoend/vtctlclient.txt @@ -1,6 +1,5 @@ Usage of vtctlclient: --action-timeout duration timeout for the total command (default 1h0m0s) - --alsologtostderr log to standard error as well as files --config-file string Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored. --config-file-not-found-handling ConfigFileNotFoundHandling Behavior when a config file is not found. (Options: error, exit, ignore, warn) (default warn) --config-name string Name of the config file (without extension) to search for. (default "vtconfig") @@ -18,32 +17,19 @@ Usage of vtctlclient: --grpc-max-message-size int Maximum allowed RPC message size. Larger messages will be rejected by gRPC with the error 'exceeding the max size'. (default 16777216) --grpc-prometheus Enable gRPC monitoring with Prometheus. -h, --help display usage and exit - --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) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) - --log_backtrace_at traceLocations when logging hits line file:N, emit a stack trace - --log_dir string If non-empty, write log files in this directory - --log_link string If non-empty, add symbolic links in this directory to the log files - --logbuflevel int Buffer log messages logged at this level or lower (-1 means don't buffer; 0 means buffer INFO only; ...). Has limited applicability on non-prod platforms. - --logtostderr log to standard error instead of files + --log-level string minimum log level (debug, info, warn, error) (default "info") --otel-endpoint string OpenTelemetry collector endpoint (host:port for gRPC); if empty, the OTEL_EXPORTER_OTLP_ENDPOINT env var is used --otel-insecure use insecure connection to OpenTelemetry collector --pprof strings enable profiling --pprof-http enable pprof http endpoints - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --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) --server string server to use for connection - --stderrthreshold severityFlag logs at or above this threshold go to stderr (default 1) --tracer string tracing service to use (default "noop") --tracing-enable-logging whether to enable logging in the tracing service --tracing-sampling-rate float sampling rate for traces as a probability between 0.0 and 1.0 (default 0.1) - --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 --vtctl-client-protocol string Protocol to use to talk to the vtctl server. (default "grpc") --vtctld-grpc-ca string the server ca to use to validate servers when connecting --vtctld-grpc-cert string the cert to use to connect diff --git a/go/flags/endtoend/vtctld.txt b/go/flags/endtoend/vtctld.txt index 855795ff3bb..8a04fabfb4e 100644 --- a/go/flags/endtoend/vtctld.txt +++ b/go/flags/endtoend/vtctld.txt @@ -85,15 +85,11 @@ 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 vtctld - --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) --lock-timeout duration Maximum time to wait when attempting to acquire a lock from the topo server (default 45s) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) + --log-level string minimum log level (debug, info, warn, error) (default "info") --max-stack-size int configure the maximum stack size in bytes (default 67108864) --mysql-server-version string MySQL server version to advertise. (default "8.4.6-Vitess") --onclose-timeout duration wait no more than this for OnClose handlers before stopping (default 10s) @@ -105,7 +101,6 @@ Flags: --port int port for the server --pprof strings enable profiling --pprof-http enable pprof http endpoints - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --remote-operation-timeout duration time to wait for a remote operation (default 15s) --s3-backup-aws-endpoint string endpoint of the S3 backend (region must be provided). --s3-backup-aws-min-partsize int Minimum part size to use, defaults to 5MiB but can be increased due to the dataset size. (default 5242880) diff --git a/go/flags/endtoend/vtctldclient.txt b/go/flags/endtoend/vtctldclient.txt index e0b0dc65bc8..0ddf70d5da7 100644 --- a/go/flags/endtoend/vtctldclient.txt +++ b/go/flags/endtoend/vtctldclient.txt @@ -120,7 +120,6 @@ Available Commands: Flags: --action-timeout duration timeout to use for the command (default 1h0m0s) - --alsologtostderr log to standard error as well as files --compact use compact format for otherwise verbose outputs --grpc-auth-static-client-creds string When using grpc_static_auth in the server, this file provides the credentials to use to authenticate with server. --grpc-compression string Which protocol to use for compressing gRPC. Default: nothing. Supported: snappy @@ -132,22 +131,11 @@ Flags: --grpc-max-message-size int Maximum allowed RPC message size. Larger messages will be rejected by gRPC with the error 'exceeding the max size'. (default 16777216) --grpc-prometheus Enable gRPC monitoring with Prometheus. -h, --help help for vtctldclient - --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) --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) - --log_backtrace_at traceLocations when logging hits line file:N, emit a stack trace - --log_dir string If non-empty, write log files in this directory - --log_link string If non-empty, add symbolic links in this directory to the log files - --logbuflevel int Buffer log messages logged at this level or lower (-1 means don't buffer; 0 means buffer INFO only; ...). Has limited applicability on non-prod platforms. - --logtostderr log to standard error instead of files + --log-level string minimum log level (debug, info, warn, error) (default "info") --mysql-server-version string MySQL server version to advertise. (default "8.4.6-Vitess") - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --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) --server string server to use for the connection (required) - --stderrthreshold severityFlag logs at or above this threshold go to stderr (default 1) --tablet-manager-grpc-ca string the server ca to use to validate servers when connecting --tablet-manager-grpc-cert string the cert to use to connect --tablet-manager-grpc-concurrency int concurrency to use to talk to a vttablet server for performance-sensitive RPCs (like ExecuteFetchAs{Dba,App}, CheckThrottler and FullStatus) (default 8) @@ -158,9 +146,7 @@ Flags: --topo-global-root string the path of the global topology data in the global topology server (default "/vitess/global") --topo-global-server-address strings the address of the global topology server(s) (default [localhost:2379]) --topo-implementation string the topology implementation to use (default "etcd2") - -v, --v Level log level for V logs - --version version for vtctldclient - --vmodule vModuleFlag comma-separated list of pattern=N settings for file-filtered logging + -v, --version version for vtctldclient --vtctl-client-protocol string Protocol to use to talk to the vtctl server. (default "grpc") --vtctld-grpc-ca string the server ca to use to validate servers when connecting --vtctld-grpc-cert string the cert to use to connect diff --git a/go/flags/endtoend/vtexplain.txt b/go/flags/endtoend/vtexplain.txt index 9632e2fb95a..4f599eaa9cb 100644 --- a/go/flags/endtoend/vtexplain.txt +++ b/go/flags/endtoend/vtexplain.txt @@ -49,22 +49,17 @@ Flags: --default-tablet-type topodatapb.TabletType The default tablet type to set for queries, when one is not explicitly selected. (default PRIMARY) --execution-mode string The execution mode to simulate -- must be set to multi, legacy-autocommit, or twopc (default "multi") -h, --help help for vtexplain - --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) --ks-shard-map string JSON map of keyspace name -> shard name -> ShardReference object. The inner map is the same as the output of FindAllShardsInKeyspace --ks-shard-map-file string File containing json blob of keyspace name -> shard name -> ShardReference object --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) + --log-level string minimum log level (debug, info, warn, error) (default "info") --mysql-server-version string MySQL server version to advertise. (default "8.4.6-Vitess") --normalize Whether to enable vtgate normalization --output-mode string Output in human-friendly text or json (default "text") --planner-version string Sets the default planner to use. Valid values are: Gen4, Gen4Greedy, Gen4Left2Right --pprof strings enable profiling --pprof-http enable pprof http endpoints - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --replication-mode string The replication mode to simulate -- must be set to either ROW or STATEMENT (default "ROW") --schema string The SQL table schema --schema-file string Identifies the file that contains the SQL table schema diff --git a/go/flags/endtoend/vtgate.txt b/go/flags/endtoend/vtgate.txt index b8fb9566533..f48f499417f 100644 --- a/go/flags/endtoend/vtgate.txt +++ b/go/flags/endtoend/vtgate.txt @@ -13,7 +13,6 @@ vtgate \ --topo-implementation etcd2 \ --topo-global-server-address localhost:2379 \ --topo-global-root /vitess/global \ - --log_dir $VTDATAROOT/tmp \ --port 15001 \ --grpc-port 15991 \ --mysql-server-port 15306 \ @@ -103,18 +102,14 @@ Flags: --healthcheck-retry-delay duration health check retry delay (default 2ms) --healthcheck-timeout duration the health check timeout period (default 1m0s) -h, --help help for vtgate - --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) --keyspaces-to-watch strings Specifies which keyspaces this vtgate should have access to while routing queries or accessing the vschema. --lameduck-period duration keep running at least this long after SIGTERM before stopping (default 50ms) --lock-heartbeat-time duration If there is lock function used. This will keep the lock connection active by using this heartbeat (default 5s) --lock-timeout duration Maximum time to wait when attempting to acquire a lock from the topo server (default 45s) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") + --log-level string minimum log level (debug, info, warn, error) (default "info") --log-queries-to-file string Enable query logging to the specified file - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) --max-memory-rows int Maximum number of rows that will be held in memory for intermediate results as well as the final result. (default 300000) --max-payload-size int The threshold for query payloads in bytes. A payload greater than this threshold will result in a failure to handle the query. --max-stack-size int configure the maximum stack size in bytes (default 67108864) @@ -174,7 +169,6 @@ Flags: --pprof-http enable pprof http endpoints --prevent-cross-keyspace-reads when set to true, the planner will fail instead of producing a plan that includes cross-keyspace joins or UNIONs --proxy-protocol Enable HAProxy PROXY protocol on MySQL listener socket - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --query-timeout int Sets the default query timeout (in ms). Can be overridden by session variable (query_timeout) or comment directive (QUERY_TIMEOUT_MS) --querylog-buffer-size int Maximum number of buffered query logs before throttling log output (default 10) --querylog-emit-on-any-condition-met Emit to query log when any of the conditions (row-threshold, time-threshold, filter-tag) is met (default false) diff --git a/go/flags/endtoend/vtgateclienttest.txt b/go/flags/endtoend/vtgateclienttest.txt index 820da747002..d0c5849f20d 100644 --- a/go/flags/endtoend/vtgateclienttest.txt +++ b/go/flags/endtoend/vtgateclienttest.txt @@ -45,14 +45,10 @@ 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 vtgateclienttest - --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) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) + --log-level string minimum log level (debug, info, warn, error) (default "info") --max-stack-size int configure the maximum stack size in bytes (default 67108864) --mysql-server-version string MySQL server version to advertise. (default "8.4.6-Vitess") --onclose-timeout duration wait no more than this for OnClose handlers before stopping (default 10s) @@ -61,7 +57,6 @@ Flags: --port int port for the server --pprof strings enable profiling --pprof-http enable pprof http endpoints - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --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 --table-refresh-interval int interval in milliseconds to refresh tables in status page with refreshRequired class diff --git a/go/flags/endtoend/vtorc.txt b/go/flags/endtoend/vtorc.txt index f23a1a476b9..df29d459c50 100644 --- a/go/flags/endtoend/vtorc.txt +++ b/go/flags/endtoend/vtorc.txt @@ -8,11 +8,9 @@ vtorc \ --topo-implementation etcd2 \ --topo-global-server-address localhost:2379 \ --topo-global-root /vitess/global \ - --log_dir $VTDATAROOT/tmp \ --port 15000 \ --instance-poll-time "1s" \ - --topo-information-refresh-duration "30s" \ - --alsologtostderr + --topo-information-refresh-duration "30s" Flags: --allow-emergency-reparent Whether VTOrc should be allowed to run emergency reparent operation when it detects a dead primary (default true) @@ -53,15 +51,11 @@ Flags: --grpc-prometheus Enable gRPC monitoring with Prometheus. -h, --help help for vtorc --instance-poll-time duration Timer duration on which VTOrc refreshes MySQL information (default 5s) - --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) --lock-timeout duration Maximum time to wait when attempting to acquire a lock from the topo server (default 45s) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) + --log-level string minimum log level (debug, info, warn, error) (default "info") --max-stack-size int configure the maximum stack size in bytes (default 67108864) --onclose-timeout duration wait no more than this for OnClose handlers before stopping (default 10s) --onterm-timeout duration wait no more than this for OnTermSync handlers before stopping (default 10s) @@ -70,7 +64,6 @@ Flags: --pprof strings enable profiling --pprof-http enable pprof http endpoints --prevent-cross-cell-failover Prevent VTOrc from promoting a primary in a different cell than the current primary in case of a failover - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --reasonable-replication-lag duration Maximum replication lag on replicas which is deemed to be acceptable (default 10s) --recovery-poll-duration duration Timer duration on which VTOrc polls its database to run a recovery (default 1s) --remote-operation-timeout duration time to wait for a remote operation (default 15s) diff --git a/go/flags/endtoend/vttablet.txt b/go/flags/endtoend/vttablet.txt index 40ffeba7b38..2faa27ca981 100644 --- a/go/flags/endtoend/vttablet.txt +++ b/go/flags/endtoend/vttablet.txt @@ -213,18 +213,14 @@ Flags: --init-tablet-type-lookup (Experimental, init parameter) if enabled, uses tablet alias to look up the tablet type from the existing topology record on restart and use that instead of init-tablet-type. This allows tablets to maintain their changed roles (e.g., RDONLY/DRAINED) across restarts. If disabled or if no topology record exists, init-tablet-type will be used. --init-tags StringMap (init parameter) comma separated list of key:value pairs used to tag the tablet --init-timeout duration (init parameter) timeout to use for the init phase. (default 1m0s) - --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) --lock-tables-timeout duration How long to keep the table locked before timing out (default 1m0s) --lock-timeout duration Maximum time to wait when attempting to acquire a lock from the topo server (default 45s) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") + --log-level string minimum log level (debug, info, warn, error) (default "info") --log-queries Enable query logging to syslog. --log-queries-to-file string Enable query logging to the specified file - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) --manifest-external-decompressor string command with arguments to store in the backup manifest when compressing a backup with an external compression engine. --max-concurrent-online-ddl int Maximum number of online DDL changes that may run concurrently (default 256) --max-stack-size int configure the maximum stack size in bytes (default 67108864) @@ -270,7 +266,6 @@ Flags: --pprof strings enable profiling --pprof-http enable pprof http endpoints --publish-retry-interval duration how long vttablet waits to retry publishing the tablet record (default 30s) - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --query-log-stream-handler string URL handler for streaming queries log (default "/debug/querylog") --query-throttler-config-refresh-interval duration How frequently to refresh configuration for the query throttler (default 1m0s) --querylog-emit-on-any-condition-met Emit to query log when any of the conditions (row-threshold, time-threshold, filter-tag) is met (default false) diff --git a/go/flags/endtoend/vttestserver.txt b/go/flags/endtoend/vttestserver.txt index 47949c553ad..e1aa2e19789 100644 --- a/go/flags/endtoend/vttestserver.txt +++ b/go/flags/endtoend/vttestserver.txt @@ -82,15 +82,11 @@ Flags: -h, --help help for vttestserver --initialize-with-random-data If this flag is each table-shard will be initialized with random data. See also the 'rng_seed' and 'min_shard_size' and 'max_shard_size' flags. --initialize-with-vt-dba-tcp If this flag is enabled, MySQL will be initialized with an additional user named vt_dba_tcp, who will have access via TCP/IP connection. - --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) --keyspaces strings Comma separated list of keyspaces (default [test_keyspace]) --lameduck-period duration keep running at least this long after SIGTERM before stopping (default 50ms) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) + --log-level string minimum log level (debug, info, warn, error) (default "info") --manifest-external-decompressor string command with arguments to store in the backup manifest when compressing a backup with an external compression engine. --max-stack-size int configure the maximum stack size in bytes (default 67108864) --max-table-shard-size int The maximum number of initial rows in a table shard. Ignored if--initialize-with-random-data is false. The actual number is chosen randomly (default 10000) @@ -122,7 +118,6 @@ Flags: --pprof-http enable pprof http endpoints --prevent-cross-keyspace-reads when set to true, the planner will fail instead of producing a plan that includes cross-keyspace joins or UNIONs --proto-topo string Define the fake cluster topology as a compact text format encoded vttest proto. See vttest.proto for more information. - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) --queryserver-config-transaction-timeout duration query server transaction timeout, a transaction will be killed if it takes longer than this value (default 30s) --rdonly-count int Rdonly tablets per shard (default 1) --replica-count int Replica tablets per shard (includes primary) (default 2) diff --git a/go/flags/endtoend/zk.txt b/go/flags/endtoend/zk.txt index 664e37965b9..321d41c4ffe 100644 --- a/go/flags/endtoend/zk.txt +++ b/go/flags/endtoend/zk.txt @@ -30,15 +30,10 @@ Available Commands: zip Store a zk tree in a zip archive. Flags: - -h, --help help for zk - --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) - --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) - --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) - --server string server(s) to connect to + -h, --help help for zk + --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") + --log-level string minimum log level (debug, info, warn, error) (default "info") + --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) + --server string server(s) to connect to Use "zk [command] --help" for more information about a command. diff --git a/go/flags/endtoend/zkctl.txt b/go/flags/endtoend/zkctl.txt index 07005fa3c99..27737d411ee 100644 --- a/go/flags/endtoend/zkctl.txt +++ b/go/flags/endtoend/zkctl.txt @@ -19,16 +19,11 @@ Flags: --config-persistence-min-interval duration minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done). (default 1s) --config-type string Config file type (omit to infer config type from file extension). -h, --help help for zkctl - --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) --log-err-stacks log stack traces for errors --log-format string log output format: json for machine-readable JSON, text for human-readable colored output (default "json") - --log-level string minimum log level when structured logging is enabled (debug, info, warn, error) (default "info") - --log-rotate-max-size uint size in bytes at which logs are rotated (glog.MaxSize) (default 1887436800) - --log-structured enable structured JSON logging (default true) + --log-level string minimum log level (debug, info, warn, error) (default "info") --pprof strings enable profiling --pprof-http enable pprof http endpoints - --purge-logs-interval duration how often try to remove old logs (default 1h0m0s) -v, --version print binary version --zk.cfg string zkid@server1:leaderPort1:electionPort1:clientPort1,...) (default "6@:3801:3802:3803") --zk.extra stringArray extra config line(s) to append verbatim to config (flag can be specified more than once) diff --git a/go/internal/flag/flag.go b/go/internal/flag/flag.go index 8ea7967d4d8..deecdf37ed8 100644 --- a/go/internal/flag/flag.go +++ b/go/internal/flag/flag.go @@ -42,7 +42,6 @@ import ( // // See VEP-4, phase 1 for details: https://github.com/vitessio/enhancements/blob/c766ea905e55409cddeb666d6073cd2ac4c9783e/veps/vep-4.md#phase-1-preparation func Parse(fs *flag.FlagSet) { - PreventGlogVFlagFromClobberingVersionFlagShorthand(fs) fs.AddGoFlagSet(goflag.CommandLine) if fs.Lookup("help") == nil { @@ -62,8 +61,6 @@ func Parse(fs *flag.FlagSet) { }() } - TrickGlog() // see the function doc for why. - flag.CommandLine = fs flag.Parse() } @@ -77,59 +74,6 @@ func IsFlagProvided(name string) bool { return false } -// TrickGlog tricks glog into understanding that flags have been parsed. -// -// N.B. Do not delete this function. `glog` is a persnickity package and wants -// to insist that you parse flags before doing any logging, which is a totally -// reasonable thing (for example, if you log something at DEBUG before parsing -// the flag that tells you to only log at WARN or greater). -// -// However, `glog` also "insists" that you use the standard library to parse (by -// checking `flag.Parsed()`), which doesn't cover cases where `glog` flags get -// installed on some other parsing package, in our case pflag, and therefore are -// actually being parsed before logging. This is incredibly annoying, because -// all log lines end up prefixed with: -// -// > "ERROR: logging before flag.Parse" -// -// So, we include this little shim to trick `glog` into (correctly, I must -// add!!!!) realizing that CLI arguments have indeed been parsed. Then, we put -// os.Args back in their rightful place, so the parsing we actually want to do -// can proceed as usual. -func TrickGlog() { - args := os.Args[1:] - os.Args = os.Args[0:1] - goflag.Parse() - - os.Args = append(os.Args, args...) -} - -// The default behavior of PFlagFromGoFlag (which is called on each flag when -// calling AddGoFlagSet) is to allow any flags with single-character names to be -// accessible both as, for example, `-v` and `--v`. -// -// This prevents us from exposing version via `--version|-v` (pflag will actually -// panic when it goes to add the glog log-level flag), so we intervene to blank -// out the Shorthand for _just_ that flag before adding the rest of the goflags -// to a particular pflag FlagSet. -// -// IMPORTANT: This must be called prior to AddGoFlagSet in both Parse and -// ParseFlagsForTest. -func PreventGlogVFlagFromClobberingVersionFlagShorthand(fs *flag.FlagSet) { - // N.B. we use goflag.Lookup instead of this package's Lookup, because we - // explicitly want to check only the goflags. - if f := goflag.Lookup("v"); f != nil { - if fs.Lookup("v") != nil { // This check is exactly what AddGoFlagSet does. - return - } - - pf := flag.PFlagFromGoFlag(f) - pf.Shorthand = "" - - fs.AddFlag(pf) - } -} - // Usage invokes the current CommandLine's Usage func, or if not overridden, // "prints a simple header and calls PrintDefaults". func Usage() { @@ -179,8 +123,7 @@ func ParseFlagsForTest() { fmt.Println("Error parsing regular test flags:", err) } - // parse remaining flags including the log-related ones like --alsologtostderr - PreventGlogVFlagFromClobberingVersionFlagShorthand(flag.CommandLine) + // Add the Go testing flags to the pflag set before the parse. pflag rejects a flag that it does not know. flag.CommandLine.AddGoFlagSet(goflag.CommandLine) flag.Parse() } @@ -196,21 +139,6 @@ func Parsed() bool { return goflag.Parsed() || flag.Parsed() } -// Lookup returns a pflag.Flag with the given name, from either the pflag or -// standard library `flag` CommandLine. If found in the latter, it is converted -// to a pflag.Flag first. If found in neither, this function returns nil. -func Lookup(name string) *flag.Flag { - if f := flag.Lookup(name); f != nil { - return f - } - - if f := goflag.Lookup(name); f != nil { - return flag.PFlagFromGoFlag(f) - } - - return nil -} - // Args returns the positional arguments with the first double-dash ("--") // removed. If no double-dash was specified on the command-line, this is // equivalent to flag.Args() from the standard library flag package. diff --git a/go/internal/flag/flag_test.go b/go/internal/flag/flag_test.go index c6ab20b1834..5c24386f5f8 100644 --- a/go/internal/flag/flag_test.go +++ b/go/internal/flag/flag_test.go @@ -25,29 +25,6 @@ import ( "github.com/stretchr/testify/assert" ) -func TestPreventGlogVFlagFromClobberingVersionFlagShorthand(t *testing.T) { - oldCommandLine := goflag.CommandLine - defer func() { - goflag.CommandLine = oldCommandLine - }() - - goflag.CommandLine = goflag.NewFlagSet(os.Args[0], goflag.ExitOnError) - - var v bool - - goflag.BoolVar(&v, "v", true, "") - - testFlagSet := pflag.NewFlagSet("testFlagSet", pflag.ExitOnError) - PreventGlogVFlagFromClobberingVersionFlagShorthand(testFlagSet) - - f := testFlagSet.Lookup("v") - assert.NotNil(t, f) - assert.Empty(t, f.Shorthand) - - // The function should not panic if -v flag is already defined - assert.NotPanics(t, func() { PreventGlogVFlagFromClobberingVersionFlagShorthand(testFlagSet) }) -} - func TestParse(t *testing.T) { oldCommandLine := goflag.CommandLine defer func() { @@ -196,55 +173,6 @@ func TestParsed(t *testing.T) { assert.True(t, b, "command-line flags should be parsed") } -func TestLookup(t *testing.T) { - oldPflagCommandLine := pflag.CommandLine - oldCommandLine := goflag.CommandLine - - defer func() { - pflag.CommandLine = oldPflagCommandLine - goflag.CommandLine = oldCommandLine - }() - - pflag.CommandLine = pflag.NewFlagSet("testPflagSet", pflag.ExitOnError) - goflag.CommandLine = goflag.NewFlagSet("testGoflagSet", goflag.ExitOnError) - - var testGoFlag, testPflag, testFlag bool - - goflag.BoolVar(&testGoFlag, "testGoFlag", true, "") - goflag.BoolVar(&testFlag, "t", true, "") - pflag.BoolVar(&testPflag, "testPflag", true, "") - - testCases := []struct { - shorthand string - name string - }{ - { - // If single character flag is passed, the shorthand should be the same - shorthand: "t", - name: "t", - }, - { - shorthand: "", - name: "testGoFlag", - }, - { - shorthand: "", - name: "testPflag", - }, - } - - for _, tt := range testCases { - f := Lookup(tt.name) - - assert.NotNil(t, f) - assert.Equal(t, tt.shorthand, f.Shorthand) - assert.Equal(t, tt.name, f.Name) - } - - f := Lookup("non-existent-flag") - assert.Nil(t, f) -} - func TestArgs(t *testing.T) { oldPflagCommandLine := pflag.CommandLine oldOsArgs := os.Args diff --git a/go/mysql/collations/integration/main_test.go b/go/mysql/collations/integration/main_test.go index 647f07c0fdc..207c13719e1 100644 --- a/go/mysql/collations/integration/main_test.go +++ b/go/mysql/collations/integration/main_test.go @@ -58,7 +58,6 @@ func mysqlconn(t *testing.T) *mysql.Conn { } func TestMain(m *testing.M) { - _flag.TrickGlog() _flag.ParseFlagsForTest() pflag.Parse() diff --git a/go/test/endtoend/vreplication/cluster_test.go b/go/test/endtoend/vreplication/cluster_test.go index f94cdbc9a44..6abc2259c33 100644 --- a/go/test/endtoend/vreplication/cluster_test.go +++ b/go/test/endtoend/vreplication/cluster_test.go @@ -641,15 +641,8 @@ func (vc *VitessCluster) AddShards(t *testing.T, cells []*Cell, keyspace *Keyspa if err = dbcmd.Wait(); err != nil { // Get logs to help understand why it failed... vtdataroot := os.Getenv("VTDATAROOT") - mysqlctlLog := path.Join(vtdataroot, "/tmp/mysqlctl.INFO") - logBytes, ferr := os.ReadFile(mysqlctlLog) - if ferr == nil { - log.Error("mysqlctl log contents:\n" + string(logBytes)) - } else { - log.Error(fmt.Sprintf("Failed to read the mysqlctl log file %q: %v", mysqlctlLog, ferr)) - } mysqldLog := path.Join(vtdataroot, fmt.Sprintf("/vt_%010d/error.log", tablets[ind].Vttablet.TabletUID)) - logBytes, ferr = os.ReadFile(mysqldLog) + logBytes, ferr := os.ReadFile(mysqldLog) if ferr == nil { log.Error("mysqld error log contents:\n" + string(logBytes)) } else { diff --git a/go/test/utils/noleak.go b/go/test/utils/noleak.go index b736cef07dd..cea61ba5751 100644 --- a/go/test/utils/noleak.go +++ b/go/test/utils/noleak.go @@ -74,8 +74,6 @@ func ensureNoGoroutines() error { ignored := []goleak.Option{ goleak.IgnoreTopFunction("internal/synctest.Run"), goleak.IgnoreTopFunction("testing/synctest.testingSynctestTest"), - goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon"), - goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"), goleak.IgnoreTopFunction("vitess.io/vitess/go/vt/dbconfigs.init.0.func1"), goleak.IgnoreTopFunction("vitess.io/vitess/go/vt/vtgate.resetAggregators"), goleak.IgnoreTopFunction("vitess.io/vitess/go/vt/vtgate.processQueryInfo"), diff --git a/go/vt/discovery/keyspace_events.go b/go/vt/discovery/keyspace_events.go index 0555cd127fe..57db5b2cfb2 100644 --- a/go/vt/discovery/keyspace_events.go +++ b/go/vt/discovery/keyspace_events.go @@ -353,7 +353,7 @@ func (kss *keyspaceState) ensureConsistentLocked() { Serving: sstate.serving, }) - log.V(2).Info(fmt.Sprintf("keyspace event resolved: %s is now consistent (serving: %t)", topoproto.KeyspaceShardString(sstate.target.Keyspace, sstate.target.Shard), + log.Debug(fmt.Sprintf("keyspace event resolved: %s is now consistent (serving: %t)", topoproto.KeyspaceShardString(sstate.target.Keyspace, sstate.target.Shard), sstate.serving)) if !sstate.serving { diff --git a/go/vt/grpcclient/glogger.go b/go/vt/grpcclient/glogger.go index ee1bd11ddd7..f319c7f0e8f 100644 --- a/go/vt/grpcclient/glogger.go +++ b/go/vt/grpcclient/glogger.go @@ -78,6 +78,6 @@ func (g *glogger) Fatalf(format string, args ...any) { os.Exit(1) } -func (g *glogger) V(l int) bool { - return bool(log.V(log.Level(l))) +func (g *glogger) V(int) bool { + return false } diff --git a/go/vt/log/flags.go b/go/vt/log/flags.go index 916742bfe57..f7b0a30f6f1 100644 --- a/go/vt/log/flags.go +++ b/go/vt/log/flags.go @@ -17,57 +17,64 @@ limitations under the License. package log import ( + "errors" "fmt" "log/slog" "os" - "strconv" - "sync/atomic" "testing" - "github.com/golang/glog" "github.com/lmittmann/tint" "github.com/mattn/go-isatty" "github.com/spf13/pflag" - - "vitess.io/vitess/go/vt/utils" ) +// removedFlagMessage is the deprecation message of the logging flags that have no effect. +const removedFlagMessage = "it has no effect and will be removed in v26" + var ( - logStructured bool - logLevel string - logFormat string + logLevel = "info" + logFormat = "json" + + // logStructured is the value of the removed --log-structured flag. Init fails when it is false. + logStructured = true ) +// RegisterFlags registers the logging flags on fs. func RegisterFlags(fs *pflag.FlagSet) { - flagVal := logRotateMaxSize{ - val: strconv.FormatUint(atomic.LoadUint64(&glog.MaxSize), 10), - } - utils.SetFlagVar(fs, &flagVal, "log-rotate-max-size", "size in bytes at which logs are rotated (glog.MaxSize)") + fs.StringVar(&logLevel, "log-level", logLevel, "minimum log level (debug, info, warn, error)") + fs.StringVar(&logFormat, "log-format", logFormat, "log output format: json for machine-readable JSON, text for human-readable colored output") - fs.BoolVar(&logStructured, "log-structured", true, "enable structured JSON logging") - fs.StringVar(&logLevel, "log-level", "info", "minimum log level when structured logging is enabled (debug, info, warn, error)") - fs.StringVar(&logFormat, "log-format", "json", "log output format: json for machine-readable JSON, text for human-readable colored output") + registerRemovedFlags(fs) } -// Init configures the logging backend. By default, a slog.JSONHandler is -// configured. If --log-structured=false is set, the deprecated glog backend -// is used instead. -func Init(fs *pflag.FlagSet) error { - if !logStructured { - fmt.Fprintln(os.Stderr, "WARNING: glog is deprecated and will be removed in v25") - structured.Store(false) - return nil +// registerRemovedFlags registers the removed logging flags that v24 did not mark as deprecated. The flags let old +// startup arguments parse for one more release. +func registerRemovedFlags(fs *pflag.FlagSet) { + fs.BoolVar(&logStructured, "log-structured", logStructured, "") + _ = fs.MarkDeprecated("log-structured", removedFlagMessage) + + for _, name := range []string{"log-rotate-max-size", "keep-logs", "keep-logs-by-mtime", "purge-logs-interval"} { + fs.String(name, "", "") + _ = fs.MarkDeprecated(name, removedFlagMessage) } +} + +// RegisterRemovedClientFlags registers the removed glog flags that vtctldclient and vtctlclient accepted without a +// deprecation warning in v24. The flags let old scripts run for one more release. +func RegisterRemovedClientFlags(fs *pflag.FlagSet) { + for _, name := range []string{"logtostderr", "alsologtostderr"} { + fs.Bool(name, false, "") + _ = fs.MarkDeprecated(name, removedFlagMessage) + } +} - // Warn if any glog flags were explicitly set while structured logging is active, - // since they have no effect. - for _, name := range []string{"logtostderr", "alsologtostderr", "stderrthreshold", "log_dir", "log_backtrace_at", "vmodule", "v"} { - if fs.Changed(name) { - fmt.Fprintf(os.Stderr, "WARNING: --%s has no effect when structured logging is enabled, pass --log-structured=false to use glog flags\n", name) - } +// Init configures the logger. +func Init() error { + // Fail on --log-structured=false. The caller expects glog log files, which Vitess does not write. + if !logStructured { + return errors.New("log: --log-structured=false is not supported, glog was removed in v25") } - // Parse the level flag into an [slog.Level]. var level slog.Level if err := level.UnmarshalText([]byte(logLevel)); err != nil { return fmt.Errorf("log: invalid --log-level %q: %w", logLevel, err) @@ -75,7 +82,6 @@ func Init(fs *pflag.FlagSet) error { l := newLogger(level) logger.Store(l) - structured.Store(true) return nil } @@ -100,27 +106,3 @@ func newLogger(level slog.Level) *slog.Logger { return slog.New(slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{AddSource: true, Level: level})) } - -type logRotateMaxSize struct { - val string -} - -func (lrms *logRotateMaxSize) Set(s string) error { - maxSize, err := strconv.ParseUint(s, 10, 64) - if err != nil { - return err - } - - atomic.StoreUint64(&glog.MaxSize, maxSize) - lrms.val = s - - return nil -} - -func (lrms *logRotateMaxSize) String() string { - return lrms.val -} - -func (lrms *logRotateMaxSize) Type() string { - return "uint64" -} diff --git a/go/vt/log/flags_test.go b/go/vt/log/flags_test.go new file mode 100644 index 00000000000..c465350db0c --- /dev/null +++ b/go/vt/log/flags_test.go @@ -0,0 +1,77 @@ +/* +Copyright 2026 The Vitess Authors. + +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, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package log + +import ( + "log/slog" + "testing" + + "github.com/spf13/pflag" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// TestInitWithoutRegisterFlags checks that Init succeeds when the logging flags are not registered. +func TestInitWithoutRegisterFlags(t *testing.T) { + previous := SwapLogger(nil) + t.Cleanup(func() { SwapLogger(previous) }) + + require.NoError(t, Init()) + assert.True(t, Enabled(slog.LevelInfo)) + assert.False(t, Enabled(slog.LevelDebug)) +} + +// TestRemovedFlagsHaveNoEffect checks that the logging flags removed without a v24 warning still parse, stay out of +// the help output, and do not stop Init. +func TestRemovedFlagsHaveNoEffect(t *testing.T) { + previous := SwapLogger(nil) + t.Cleanup(func() { SwapLogger(previous) }) + + fs := pflag.NewFlagSet("test", pflag.ContinueOnError) + RegisterFlags(fs) + RegisterRemovedClientFlags(fs) + + err := fs.Parse([]string{ + "--log-structured", + "--log-rotate-max-size=1024", + "--keep-logs=1h", + "--keep-logs-by-mtime=1h", + "--purge-logs-interval=1h", + "--logtostderr", + "--alsologtostderr", + }) + require.NoError(t, err) + + for _, name := range []string{"log-structured", "log-rotate-max-size", "keep-logs", "keep-logs-by-mtime", "purge-logs-interval", "logtostderr", "alsologtostderr"} { + assert.NotEmpty(t, fs.Lookup(name).Deprecated, name) + } + + require.NoError(t, Init()) +} + +// TestInitRejectsLogStructuredFalse checks that Init fails when --log-structured=false asks for glog log files. +func TestInitRejectsLogStructuredFalse(t *testing.T) { + previous := SwapLogger(nil) + t.Cleanup(func() { SwapLogger(previous) }) + + fs := pflag.NewFlagSet("test", pflag.ContinueOnError) + RegisterFlags(fs) + t.Cleanup(func() { logStructured = true }) + + require.NoError(t, fs.Parse([]string{"--log-structured=false"})) + assert.ErrorContains(t, Init(), "--log-structured=false") +} diff --git a/go/vt/log/log.go b/go/vt/log/log.go index b57239a18fb..ac074791fbd 100644 --- a/go/vt/log/log.go +++ b/go/vt/log/log.go @@ -22,22 +22,12 @@ import ( "runtime" "sync/atomic" "time" - - "github.com/golang/glog" ) -// Level is used with V() to test log verbosity. -type Level = glog.Level - var ( - // structured is whether structured logging is currently enabled or not. - structured atomic.Bool - - // logger is the currently configured structured logger. + // logger is the currently configured logger. logger atomic.Pointer[slog.Logger] - Flush = glog.Flush - Debug = func(msg string, attrs ...slog.Attr) { log(slog.LevelDebug, 1, msg, attrs...) } Info = func(msg string, attrs ...slog.Attr) { log(slog.LevelInfo, 1, msg, attrs...) } Warn = func(msg string, attrs ...slog.Attr) { log(slog.LevelWarn, 1, msg, attrs...) } @@ -49,35 +39,30 @@ var ( ErrorDepth = func(depth int, msg string, attrs ...slog.Attr) { log(slog.LevelError, depth+1, msg, attrs...) } ) -// init is used to initialize structured logging to true and set up a default logger. -// This is to workaround situations (like testing) where there is no explicit [Init] call -// that enables structured logging. This should be removed once structured logging is -// the only option. +// init sets up a default logger. This is to work around situations (like testing) where there is no explicit [Init] +// call. func init() { logger.Store(newLogger(slog.LevelInfo)) - structured.Store(true) } -// SwapLogger atomically replaces the structured logger with a new one +// SwapLogger atomically replaces the logger with a new one // and returns the previous logger. This is safe for concurrent use and is // intended for tests that need to intercept log output. func SwapLogger(newLogger *slog.Logger) *slog.Logger { return logger.Swap(newLogger) } -// log is a helper that logs with glog or slog depending on the configured flags. -func log(level slog.Level, depth int, msg string, attrs ...slog.Attr) { - if !structured.Load() { - logGlog(level, depth+1, msg, attrs...) - return - } - +// Enabled reports whether the current logger emits records at the given level. +// Use it to skip building expensive log attributes. +func Enabled(level slog.Level) bool { l := logger.Load() - if l == nil { - return - } + return l != nil && l.Enabled(context.Background(), level) +} - if !l.Enabled(context.Background(), level) { +// log is a helper that logs with slog. +func log(level slog.Level, depth int, msg string, attrs ...slog.Attr) { + l := logger.Load() + if l == nil || !l.Enabled(context.Background(), level) { return } @@ -89,72 +74,3 @@ func log(level slog.Level, depth int, msg string, attrs ...slog.Attr) { _ = l.Handler().Handle(context.Background(), r) } - -// logGlog is a helper that logs with glog. If structured attributes are passed, they -// are appended to the message in the format "key=value". -func logGlog(level slog.Level, depth int, msg string, attrs ...slog.Attr) { - depth++ - - if len(attrs) == 0 { - switch { - case level >= slog.LevelError: - glog.ErrorDepth(depth, msg) - case level >= slog.LevelWarn: - glog.WarningDepth(depth, msg) - default: - glog.InfoDepth(depth, msg) - } - - return - } - - args := make([]any, 0, len(attrs)+2) - - // Append the message, and add a space to separate the message from the start of the attributes. glog - // follows fmt.Print semantics, which concatenates two entries if either one is a string, and only - // separates with a space if both are non-strings. - args = append(args, msg, " ") - - if len(args) > 0 { - args = append(args, " ") - } - - for _, attr := range attrs { - args = append(args, attr) - } - - switch { - case level >= slog.LevelError: - glog.ErrorDepth(depth, args...) - case level >= slog.LevelWarn: - glog.WarningDepth(depth, args...) - default: - glog.InfoDepth(depth, args...) - } -} - -// Verbose gates logging at a given V-level. Used to temporarily support glog -// call sites. -// -// TODO: migrate call sites to normal debug logging and remove this once glog -// is removed. -type Verbose bool - -func V(level Level) Verbose { - if !structured.Load() { - return Verbose(glog.V(level)) - } - - l := logger.Load() - if l == nil { - return false - } - - return Verbose(l.Enabled(context.Background(), slog.Level(-int(level)))) -} - -func (v Verbose) Info(msg string, attrs ...slog.Attr) { - if v { - log(slog.LevelInfo, 1, msg, attrs...) - } -} diff --git a/go/vt/log/prefixed.go b/go/vt/log/prefixed.go index 66017807bb1..8dfd302a598 100644 --- a/go/vt/log/prefixed.go +++ b/go/vt/log/prefixed.go @@ -45,6 +45,3 @@ func (pl *PrefixedLogger) WarnDepth(depth int, msg string, attrs ...slog.Attr) { func (pl *PrefixedLogger) ErrorDepth(depth int, msg string, attrs ...slog.Attr) { ErrorDepth(depth+1, pl.prefix+msg, attrs...) } - -func (pl *PrefixedLogger) V(level Level) Verbose { return V(level) } -func (pl *PrefixedLogger) Flush() { Flush() } diff --git a/go/vt/logutil/console_logger.go b/go/vt/logutil/console_logger.go index 67cbcb90190..b8e622fdf2a 100644 --- a/go/vt/logutil/console_logger.go +++ b/go/vt/logutil/console_logger.go @@ -22,7 +22,7 @@ import ( "vitess.io/vitess/go/vt/log" ) -// ConsoleLogger is a Logger that uses glog directly to log, at the right level. +// ConsoleLogger is a Logger that writes at the requested level. // // Note that methods on ConsoleLogger must use pointer receivers, // because otherwise an autogenerated conversion method will be inserted in the diff --git a/go/vt/logutil/flush.go b/go/vt/logutil/flush.go deleted file mode 100644 index e3b02486309..00000000000 --- a/go/vt/logutil/flush.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright 2019 The Vitess Authors. - -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, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package logutil - -import ( - "vitess.io/vitess/go/event" -) - -var onFlushHooks event.Hooks - -// OnFlush registers a function to be called when Flush() is invoked. -func OnFlush(fn func()) { - onFlushHooks.Add(fn) -} - -// Flush calls the functions registered through OnFlush() and waits for them. -// -// Programs that use servenv.Run*() will invoke Flush() automatically at -// shutdown. Other programs should defer logutil.Flush() at the beginning of -// main(). -// -// Concurrent calls to Flush are serialized. -func Flush() { - onFlushHooks.Fire() -} diff --git a/go/vt/logutil/flush_glog.go b/go/vt/logutil/flush_glog.go deleted file mode 100644 index 8b7015dd3fe..00000000000 --- a/go/vt/logutil/flush_glog.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -Copyright 2019 The Vitess Authors. - -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, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package logutil - -import ( - "vitess.io/vitess/go/vt/log" -) - -func init() { - OnFlush(log.Flush) -} diff --git a/go/vt/logutil/level.go b/go/vt/logutil/level.go deleted file mode 100644 index 0b5b93efdd5..00000000000 --- a/go/vt/logutil/level.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright 2019 The Vitess Authors. - -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, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package logutil - -import ( - _flag "vitess.io/vitess/go/internal/flag" -) - -func init() { - threshold := _flag.Lookup("stderrthreshold") - if threshold == nil { - // the logging module doesn't specify a stderrthreshold flag - return - } - - const warningLevel = "1" - if err := threshold.Value.Set(warningLevel); err != nil { - return - } - threshold.DefValue = warningLevel -} diff --git a/go/vt/logutil/logutil.go b/go/vt/logutil/logutil.go index eea87484921..ce65213f4af 100644 --- a/go/vt/logutil/logutil.go +++ b/go/vt/logutil/logutil.go @@ -14,8 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// package logutil provides some utilities for logging using glog and -// redirects the stdlib logging to glog. +// Package logutil provides logging utilities and redirects standard library logging. package logutil diff --git a/go/vt/logutil/logutil_test.go b/go/vt/logutil/logutil_test.go deleted file mode 100644 index fb415748df9..00000000000 --- a/go/vt/logutil/logutil_test.go +++ /dev/null @@ -1,130 +0,0 @@ -/* -Copyright 2019 The Vitess Authors. - -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, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package logutil - -import ( - "fmt" - "os" - "path" - "path/filepath" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestParsing(t *testing.T) { - path := []string{ - "/tmp/something.foo/zkocc.goedel.szopa.log.INFO.20130806-151006.10530", - "/tmp/something.foo/zkocc.goedel.szopa.test.log.ERROR.20130806-151006.10530", - } - - for _, filepath := range path { - ts, err := parseCreatedTimestamp(filepath) - require.NoError(t, err) - - want := time.Date(2013, 8, 6, 15, 10, 0o6, 0, time.Now().Location()) - assert.Equalf(t, want, ts, "timestamp: want %v, got %v", want, ts) - } -} - -func TestPurgeByCtime(t *testing.T) { - logDir := path.Join(os.TempDir(), fmt.Sprintf("%v-%v", os.Args[0], os.Getpid())) - if err := os.MkdirAll(logDir, 0o777); err != nil { - require.NoError(t, err) - } - defer os.RemoveAll(logDir) - - now := time.Date(2013, 8, 6, 15, 10, 0o6, 0, time.Now().Location()) - files := []string{ - "zkocc.goedel.szopa.log.INFO.20130806-121006.10530", - "zkocc.goedel.szopa.log.INFO.20130806-131006.10530", - "zkocc.goedel.szopa.log.INFO.20130806-141006.10530", - "zkocc.goedel.szopa.log.INFO.20130806-151006.10530", - } - - for _, file := range files { - if _, err := os.Create(path.Join(logDir, file)); err != nil { - require.NoError(t, err) - } - } - if err := os.Symlink(files[1], path.Join(logDir, "zkocc.INFO")); err != nil { - require.NoError(t, err) - } - - purgeLogsOnce(now, logDir, "zkocc", 30*time.Minute, 0) - - left, err := filepath.Glob(path.Join(logDir, "zkocc.*")) - require.NoError(t, err) - - // 131006 is current - // 151006 is within 30 min - // symlink remains - // the rest should be removed. - assert.Lenf(t, left, 3, "wrong number of files remain: want %v, got %v", 3, len(left)) -} - -func TestPurgeByMtime(t *testing.T) { - logDir := path.Join(os.TempDir(), fmt.Sprintf("%v-%v", os.Args[0], os.Getpid())) - if err := os.MkdirAll(logDir, 0o777); err != nil { - require.NoError(t, err) - } - defer os.RemoveAll(logDir) - createFileWithMtime := func(filename, mtimeStr string) { - var err error - var mtime time.Time - filepath := path.Join(logDir, filename) - if mtime, err = time.Parse(time.RFC3339, mtimeStr); err != nil { - require.NoError(t, err) - } - if _, err = os.Create(filepath); err != nil { - require.NoError(t, err) - } - if err = os.Chtimes(filepath, mtime, mtime); err != nil { - require.NoError(t, err) - } - } - now := time.Date(2020, 1, 1, 12, 0, 0, 0, time.UTC) - filenameMtimeMap := map[string]string{ - "vtadam.localhost.vitess.log.INFO.20200101-113000.00000": "2020-01-01T11:30:00.000Z", - "vtadam.localhost.vitess.log.INFO.20200101-100000.00000": "2020-01-01T10:00:00.000Z", - "vtadam.localhost.vitess.log.INFO.20200101-090000.00000": "2020-01-01T09:00:00.000Z", - "vtadam.localhost.vitess.log.INFO.20200101-080000.00000": "2020-01-01T08:00:00.000Z", - } - for filename, mtimeStr := range filenameMtimeMap { - createFileWithMtime(filename, mtimeStr) - } - - // Create vtadam.INFO symlink to 100000. This is a contrived example in that - // current log (100000) is not the latest log (113000). This will not happen - // IRL but it helps us test edge cases of purging by mtime. - if err := os.Symlink("vtadam.localhost.vitess.log.INFO.20200101-100000.00000", path.Join(logDir, "vtadam.INFO")); err != nil { - require.NoError(t, err) - } - - purgeLogsOnce(now, logDir, "vtadam", 0, 1*time.Hour) - - left, err := filepath.Glob(path.Join(logDir, "vtadam.*")) - require.NoError(t, err) - - // 1. 113000 is within 1 hour - // 2. 100000 is current (vtadam.INFO) - // 3. vtadam.INFO symlink remains - // rest are removed - assert.Lenf(t, left, 3, "wrong number of files remain: want %v, got %v", 3, len(left)) -} diff --git a/go/vt/logutil/purge.go b/go/vt/logutil/purge.go deleted file mode 100644 index fb26b11f06e..00000000000 --- a/go/vt/logutil/purge.go +++ /dev/null @@ -1,136 +0,0 @@ -/* -Copyright 2019 The Vitess Authors. - -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, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package logutil - -import ( - "fmt" - "os" - "path" - "path/filepath" - "strings" - "time" - - "github.com/spf13/pflag" - - _flag "vitess.io/vitess/go/internal/flag" - "vitess.io/vitess/go/vt/utils" -) - -var ( - keepLogsByCtime time.Duration - keepLogsByMtime time.Duration - purgeLogsInterval = 1 * time.Hour -) - -// RegisterFlags installs logutil flags on the given FlagSet. -// -// `go/cmd/*` entrypoints should either use servenv.ParseFlags(WithArgs)? which -// calls this function, or call this function directly before parsing -// command-line arguments. -func RegisterFlags(fs *pflag.FlagSet) { - utils.SetFlagDurationVar(fs, &keepLogsByCtime, "keep-logs", keepLogsByCtime, "keep logs for this long (using ctime) (zero to keep forever)") - utils.SetFlagDurationVar(fs, &keepLogsByMtime, "keep-logs-by-mtime", keepLogsByMtime, "keep logs for this long (using mtime) (zero to keep forever)") - utils.SetFlagDurationVar(fs, &purgeLogsInterval, "purge-logs-interval", purgeLogsInterval, "how often try to remove old logs") -} - -// parse parses a file name (as used by glog) and returns its process -// name and timestamp. -func parseCreatedTimestamp(filename string) (timestamp time.Time, err error) { - parts := strings.Split(filepath.Base(filename), ".") - if len(parts) < 6 { - return time.Time{}, fmt.Errorf("malformed logfile name: %v", filename) - } - return time.ParseInLocation("20060102-150405", parts[len(parts)-2], time.Now().Location()) -} - -func getModifiedTimestamp(filename string) (timestamp time.Time, err error) { - fileInfo, err := os.Stat(filename) - if err != nil { - return time.Time{}, err - } - return fileInfo.ModTime(), nil -} - -var levels = []string{"INFO", "ERROR", "WARNING", "FATAL"} - -// purgeLogsOnce removes logfiles for program for dir, if their age -// relative to now is greater than [cm]timeDelta -func purgeLogsOnce(now time.Time, dir, program string, ctimeDelta time.Duration, mtimeDelta time.Duration) { - current := make(map[string]bool) - for _, level := range levels { - c, err := filepath.EvalSymlinks(path.Join(dir, fmt.Sprintf("%s.%s", program, level))) - if err != nil { - continue - } - current[c] = true - } - - files, err := filepath.Glob(path.Join(dir, program+".*")) - if err != nil { - return - } - for _, file := range files { - statInfo, err := os.Lstat(file) - if err != nil { - // Failed to stat file - continue - } - if current[file] || !statInfo.Mode().IsRegular() { - // Do not purge current file or any non-regular files (symlinks etc) - continue - } - purgeFile := false - if ctimeDelta != 0 { - createdTs, err := parseCreatedTimestamp(file) - if err != nil { - continue - } - purgeFile = purgeFile || now.Sub(createdTs) > ctimeDelta - } - if mtimeDelta != 0 { - modifiedTs, err := getModifiedTimestamp(file) - if err != nil { - continue - } - purgeFile = purgeFile || now.Sub(modifiedTs) > mtimeDelta - } - if purgeFile { - os.Remove(file) - } - } -} - -// PurgeLogs removes any log files that were started more than -// keepLogs ago and that aren't the current log. -func PurgeLogs() { - f := _flag.Lookup("log_dir") - if f == nil { - panic("the logging module doesn't specify a log_dir flag") - } - if keepLogsByCtime == 0 && keepLogsByMtime == 0 { - return - } - logDir := f.Value.String() - program := filepath.Base(os.Args[0]) - ticker := time.NewTicker(purgeLogsInterval) - - go func() { - for range ticker.C { - purgeLogsOnce(time.Now(), logDir, program, keepLogsByCtime, keepLogsByMtime) - } - }() -} diff --git a/go/vt/mysqlctl/azblobbackupstorage/azblob.go b/go/vt/mysqlctl/azblobbackupstorage/azblob.go index d00c4c9b3ac..1c4a3f9a870 100644 --- a/go/vt/mysqlctl/azblobbackupstorage/azblob.go +++ b/go/vt/mysqlctl/azblobbackupstorage/azblob.go @@ -23,6 +23,7 @@ import ( "errors" "fmt" "io" + "log/slog" "net/url" "os" "strings" @@ -184,17 +185,8 @@ func azServiceURL(credentials *azblob.SharedKeyCredential) azblob.ServiceURL { } }, ShouldLog: func(level pipeline.LogLevel) bool { - switch level { - case pipeline.LogFatal, pipeline.LogPanic: - return bool(log.V(3)) - case pipeline.LogError: - return bool(log.V(3)) - case pipeline.LogWarning: - return bool(log.V(2)) - case pipeline.LogInfo, pipeline.LogDebug: - return bool(log.V(1)) - } - return false + // Emit SDK logs only at debug level. The SDK logs a full request dump for each slow or failed try. + return level != pipeline.LogNone && log.Enabled(slog.LevelDebug) }, }, }) diff --git a/go/vt/servenv/flush_logutil.go b/go/vt/servenv/flush_logutil.go deleted file mode 100644 index bfe06a10a23..00000000000 --- a/go/vt/servenv/flush_logutil.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -Copyright 2019 The Vitess Authors. - -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, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package servenv - -import ( - "vitess.io/vitess/go/vt/logutil" -) - -func init() { - OnClose(logutil.Flush) -} diff --git a/go/vt/servenv/flushlogs.go b/go/vt/servenv/flushlogs.go index d3ba162249a..ce011f0b925 100644 --- a/go/vt/servenv/flushlogs.go +++ b/go/vt/servenv/flushlogs.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Vitess Authors. +Copyright 2026 The Vitess Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -20,14 +20,17 @@ import ( "fmt" "net/http" - "vitess.io/vitess/go/vt/logutil" + "vitess.io/vitess/go/vt/log" ) +// init registers the deprecated /debug/flushlogs endpoint. v24 did not show a deprecation warning for it, so it +// stays as a no-op until v26. func init() { - OnInit(func() { - HTTPHandleFunc("/debug/flushlogs", func(w http.ResponseWriter, r *http.Request) { - logutil.Flush() - fmt.Fprint(w, "flushed") - }) - }) + HTTPHandleFunc("/debug/flushlogs", flushLogs) +} + +// flushLogs responds with success and logs a deprecation warning. The logger writes each record immediately. +func flushLogs(w http.ResponseWriter, _ *http.Request) { + log.Warn("/debug/flushlogs is deprecated, it has no effect and will be removed in v26") + fmt.Fprint(w, "flushed") } diff --git a/go/vt/servenv/flushlogs_test.go b/go/vt/servenv/flushlogs_test.go new file mode 100644 index 00000000000..7b68d718c09 --- /dev/null +++ b/go/vt/servenv/flushlogs_test.go @@ -0,0 +1,47 @@ +/* +Copyright 2026 The Vitess Authors. + +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, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package servenv + +import ( + "io" + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "vitess.io/vitess/go/vt/servenv/testutils" +) + +// TestFlushLogsHandler checks that the deprecated /debug/flushlogs endpoint still responds with success. +func TestFlushLogsHandler(t *testing.T) { + server := testutils.HTTPTestServer() + t.Cleanup(server.Close) + + req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, server.URL+"/debug/flushlogs", nil) + require.NoError(t, err) + + resp, err := http.DefaultClient.Do(req) + require.NoError(t, err) + t.Cleanup(func() { resp.Body.Close() }) + + body, err := io.ReadAll(resp.Body) + require.NoError(t, err) + + assert.Equal(t, http.StatusOK, resp.StatusCode) + assert.Equal(t, "flushed", string(body)) +} diff --git a/go/vt/servenv/servenv.go b/go/vt/servenv/servenv.go index e438b544520..d3d812d2088 100644 --- a/go/vt/servenv/servenv.go +++ b/go/vt/servenv/servenv.go @@ -29,7 +29,6 @@ limitations under the License. package servenv import ( - "flag" "fmt" "net/url" "os" @@ -48,7 +47,6 @@ import ( viperdebug "vitess.io/vitess/go/viperutil/debug" "vitess.io/vitess/go/vt/grpccommon" "vitess.io/vitess/go/vt/log" - "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/utils" "vitess.io/vitess/go/vt/vterrors" @@ -193,7 +191,6 @@ func fireOnCloseHooks(timeout time.Duration) bool { // fireHooksWithTimeout returns true iff all the hooks finish before the timeout. func fireHooksWithTimeout(timeout time.Duration, name string, hookFn func()) bool { - defer log.Flush() log.Info(fmt.Sprintf("Firing %s hooks and waiting up to %v for them", name, timeout)) timer := time.NewTimer(timeout) @@ -307,7 +304,7 @@ func ParseFlags(cmd string) { _flag.Parse(fs) - if err := log.Init(fs); err != nil { + if err := log.Init(); err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) os.Exit(1) } @@ -325,8 +322,6 @@ func ParseFlags(cmd string) { } loadViper(cmd) - - logutil.PurgeLogs() } // ParseFlagsForTests initializes flags but skips the version, filesystem @@ -341,16 +336,14 @@ func ParseFlagsForTests(cmd string) { } // MoveFlagsToCobraCommand moves the servenv-registered flags to the flagset of -// the given cobra command, then copies over the glog flags that otherwise -// require manual transferring. +// the given cobra command. func MoveFlagsToCobraCommand(cmd *cobra.Command) { moveFlags(cmd.Name(), cmd.Flags()) } // MovePersistentFlagsToCobraCommand functions exactly like MoveFlagsToCobraCommand, // but moves the servenv-registered flags to the persistent flagset of -// the given cobra command, then copies over the glog flags that otherwise -// require manual transferring. +// the given cobra command. // // Useful for transferring flags to a parent command whose subcommands should // inherit the servenv-registered flags. @@ -361,26 +354,6 @@ func MovePersistentFlagsToCobraCommand(cmd *cobra.Command) { func moveFlags(name string, fs *pflag.FlagSet) { fs.AddFlagSet(GetFlagSetFor(name)) - // glog flags, no better way to do this - _flag.PreventGlogVFlagFromClobberingVersionFlagShorthand(fs) - fs.AddGoFlag(flag.Lookup("logtostderr")) - fs.AddGoFlag(flag.Lookup("log_backtrace_at")) - fs.AddGoFlag(flag.Lookup("alsologtostderr")) - fs.AddGoFlag(flag.Lookup("stderrthreshold")) - fs.AddGoFlag(flag.Lookup("log_dir")) - fs.AddGoFlag(flag.Lookup("vmodule")) - - // glog is deprecated in favor of structured logging (--log-structured). - // These flags will be removed in v25. - const deprecationMsg = "glog and its flags have been deprecated, use the default structured logging instead (\"--log-structured\")" - _ = fs.MarkDeprecated("logtostderr", deprecationMsg) - _ = fs.MarkDeprecated("log_backtrace_at", deprecationMsg) - _ = fs.MarkDeprecated("alsologtostderr", deprecationMsg) - _ = fs.MarkDeprecated("stderrthreshold", deprecationMsg) - _ = fs.MarkDeprecated("log_dir", deprecationMsg) - _ = fs.MarkDeprecated("vmodule", deprecationMsg) - _ = fs.MarkDeprecated("v", deprecationMsg) - pflag.CommandLine = fs } @@ -388,9 +361,7 @@ func moveFlags(name string, fs *pflag.FlagSet) { // viper infrastructure. It matches the signature of cobra's (Pre|Post)RunE-type // functions. func CobraPreRunE(cmd *cobra.Command, args []string) error { - _flag.TrickGlog() - - if err := log.Init(cmd.Flags()); err != nil { + if err := log.Init(); err != nil { return err } @@ -415,8 +386,6 @@ func CobraPreRunE(cmd *cobra.Command, args []string) error { OnTerm(func() { close(ch) }) HTTPHandleFunc("/debug/config", viperdebug.HandlerFunc) - logutil.PurgeLogs() - return nil } @@ -439,7 +408,7 @@ func ParseFlagsWithArgs(cmd string) []string { _flag.Parse(fs) - if err := log.Init(fs); err != nil { + if err := log.Init(); err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) os.Exit(1) } @@ -457,8 +426,6 @@ func ParseFlagsWithArgs(cmd string) []string { loadViper(cmd) - logutil.PurgeLogs() - return args } @@ -522,8 +489,6 @@ func init() { // Flags in package log are installed for all binaries. OnParse(log.RegisterFlags) - // Flags in package logutil are installed for all binaries. - OnParse(logutil.RegisterFlags) // Flags in package viperutil/config are installed for all binaries. OnParse(viperutil.RegisterFlags) } diff --git a/go/vt/topotools/mirror_rules.go b/go/vt/topotools/mirror_rules.go index 32572b6e1df..89ce5d0ea60 100644 --- a/go/vt/topotools/mirror_rules.go +++ b/go/vt/topotools/mirror_rules.go @@ -56,7 +56,7 @@ func GetMirrorRules(ctx context.Context, ts *topo.Server) (map[string]map[string // SaveMirrorRules converts a mapping of fromTable=>[]toTables into a // vschemapb.MirrorRules protobuf message and saves it in the topology. func SaveMirrorRules(ctx context.Context, ts *topo.Server, rules map[string]map[string]float32) error { - log.V(2).Info(fmt.Sprintf("Saving mirror rules %v\n", rules)) + log.Debug(fmt.Sprintf("Saving mirror rules %v", rules)) rrs := &vschemapb.MirrorRules{Rules: make([]*vschemapb.MirrorRule, 0)} for fromTable, mrs := range rules { diff --git a/go/vt/utils/flags.go b/go/vt/utils/flags.go index 3eb527b151c..5d72e5974a7 100644 --- a/go/vt/utils/flags.go +++ b/go/vt/utils/flags.go @@ -99,11 +99,6 @@ var deprecationWarningsEmitted = make(map[string]bool) // Translate flag names from underscores to dashes and print a deprecation warning. func NormalizeUnderscoresToDashes(f *pflag.FlagSet, name string) pflag.NormalizedName { - // `log_dir`, `log_link` and `log_backtrace_at` are exceptions because they are used by glog. - if name == "log_dir" || name == "log_link" || name == "log_backtrace_at" { - return pflag.NormalizedName(name) - } - // We only want to normalize flags that purely use underscores. if !strings.Contains(name, "_") || strings.Contains(name, "-") { return pflag.NormalizedName(name) diff --git a/go/vt/vtgate/buffer/buffer.go b/go/vt/vtgate/buffer/buffer.go index b2bd872040e..bc65114737b 100644 --- a/go/vt/vtgate/buffer/buffer.go +++ b/go/vt/vtgate/buffer/buffer.go @@ -88,7 +88,7 @@ func init() { // To simplify things, we've merged the detection for different MySQL flavors // in one function. Supported flavors: MariaDB, MySQL func CausedByFailover(err error) bool { - log.V(2).Info(fmt.Sprintf("Checking error (type: %T) if it is caused by a failover. err: %v", err, err)) + log.Debug(fmt.Sprintf("Checking error (type: %T) if it is caused by a failover. err: %v", err, err)) reason, isFailover := isFailoverError(err) if isFailover { log.Info("CausedByFailover signalling failover for reason: " + reason) diff --git a/go/vt/vtgate/buffer/shard_buffer.go b/go/vt/vtgate/buffer/shard_buffer.go index 814f1ac6aac..7b83addbf44 100644 --- a/go/vt/vtgate/buffer/shard_buffer.go +++ b/go/vt/vtgate/buffer/shard_buffer.go @@ -518,7 +518,7 @@ func (sb *shardBuffer) recordKeyspaceEvent(alias *topodatapb.TabletAlias, stillS sb.mu.Lock() defer sb.mu.Unlock() - log.V(2).Info(fmt.Sprintf("disruption in shard %s/%s resolved (serving: %v), movetable state %#v", sb.keyspace, sb.shard, stillServing, keyspaceEvent.MoveTablesState)) + log.Debug(fmt.Sprintf("disruption in shard %s/%s resolved (serving: %v), movetable state %#v", sb.keyspace, sb.shard, stillServing, keyspaceEvent.MoveTablesState)) if !topoproto.TabletAliasEqual(alias, sb.currentPrimary) { if sb.currentPrimary != nil { diff --git a/go/vt/vtgate/plan_execute.go b/go/vt/vtgate/plan_execute.go index 5f17eb2bb6e..b2f1ca3c021 100644 --- a/go/vt/vtgate/plan_execute.go +++ b/go/vt/vtgate/plan_execute.go @@ -188,7 +188,7 @@ func (e *Executor) newExecute( // Retry if needed. rootCause := vterrors.RootCause(err) if rootCause != nil && strings.Contains(rootCause.Error(), "enforce denied tables") { - log.V(2).Info(fmt.Sprintf("Retry: %d, will retry query %s due to %v", try, sql, err)) + log.Debug(fmt.Sprintf("Retry: %d, will retry query %s due to %v", try, sql, err)) if try == 0 { // We are going to retry at least once defer func() { // Prevent any plan cache pollution from queries planned against the wrong keyspace during a MoveTables diff --git a/go/vt/vtgate/plugin_mysql_server.go b/go/vt/vtgate/plugin_mysql_server.go index 66649273116..25d148fe87c 100644 --- a/go/vt/vtgate/plugin_mysql_server.go +++ b/go/vt/vtgate/plugin_mysql_server.go @@ -2081,7 +2081,6 @@ func stopListener(listener *mysql.Listener, shutdown bool) { } func (srv *mysqlServer) rollbackAtShutdown() { - defer log.Flush() if srv.vtgateHandle == nil { // we still haven't been able to initialise the vtgateHandler, so we don't need to rollback anything return diff --git a/go/vt/vtgate/tabletgateway.go b/go/vt/vtgate/tabletgateway.go index 856dcf741ae..e3d15f84d67 100644 --- a/go/vt/vtgate/tabletgateway.go +++ b/go/vt/vtgate/tabletgateway.go @@ -394,7 +394,7 @@ func (gw *TabletGateway) withRetry(ctx context.Context, target *querypb.Target, // replica queries, so it doesn't make any sense to check for resharding or reparenting in that case. if kev := gw.kev; kev != nil && target.TabletType == topodatapb.TabletType_PRIMARY { if kev.TargetIsBeingResharded(ctx, target) { - log.V(2).Info(fmt.Sprintf("current keyspace is being resharded, retrying: %s: %s", target.Keyspace, debug.Stack())) + log.Debug(fmt.Sprintf("current keyspace is being resharded, retrying: %s: %s", target.Keyspace, debug.Stack())) err = vterrors.Errorf(vtrpcpb.Code_CLUSTER_EVENT, buffer.ClusterEventReshardingInProgress) continue } diff --git a/go/vt/vtgate/temp_table_refresh.go b/go/vt/vtgate/temp_table_refresh.go index 697004df96f..eec7e053845 100644 --- a/go/vt/vtgate/temp_table_refresh.go +++ b/go/vt/vtgate/temp_table_refresh.go @@ -300,7 +300,7 @@ func (r *tempTableActivityRefresher) refresh(ctx context.Context, t tempTableRef _, err = qs.Execute(ctx, nil, t.target, tempTableActivityRefreshQuery, nil, 0 /* transactionID */, t.reservedID, nil /* options */) } if err != nil { - log.V(2).Info("temp-table activity refresh failed", + log.Debug("temp-table activity refresh failed", slog.Int64("reserved_id", t.reservedID), slog.Any("error", err)) } diff --git a/go/vt/vtorc/logic/topology_recovery_test.go b/go/vt/vtorc/logic/topology_recovery_test.go index 831eec3520b..f7ba0f7525f 100644 --- a/go/vt/vtorc/logic/topology_recovery_test.go +++ b/go/vt/vtorc/logic/topology_recovery_test.go @@ -909,7 +909,6 @@ func TestRecoverIncapacitatedPrimary(t *testing.T) { close(done) }() restoreStderr = func() { - log.Flush() _ = w.Close() os.Stderr = oldStderr _ = unix.Dup2(oldFD, int(os.Stderr.Fd())) @@ -1069,7 +1068,6 @@ func TestRecoverIncapacitatedPrimary(t *testing.T) { attempted, topologyRecovery, err := recoverIncapacitatedPrimary(t.Context(), &analysis, logger) if restoreStderr != nil { - log.Flush() require.Eventually(t, func() bool { err := db.QueryVTOrc("select message from topology_recovery_steps where message like 'ERS - %'", nil, func(_ sqlutils.RowMap) error { return nil diff --git a/go/vt/vttablet/tabletmanager/rpc_vreplication_test.go b/go/vt/vttablet/tabletmanager/rpc_vreplication_test.go index 484cfa91c32..28e4b691837 100644 --- a/go/vt/vttablet/tabletmanager/rpc_vreplication_test.go +++ b/go/vt/vttablet/tabletmanager/rpc_vreplication_test.go @@ -1086,7 +1086,6 @@ func TestUpdateVReplicationWorkflow(t *testing.T) { defer func() { if err := recover(); err != nil { log.Info(fmt.Sprintf("Got panic in test: %v", err)) - log.Flush() require.Failf(t, "panic in test", "Recovered from panic: %v, stack: %s", err, debug.Stack()) } }() diff --git a/go/vt/vttablet/tabletmanager/vreplication/vplayer.go b/go/vt/vttablet/tabletmanager/vreplication/vplayer.go index d6634882b01..598c2746323 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/vplayer.go +++ b/go/vt/vttablet/tabletmanager/vreplication/vplayer.go @@ -146,7 +146,7 @@ func newVPlayer(vr *vreplicator, settings binlogplayer.VRSettings, copyState map saveStop = false } log.Info(fmt.Sprintf("Starting VReplication player id: %v, name: %v, startPos: %v, stop: %v", vr.id, vr.WorkflowName, settings.StartPos, settings.StopPos)) - log.V(2).Info(fmt.Sprintf("Starting VReplication player id: %v, startPos: %v, stop: %v, filter: %+v", vr.id, settings.StartPos, settings.StopPos, vr.source.Filter)) + log.Debug(fmt.Sprintf("Starting VReplication player id: %v, startPos: %v, stop: %v, filter: %+v", vr.id, settings.StartPos, settings.StopPos, vr.source.Filter)) queryFunc := func(ctx context.Context, sql string) (*sqltypes.Result, error) { return vr.dbClient.ExecuteWithRetry(ctx, sql) } diff --git a/go/vt/vttablet/tabletmanager/vreplication/vplayer_flaky_test.go b/go/vt/vttablet/tabletmanager/vreplication/vplayer_flaky_test.go index 70fe79ee40a..3a0afe3d62b 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/vplayer_flaky_test.go +++ b/go/vt/vttablet/tabletmanager/vreplication/vplayer_flaky_test.go @@ -4169,7 +4169,6 @@ func TestPlayerStalls(t *testing.T) { // The log message is written asynchronously after the stalled // workflow transitions to the error state, so poll for it. require.EventuallyWithT(t, func(c *assert.CollectT) { - log.Flush() assert.Contains(c, logger.String(), relayLogIOStalledMsg) }, 30*time.Second, 100*time.Millisecond, "expected log message not found") execStatements(t, []string{"set @@session.binlog_format='ROW'"}) @@ -4209,7 +4208,6 @@ func TestPlayerStalls(t *testing.T) { // locks held by the preFunc connection, rather than sleeping a // fixed multiple of the heartbeat interval. require.EventuallyWithT(t, func(c *assert.CollectT) { - log.Flush() assert.Contains(c, logger.String(), failedToRecordHeartbeatMsg) }, 30*time.Second, 100*time.Millisecond, "expected log message not found") // The vplayer also records the failure in the vreplication @@ -4414,7 +4412,6 @@ func TestPlayerNoStallWhileThrottled(t *testing.T) { // denial handoff to the relay log, the stall fires within // vplayerProgressDeadline and errors the stream. time.Sleep(3 * vplayerProgressDeadline) - log.Flush() require.NotContains(t, logger.String(), relayLogIOStalledMsg, "the stall detector fired while the vplayer was throttled") @@ -4435,6 +4432,5 @@ func TestPlayerNoStallWhileThrottled(t *testing.T) { require.Len(c, res.Rows, 1) assert.Equal(c, "3", res.Rows[0][0].ToString()) }, 30*time.Second, 100*time.Millisecond, "the queued rows were not applied after the throttler allowed again") - log.Flush() require.NotContains(t, logger.String(), relayLogIOStalledMsg) } diff --git a/go/vt/vttablet/tabletserver/schema/engine.go b/go/vt/vttablet/tabletserver/schema/engine.go index 05b00d389ce..1e52d4703da 100644 --- a/go/vt/vttablet/tabletserver/schema/engine.go +++ b/go/vt/vttablet/tabletserver/schema/engine.go @@ -397,7 +397,7 @@ func (se *Engine) ReloadAtEx(ctx context.Context, pos replication.Position, incl return nil } if !pos.IsZero() && se.reloadAtPos.AtLeast(pos) { - log.V(2).Info("ReloadAtEx: found cached schema at " + replication.EncodePosition(pos)) + log.Debug("ReloadAtEx: found cached schema at " + replication.EncodePosition(pos)) return nil } if err := se.reload(ctx, includeStats); err != nil { @@ -588,7 +588,7 @@ func (se *Engine) reload(ctx context.Context, includeStats bool) error { continue } - log.V(2).Info("Reading schema for table: " + tableName) + log.Debug("Reading schema for table: " + tableName) tableType := row[1].String() table, err := LoadTable(conn, se.cp.DBName(), tableName, tableType, row[3].ToString(), se.env.Environment().CollationEnv(), se.env.Config().TrackSchemaVersions) diff --git a/go/vt/vttablet/tabletserver/schema/historian.go b/go/vt/vttablet/tabletserver/schema/historian.go index 22128a6a6c7..588ae7563a0 100644 --- a/go/vt/vttablet/tabletserver/schema/historian.go +++ b/go/vt/vttablet/tabletserver/schema/historian.go @@ -39,9 +39,6 @@ const ( getNextSchemaVersions = "select id, pos, ddl, time_updated, schemax from %s.schema_version where id > %d order by id asc" ) -// vl defines the glog verbosity level for the package -const vl = 10 - // trackedSchema has the snapshot of the table at a given pos (reached by ddl) type trackedSchema struct { schema map[string]*binlogdatapb.MinimalTable @@ -257,7 +254,7 @@ func (h *historian) readRow(row []sqltypes.Value) (*trackedSchema, int64, error) if err := sch.UnmarshalVT(rowBytes); err != nil { return nil, 0, err } - log.V(vl).Info(fmt.Sprintf("Read tracked schema from db: id %d, pos %v, ddl %s, schema len %d, time_updated %d \n", id, replication.EncodePosition(pos), ddl, len(sch.Tables), timeUpdated)) + log.Debug(fmt.Sprintf("Read tracked schema from db: id %d, pos %v, ddl %s, schema len %d, time_updated %d", id, replication.EncodePosition(pos), ddl, len(sch.Tables), timeUpdated)) tables := map[string]*binlogdatapb.MinimalTable{} for _, t := range sch.Tables { diff --git a/go/vt/vttablet/tabletserver/vstreamer/copy.go b/go/vt/vttablet/tabletserver/vstreamer/copy.go index 7fe6c5c4412..719e84d4a74 100644 --- a/go/vt/vttablet/tabletserver/vstreamer/copy.go +++ b/go/vt/vttablet/tabletserver/vstreamer/copy.go @@ -36,7 +36,7 @@ import ( func (uvs *uvstreamer) copy(ctx context.Context) error { for len(uvs.tablesToCopy) > 0 { tableName := uvs.tablesToCopy[0] - log.V(2).Info("Copystate not empty starting catchupAndCopy on table " + tableName) + log.Debug("Copystate not empty starting catchupAndCopy on table " + tableName) if err := uvs.catchupAndCopy(ctx, tableName); err != nil { uvs.vse.errorCounts.Add("Copy", 1) return err @@ -118,7 +118,7 @@ func (uvs *uvstreamer) sendFieldEvent(ctx context.Context, gtid string, fieldEve Type: binlogdatapb.VEventType_FIELD, FieldEvent: fieldEvent, }} - log.V(2).Info(fmt.Sprintf("Sending field event %v, gtid is %s", fieldEvent, gtid)) + log.Debug(fmt.Sprintf("Sending field event %v, gtid is %s", fieldEvent, gtid)) uvs.send(evs) if err := uvs.setPosition(gtid, true); err != nil { @@ -242,7 +242,7 @@ func (uvs *uvstreamer) copyTable(ctx context.Context, tableName string) error { return err } } else { - log.V(2).Info(fmt.Sprintf("Not starting fastforward pos is %s, uvs.pos is %s, rows.gtid %s", pos, uvs.pos, rows.Gtid)) + log.Debug(fmt.Sprintf("Not starting fastforward pos is %s, uvs.pos is %s, rows.gtid %s", pos, uvs.pos, rows.Gtid)) } // Store a copy of the fields and pkfields because the original will be cleared @@ -276,7 +276,7 @@ func (uvs *uvstreamer) copyTable(ctx context.Context, tableName string) error { } if len(rows.Rows) == 0 { - log.V(2).Info("0 rows returned for table " + tableName) + log.Debug("0 rows returned for table " + tableName) return nil } @@ -296,7 +296,7 @@ func (uvs *uvstreamer) copyTable(ctx context.Context, tableName string) error { Rows: []*querypb.Row{rows.Lastpk.CloneVT()}, }) qrLastPK := sqltypes.ResultToProto3(newLastPK) - log.V(2).Info("Calling sendEventForRows with gtid " + rows.Gtid) + log.Debug("Calling sendEventForRows with gtid " + rows.Gtid) if err := uvs.sendEventsForRows(ctx, tableName, rows, qrLastPK); err != nil { log.Info(fmt.Sprintf("sendEventsForRows returned error %v", err)) return err @@ -305,7 +305,7 @@ func (uvs *uvstreamer) copyTable(ctx context.Context, tableName string) error { uvs.inTransaction = false uvs.setCopyState(tableName, qrLastPK) - log.V(2).Info(fmt.Sprintf("NewLastPK: %v", qrLastPK)) + log.Debug(fmt.Sprintf("NewLastPK: %v", qrLastPK)) return nil }, uvs.options) if err != nil { diff --git a/go/vt/vttablet/tabletserver/vstreamer/engine.go b/go/vt/vttablet/tabletserver/vstreamer/engine.go index 813342a5fb7..f4719fc7769 100644 --- a/go/vt/vttablet/tabletserver/vstreamer/engine.go +++ b/go/vt/vttablet/tabletserver/vstreamer/engine.go @@ -469,7 +469,7 @@ func (vse *Engine) setWatch() { vschema: vschema, } b, _ := json.MarshalIndent(vschema, "", " ") - log.V(2).Info(fmt.Sprintf("Updated vschema: %s", b)) + log.Debug(fmt.Sprintf("Updated vschema: %s", b)) for _, s := range vse.streamers { s.SetVSchema(vse.lvschema) } diff --git a/go/vtbench/vtbench.go b/go/vtbench/vtbench.go index 7f079635d84..bf3c45963ee 100644 --- a/go/vtbench/vtbench.go +++ b/go/vtbench/vtbench.go @@ -134,7 +134,7 @@ func (b *Bench) Run(ctx context.Context) error { } func (b *Bench) createConns(ctx context.Context) error { - log.V(10).Info(fmt.Sprintf("creating %d client connections...", b.Threads)) + log.Debug(fmt.Sprintf("creating %d client connections...", b.Threads)) start := time.Now() reportInterval := 2 * time.Second report := start.Add(reportInterval) @@ -148,15 +148,15 @@ func (b *Bench) createConns(ctx context.Context) error { switch b.ConnParams.Protocol { case MySQL: - log.V(5).Info(fmt.Sprintf("connecting to %s using mysql protocol...", host)) + log.Debug(fmt.Sprintf("connecting to %s using mysql protocol...", host)) conn = &mysqlClientConn{} err = conn.connect(ctx, cp) case GRPCVtgate: - log.V(5).Info(fmt.Sprintf("connecting to %s using grpc vtgate protocol...", host)) + log.Debug(fmt.Sprintf("connecting to %s using grpc vtgate protocol...", host)) conn = &grpcVtgateConn{} err = conn.connect(ctx, cp) case GRPCVttablet: - log.V(5).Info(fmt.Sprintf("connecting to %s using grpc vttablet protocol...", host)) + log.Debug(fmt.Sprintf("connecting to %s using grpc vttablet protocol...", host)) conn = &grpcVttabletConn{} err = conn.connect(ctx, cp) default: @@ -196,13 +196,13 @@ func (b *Bench) createThreads(ctx context.Context) { // Create a barrier so all the threads start at the same time b.lock.Lock() - log.V(10).Info(fmt.Sprintf("starting %d threads", b.Threads)) + log.Debug(fmt.Sprintf("starting %d threads", b.Threads)) for i := 0; i < b.Threads; i++ { b.wg.Add(1) go b.threads[i].clientLoop(ctx) } - log.V(10).Info(fmt.Sprintf("waiting for %d threads to start", b.Threads)) + log.Debug(fmt.Sprintf("waiting for %d threads to start", b.Threads)) b.wg.Wait() b.wg.Add(b.Threads) @@ -214,7 +214,7 @@ func (b *Bench) runTest(ctx context.Context) error { b.lock.Unlock() // Then wait for them all to finish looping - log.V(10).Info(fmt.Sprintf("waiting for %d threads to finish", b.Threads)) + log.Debug(fmt.Sprintf("waiting for %d threads to finish", b.Threads)) b.wg.Wait() b.TotalTime = time.Since(start) @@ -227,9 +227,9 @@ func (bt *benchThread) clientLoop(ctx context.Context) { // Declare that startup is finished and wait for // the barrier b.wg.Done() - log.V(10).Info(fmt.Sprintf("thread %d waiting for startup barrier", bt.i)) + log.Debug(fmt.Sprintf("thread %d waiting for startup barrier", bt.i)) b.lock.RLock() - log.V(10).Info(fmt.Sprintf("thread %d starting loop", bt.i)) + log.Debug(fmt.Sprintf("thread %d starting loop", bt.i)) for i := 0; i < b.Count; i++ { // Enforce the deadline across all protocols, even if execute() @@ -243,7 +243,7 @@ func (bt *benchThread) clientLoop(ctx context.Context) { if err != nil { b.Errors.Add(errorCode(err).String(), 1) if b.ContinueOnError && ctx.Err() == nil { - log.V(1).Info(fmt.Sprintf("query error: %v", err)) + log.Debug(fmt.Sprintf("query error: %v", err)) continue } log.Error(fmt.Sprintf("query error: %v", err)) diff --git a/java/grpc-client/src/test/java/io/client/grpc/GrpcClientStaticAuthTest.java b/java/grpc-client/src/test/java/io/client/grpc/GrpcClientStaticAuthTest.java index 59102025291..a3ddf20f5cd 100644 --- a/java/grpc-client/src/test/java/io/client/grpc/GrpcClientStaticAuthTest.java +++ b/java/grpc-client/src/test/java/io/client/grpc/GrpcClientStaticAuthTest.java @@ -62,7 +62,6 @@ public static void setUpBeforeClass() throws Exception { vtgateclienttest = new ProcessBuilder(Arrays.asList( vtRoot + "/bin/vtgateclienttest", - "--logtostderr", "--grpc-port", Integer.toString(port), "--service-map", "grpc-vtgateservice", "--grpc-auth-mode", "static", diff --git a/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTest.java b/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTest.java index 1ff1bba9448..fc70689a883 100644 --- a/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTest.java +++ b/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTest.java @@ -54,7 +54,6 @@ public static void setUpBeforeClass() throws Exception { new ProcessBuilder( Arrays.asList( vtRoot + "/bin/vtgateclienttest", - "--logtostderr", "--grpc-port", Integer.toString(port), "--service-map", diff --git a/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTlsClientAuthTest.java b/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTlsClientAuthTest.java index bdc9e7e38ae..ab4f22bc7ac 100644 --- a/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTlsClientAuthTest.java +++ b/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTlsClientAuthTest.java @@ -173,7 +173,7 @@ private static void startVtgate() throws Exception { final String key = certDirectory.getCanonicalPath() + File.separatorChar + "server-key.pem"; final String vtgateCommand = String.format( - "%s --grpc-cert %s --grpc-key %s --grpc-ca %s --logtostderr --grpc-port %s --service-map grpc-vtgateservice", + "%s --grpc-cert %s --grpc-key %s --grpc-ca %s --grpc-port %s --service-map grpc-vtgateservice", vtRoot + "/bin/vtgateclienttest", cert, key, caCert, Integer.toString(port)); System.out.println(vtgateCommand); vtgateclienttest = new ProcessBuilder(vtgateCommand.split(" ")).inheritIO().start(); diff --git a/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTlsTest.java b/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTlsTest.java index 1d96c73be1c..9d21f1aa3d3 100644 --- a/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTlsTest.java +++ b/java/grpc-client/src/test/java/io/client/grpc/GrpcClientTlsTest.java @@ -153,7 +153,7 @@ private static void startVtgate() throws Exception { final String key = certDirectory.getCanonicalPath() + File.separatorChar + "server-key.pem"; final String vtgate = String.format( - "%s --grpc-cert %s --grpc-key %s --logtostderr --grpc-port %s --service-map grpc-vtgateservice", + "%s --grpc-cert %s --grpc-key %s --grpc-port %s --service-map grpc-vtgateservice", vtRoot + "/bin/vtgateclienttest", cert, key, diff --git a/java/grpc-client/src/test/java/io/client/grpc/GrpcClientWithRetriesTest.java b/java/grpc-client/src/test/java/io/client/grpc/GrpcClientWithRetriesTest.java index 29420ff37f3..519a3a4a20a 100644 --- a/java/grpc-client/src/test/java/io/client/grpc/GrpcClientWithRetriesTest.java +++ b/java/grpc-client/src/test/java/io/client/grpc/GrpcClientWithRetriesTest.java @@ -49,7 +49,6 @@ public static void setUpBeforeClass() throws Exception { new ProcessBuilder( Arrays.asList( vtRoot + "/bin/vtgateclienttest", - "--logtostderr", "--grpc-port", Integer.toString(port), "--service-map", diff --git a/tools/rowlog/rowlog.go b/tools/rowlog/rowlog.go index f5f76cbd904..d6ee9043515 100644 --- a/tools/rowlog/rowlog.go +++ b/tools/rowlog/rowlog.go @@ -19,7 +19,6 @@ package main import ( "context" "encoding/json" - "flag" "fmt" "io" "os" @@ -423,17 +422,9 @@ func getTablet(ctx context.Context, ts *topo.Server, cells []string, keyspace st return tabletId } -func trickGlog() { - var args []string - os.Args, args = os.Args[:1], os.Args[1:] - defer func() { os.Args = append(os.Args, args...) }() - flag.Parse() -} - var testResumability bool func parseCommandLine() *RowLogConfig { - trickGlog() sourceKeyspace := pflag.StringP("source", "s", "", "") targetKeyspace := pflag.StringP("target", "t", "", "") ids := pflag.StringSlice("ids", nil, "")