Skip to content

Commit

Permalink
vttestserver: make tablet_refresh_interval configurable and reduce de…
Browse files Browse the repository at this point in the history
…fault value (vitessio#11918)

* setting up refresh_interval and check_leader_interval

Signed-off-by: Rameez Sajwani <[email protected]>

* setting default value, if not provided

Signed-off-by: Rameez Sajwani <[email protected]>

* fixing vttablet flags

Signed-off-by: Rameez Sajwani <[email protected]>

* fixing vtttestserver flags

Signed-off-by: Rameez Sajwani <[email protected]>

* adding comments and removing unwanted script

Signed-off-by: Rameez Sajwani <[email protected]>

* code review

Signed-off-by: Rameez Sajwani <[email protected]>

* removing leader Check interval

Signed-off-by: Rameez Sajwani <[email protected]>

* change to flags out put file

Signed-off-by: Rameez Sajwani <[email protected]>

* adding summary

Signed-off-by: Rameez Sajwani <[email protected]>

* code review feedback

Signed-off-by: Rameez Sajwani <[email protected]>

Signed-off-by: Rameez Sajwani <[email protected]>
  • Loading branch information
rsajwani authored Dec 19, 2022
1 parent ece6501 commit a6ab8a2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion doc/releasenotes/16_0_0_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
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.
1 change: 1 addition & 0 deletions docker/vttestserver/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

2 changes: 2 additions & 0 deletions go/cmd/vttestserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"strings"
"sync"
"syscall"
"time"

"github.com/spf13/pflag"
"google.golang.org/protobuf/encoding/prototext"
Expand Down Expand Up @@ -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)
}

Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vttestserver.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions go/vt/vttest/local_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"path"
"path/filepath"
"strings"
"time"
"unicode"

"google.golang.org/protobuf/encoding/protojson"
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions go/vt/vttest/vtprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()...)

Expand Down

0 comments on commit a6ab8a2

Please sign in to comment.