From a6ab8a21c52fb578faf5d61bf4bb11c351a03a4f Mon Sep 17 00:00:00 2001 From: Rameez Sajwani Date: Mon, 19 Dec 2022 10:06:16 -0800 Subject: [PATCH] vttestserver: make tablet_refresh_interval configurable and reduce default value (#11918) * setting up refresh_interval and check_leader_interval Signed-off-by: Rameez Sajwani * setting default value, if not provided Signed-off-by: Rameez Sajwani * fixing vttablet flags Signed-off-by: Rameez Sajwani * fixing vtttestserver flags Signed-off-by: Rameez Sajwani * adding comments and removing unwanted script Signed-off-by: Rameez Sajwani * code review Signed-off-by: Rameez Sajwani * removing leader Check interval Signed-off-by: Rameez Sajwani * change to flags out put file Signed-off-by: Rameez Sajwani * adding summary Signed-off-by: Rameez Sajwani * code review feedback Signed-off-by: Rameez Sajwani Signed-off-by: Rameez Sajwani --- doc/releasenotes/16_0_0_summary.md | 11 ++++++++++- docker/vttestserver/run.sh | 1 + go/cmd/vttestserver/main.go | 2 ++ go/flags/endtoend/vttestserver.txt | 1 + go/vt/vttest/local_cluster.go | 3 +++ go/vt/vttest/vtprocess.go | 9 +++++++++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/doc/releasenotes/16_0_0_summary.md b/doc/releasenotes/16_0_0_summary.md index 9b44c6b8177..bc4e2319681 100644 --- a/doc/releasenotes/16_0_0_summary.md +++ b/doc/releasenotes/16_0_0_summary.md @@ -246,4 +246,13 @@ VSchema Example #### Flag Deprecations -The flag `lock-shard-timeout` has been deprecated. Please use the newly introduced `lock-timeout` instead. More detail [here](#lock-timeout-introduction). \ No newline at end of file +The flag `lock-shard-timeout` has been deprecated. Please use the newly introduced `lock-timeout` instead. More detail [here](#lock-timeout-introduction). + +### VTTestServer + +#### Improvement + +Creating a database with vttestserver was taking ~45 seconds. This can be problematic in test environments where testcases do a lot of `create` and `drop` database. +In an effort to minimize the database creation time, we have changed the value of `tablet_refresh_interval` to 10s while instantiating vtcombo during vttestserver initialization. We have also made this configurable so that it can be reduced further if desired. +For any production cluster the default value of this flag is still [1 minute](https://vitess.io/docs/15.0/reference/programs/vtgate/). Reducing this values might put more stress on Topo Server (since we now read from Topo server more often) but for testing purposes +this shouldn't be a concern. diff --git a/docker/vttestserver/run.sh b/docker/vttestserver/run.sh index 18e40bb5ede..c3df8cbe1f7 100755 --- a/docker/vttestserver/run.sh +++ b/docker/vttestserver/run.sh @@ -42,5 +42,6 @@ rm -vf "$VTDATAROOT"/"$tablet_dir"/{mysql.sock,mysql.sock.lock} --enable_direct_ddl="${ENABLE_DIRECT_DDL:-true}" \ --planner-version="${PLANNER_VERSION:-v3}" \ --vschema_ddl_authorized_users=% \ + --tablet_refresh_interval "$TABLET_REFRESH_INTERVAL" --schema_dir="/vt/schema/" diff --git a/go/cmd/vttestserver/main.go b/go/cmd/vttestserver/main.go index 6eedf82cdcf..99297dc5976 100644 --- a/go/cmd/vttestserver/main.go +++ b/go/cmd/vttestserver/main.go @@ -26,6 +26,7 @@ import ( "strings" "sync" "syscall" + "time" "github.com/spf13/pflag" "google.golang.org/protobuf/encoding/prototext" @@ -165,6 +166,7 @@ func registerFlags(fs *pflag.FlagSet) { fs.StringVar(&config.ExternalTopoGlobalServerAddress, "external_topo_global_server_address", "", "the address of the global topology server for vtcombo process") fs.StringVar(&config.ExternalTopoGlobalRoot, "external_topo_global_root", "", "the path of the global topology data in the global topology server for vtcombo process") + fs.DurationVar(&config.VtgateTabletRefreshInterval, "tablet_refresh_interval", 10*time.Second, "Interval at which vtgate refreshes tablet information from topology server.") acl.RegisterFlags(fs) } diff --git a/go/flags/endtoend/vttestserver.txt b/go/flags/endtoend/vttestserver.txt index df27f46bcb8..197ab0bdf2c 100644 --- a/go/flags/endtoend/vttestserver.txt +++ b/go/flags/endtoend/vttestserver.txt @@ -108,6 +108,7 @@ Usage of vttestserver: --tablet_manager_grpc_key string the key to use to connect --tablet_manager_grpc_server_name string the server name to use to validate server certificate --tablet_manager_protocol string Protocol to use to make tabletmanager RPCs to vttablets. (default "grpc") + --tablet_refresh_interval duration Interval at which vtgate refreshes tablet information from topology server. (default 10s) --topo_consul_lock_delay duration LockDelay for consul session. (default 15s) --topo_consul_lock_session_checks string List of checks for consul session. (default "serfHealth") --topo_consul_lock_session_ttl string TTL for consul session. diff --git a/go/vt/vttest/local_cluster.go b/go/vt/vttest/local_cluster.go index 40ba6937e27..ce8d16ec075 100644 --- a/go/vt/vttest/local_cluster.go +++ b/go/vt/vttest/local_cluster.go @@ -27,6 +27,7 @@ import ( "path" "path/filepath" "strings" + "time" "unicode" "google.golang.org/protobuf/encoding/protojson" @@ -143,6 +144,8 @@ type Config struct { ExternalTopoGlobalServerAddress string ExternalTopoGlobalRoot string + + VtgateTabletRefreshInterval time.Duration } // InitSchemas is a shortcut for tests that just want to setup a single diff --git a/go/vt/vttest/vtprocess.go b/go/vt/vttest/vtprocess.go index 6c5f73b322c..d8dd50cb2e8 100644 --- a/go/vt/vttest/vtprocess.go +++ b/go/vt/vttest/vtprocess.go @@ -228,6 +228,15 @@ func VtcomboProcess(environment Environment, args *Config, mysql MySQLManager) ( fmt.Sprintf("--enable_system_settings=%t", args.EnableSystemSettings), }...) + // If topo tablet refresh interval is not defined then we will give it value of 10s. Please note + // that the default value is 1 minute, but we are keeping it low to make vttestserver perform faster. + // Less value might result in high pressure on topo but for testing purpose that should not be a concern. + if args.VtgateTabletRefreshInterval <= 0 { + vt.ExtraArgs = append(vt.ExtraArgs, fmt.Sprintf("--tablet_refresh_interval=%v", 10*time.Second)) + } else { + vt.ExtraArgs = append(vt.ExtraArgs, fmt.Sprintf("--tablet_refresh_interval=%v", args.VtgateTabletRefreshInterval)) + } + vt.ExtraArgs = append(vt.ExtraArgs, QueryServerArgs...) vt.ExtraArgs = append(vt.ExtraArgs, environment.VtcomboArguments()...)