Skip to content

Commit a6ab8a2

Browse files
authored
vttestserver: make tablet_refresh_interval configurable and reduce default 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]>
1 parent ece6501 commit a6ab8a2

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

doc/releasenotes/16_0_0_summary.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,13 @@ VSchema Example
246246

247247
#### Flag Deprecations
248248

249-
The flag `lock-shard-timeout` has been deprecated. Please use the newly introduced `lock-timeout` instead. More detail [here](#lock-timeout-introduction).
249+
The flag `lock-shard-timeout` has been deprecated. Please use the newly introduced `lock-timeout` instead. More detail [here](#lock-timeout-introduction).
250+
251+
### VTTestServer
252+
253+
#### Improvement
254+
255+
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.
256+
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.
257+
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
258+
this shouldn't be a concern.

docker/vttestserver/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@ rm -vf "$VTDATAROOT"/"$tablet_dir"/{mysql.sock,mysql.sock.lock}
4242
--enable_direct_ddl="${ENABLE_DIRECT_DDL:-true}" \
4343
--planner-version="${PLANNER_VERSION:-v3}" \
4444
--vschema_ddl_authorized_users=% \
45+
--tablet_refresh_interval "$TABLET_REFRESH_INTERVAL"
4546
--schema_dir="/vt/schema/"
4647

go/cmd/vttestserver/main.go

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"strings"
2727
"sync"
2828
"syscall"
29+
"time"
2930

3031
"github.com/spf13/pflag"
3132
"google.golang.org/protobuf/encoding/prototext"
@@ -165,6 +166,7 @@ func registerFlags(fs *pflag.FlagSet) {
165166
fs.StringVar(&config.ExternalTopoGlobalServerAddress, "external_topo_global_server_address", "", "the address of the global topology server for vtcombo process")
166167
fs.StringVar(&config.ExternalTopoGlobalRoot, "external_topo_global_root", "", "the path of the global topology data in the global topology server for vtcombo process")
167168

169+
fs.DurationVar(&config.VtgateTabletRefreshInterval, "tablet_refresh_interval", 10*time.Second, "Interval at which vtgate refreshes tablet information from topology server.")
168170
acl.RegisterFlags(fs)
169171
}
170172

go/flags/endtoend/vttestserver.txt

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Usage of vttestserver:
108108
--tablet_manager_grpc_key string the key to use to connect
109109
--tablet_manager_grpc_server_name string the server name to use to validate server certificate
110110
--tablet_manager_protocol string Protocol to use to make tabletmanager RPCs to vttablets. (default "grpc")
111+
--tablet_refresh_interval duration Interval at which vtgate refreshes tablet information from topology server. (default 10s)
111112
--topo_consul_lock_delay duration LockDelay for consul session. (default 15s)
112113
--topo_consul_lock_session_checks string List of checks for consul session. (default "serfHealth")
113114
--topo_consul_lock_session_ttl string TTL for consul session.

go/vt/vttest/local_cluster.go

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"path"
2828
"path/filepath"
2929
"strings"
30+
"time"
3031
"unicode"
3132

3233
"google.golang.org/protobuf/encoding/protojson"
@@ -143,6 +144,8 @@ type Config struct {
143144
ExternalTopoGlobalServerAddress string
144145

145146
ExternalTopoGlobalRoot string
147+
148+
VtgateTabletRefreshInterval time.Duration
146149
}
147150

148151
// InitSchemas is a shortcut for tests that just want to setup a single

go/vt/vttest/vtprocess.go

+9
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,15 @@ func VtcomboProcess(environment Environment, args *Config, mysql MySQLManager) (
228228
fmt.Sprintf("--enable_system_settings=%t", args.EnableSystemSettings),
229229
}...)
230230

231+
// If topo tablet refresh interval is not defined then we will give it value of 10s. Please note
232+
// that the default value is 1 minute, but we are keeping it low to make vttestserver perform faster.
233+
// Less value might result in high pressure on topo but for testing purpose that should not be a concern.
234+
if args.VtgateTabletRefreshInterval <= 0 {
235+
vt.ExtraArgs = append(vt.ExtraArgs, fmt.Sprintf("--tablet_refresh_interval=%v", 10*time.Second))
236+
} else {
237+
vt.ExtraArgs = append(vt.ExtraArgs, fmt.Sprintf("--tablet_refresh_interval=%v", args.VtgateTabletRefreshInterval))
238+
}
239+
231240
vt.ExtraArgs = append(vt.ExtraArgs, QueryServerArgs...)
232241
vt.ExtraArgs = append(vt.ExtraArgs, environment.VtcomboArguments()...)
233242

0 commit comments

Comments
 (0)