From 7a8ff7d8144bea2d5df9d0886c2fe3385ea2f99c Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 19 Dec 2024 01:05:39 -0500 Subject: [PATCH] [release-20.0] parse transaction timeout as duration (#16338) (#17405) Signed-off-by: shanth96 Co-authored-by: shanth96 --- go/cmd/vttestserver/cli/main.go | 2 +- go/flags/endtoend/vttestserver.txt | 2 +- go/vt/vttest/local_cluster.go | 2 +- go/vt/vttest/vtprocess.go | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/go/cmd/vttestserver/cli/main.go b/go/cmd/vttestserver/cli/main.go index 5601623b2fa..479ea4441f8 100644 --- a/go/cmd/vttestserver/cli/main.go +++ b/go/cmd/vttestserver/cli/main.go @@ -206,7 +206,7 @@ func New() (cmd *cobra.Command) { cmd.Flags().BoolVar(&config.EnableSystemSettings, "enable_system_settings", true, "This will enable the system settings to be changed per session at the database connection level") cmd.Flags().StringVar(&config.TransactionMode, "transaction_mode", "MULTI", "Transaction mode MULTI (default), SINGLE or TWOPC ") - cmd.Flags().Float64Var(&config.TransactionTimeout, "queryserver-config-transaction-timeout", 0, "query server transaction timeout (in seconds), a transaction will be killed if it takes longer than this value") + cmd.Flags().DurationVar(&config.TransactionTimeout, "queryserver-config-transaction-timeout", 30*time.Second, "query server transaction timeout, a transaction will be killed if it takes longer than this value") cmd.Flags().StringVar(&config.TabletHostName, "tablet_hostname", "localhost", "The hostname to use for the tablet otherwise it will be derived from OS' hostname") diff --git a/go/flags/endtoend/vttestserver.txt b/go/flags/endtoend/vttestserver.txt index 8cce76afc65..95c69714e59 100644 --- a/go/flags/endtoend/vttestserver.txt +++ b/go/flags/endtoend/vttestserver.txt @@ -106,7 +106,7 @@ Flags: --pprof-http enable pprof http endpoints --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 float query server transaction timeout (in seconds), a transaction will be killed if it takes longer than this value + --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) --replication_connect_retry duration how long to wait in between replica reconnect attempts. Only precise to the second. (default 10s) diff --git a/go/vt/vttest/local_cluster.go b/go/vt/vttest/local_cluster.go index 3c65f7de1eb..406269ef749 100644 --- a/go/vt/vttest/local_cluster.go +++ b/go/vt/vttest/local_cluster.go @@ -128,7 +128,7 @@ type Config struct { // TransactionMode is SINGLE, MULTI or TWOPC TransactionMode string - TransactionTimeout float64 + TransactionTimeout time.Duration // The host name to use for the table otherwise it will be resolved from the local hostname TabletHostName string diff --git a/go/vt/vttest/vtprocess.go b/go/vt/vttest/vtprocess.go index 2d2c9116c6d..3f34994bb75 100644 --- a/go/vt/vttest/vtprocess.go +++ b/go/vt/vttest/vtprocess.go @@ -188,7 +188,6 @@ var QueryServerArgs = []string{ "--queryserver-config-schema-reload-time", "60s", "--queryserver-config-stream-pool-size", "4", "--queryserver-config-transaction-cap", "4", - "--queryserver-config-transaction-timeout", "300s", "--queryserver-config-txpool-timeout", "300s", } @@ -260,7 +259,7 @@ func VtcomboProcess(environment Environment, args *Config, mysql MySQLManager) ( vt.ExtraArgs = append(vt.ExtraArgs, []string{"--transaction_mode", args.TransactionMode}...) } if args.TransactionTimeout != 0 { - vt.ExtraArgs = append(vt.ExtraArgs, "--queryserver-config-transaction-timeout", fmt.Sprintf("%f", args.TransactionTimeout)) + vt.ExtraArgs = append(vt.ExtraArgs, "--queryserver-config-transaction-timeout", fmt.Sprintf("%v", args.TransactionTimeout)) } if args.TabletHostName != "" { vt.ExtraArgs = append(vt.ExtraArgs, []string{"--tablet_hostname", args.TabletHostName}...)