Skip to content

Commit

Permalink
cleanup deprecated flag types in tabletenv
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Mason <[email protected]>
  • Loading branch information
Andrew Mason committed Dec 8, 2023
1 parent 084075f commit a196203
Show file tree
Hide file tree
Showing 31 changed files with 494 additions and 281 deletions.
5 changes: 3 additions & 2 deletions go/test/fuzzing/tabletserver_schema_fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"context"
"sync"
"testing"
"time"

"vitess.io/vitess/go/mysql/fakesqldb"
"vitess.io/vitess/go/sqltypes"
Expand Down Expand Up @@ -60,9 +61,9 @@ func newTestLoadTable(tableName, comment string, db *fakesqldb.DB) (*schema.Tabl
appParams := db.ConnParams()
dbaParams := db.ConnParams()
cfg := tabletenv.ConnPoolConfig{
Size: 2,
Size: 2,
IdleTimeout: 10 * time.Second,
}
_ = cfg.IdleTimeoutSeconds.Set("10s")

connPool := connpool.NewPool(tabletenv.NewEnv(nil, "SchemaTest"), "", cfg)
connPool.Open(appParams, dbaParams, appParams)
Expand Down
3 changes: 2 additions & 1 deletion go/vt/vttablet/endtoend/connkilling/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"os"
"testing"
"time"

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/vt/tableacl"
Expand Down Expand Up @@ -81,7 +82,7 @@ func TestMain(m *testing.M) {
connParams = cluster.MySQLConnParams()
connAppDebugParams = cluster.MySQLAppDebugConnParams()
config := tabletenv.NewDefaultConfig()
_ = config.Oltp.TxTimeoutSeconds.Set("3s")
config.Oltp.TxTimeout = 3 * time.Second
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := framework.StartCustomServer(ctx, connParams, connAppDebugParams, cluster.DbName(), config)
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vttablet/endtoend/framework/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ func StartServer(ctx context.Context, connParams, connAppDebugParams mysql.ConnP
config.TwoPCCoordinatorAddress = "fake"
config.HotRowProtection.Mode = tabletenv.Enable
config.TrackSchemaVersions = true
_ = config.GracePeriods.ShutdownSeconds.Set("2s")
config.GracePeriods.Shutdown = 2 * time.Second
config.SignalWhenSchemaChange = true
_ = config.Healthcheck.IntervalSeconds.Set("100ms")
_ = config.Oltp.TxTimeoutSeconds.Set("5s")
_ = config.Olap.TxTimeoutSeconds.Set("5s")
config.Healthcheck.Interval = 100 * time.Millisecond
config.Oltp.TxTimeout = 5 * time.Second
config.Olap.TxTimeout = 5 * time.Second
config.EnableViews = true
config.QueryCacheDoorkeeper = false
gotBytes, _ := yaml2.Marshal(config)
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/endtoend/streamtimeout/healthstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestSchemaChangeTimedout(t *testing.T) {
// This is because the query timeout triggers the *DBConn.Kill() method, which in turn holds the mutex lock on the health_streamer.
// Although not indefinitely, this can result in longer wait times.
// It's worth noting that the behavior of *DBConn.Kill() is outside the scope of this test.
reloadInterval := config.SignalSchemaChangeReloadIntervalSeconds.Get()
reloadInterval := config.SignalSchemaChangeReloadInterval
time.Sleep(reloadInterval)

// pause simulating the mysql stall to allow the health_streamer to resume.
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/endtoend/streamtimeout/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestMain(m *testing.M) {
connParams := cluster.MySQLConnParams()
connAppDebugParams := cluster.MySQLAppDebugConnParams()
config = tabletenv.NewDefaultConfig()
_ = config.SchemaReloadIntervalSeconds.Set("2100ms")
config.SchemaReloadInterval = (2 * time.Second) + (100 * time.Millisecond)
config.SchemaChangeReloadTimeout = 10 * time.Second
config.SignalWhenSchemaChange = true

Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/onlineddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ func NewExecutor(env tabletenv.Env, tabletAlias *topodatapb.TabletAlias, ts *top
tabletAlias: tabletAlias.CloneVT(),

pool: connpool.NewPool(env, "OnlineDDLExecutorPool", tabletenv.ConnPoolConfig{
Size: databasePoolSize,
IdleTimeoutSeconds: env.Config().OltpReadPool.IdleTimeoutSeconds,
Size: databasePoolSize,
IdleTimeout: env.Config().OltpReadPool.IdleTimeout,
}),
tabletTypeFunc: tabletTypeFunc,
ts: ts,
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletserver/connpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ type Pool struct {
// to publish stats only.
func NewPool(env tabletenv.Env, name string, cfg tabletenv.ConnPoolConfig) *Pool {
cp := &Pool{
timeout: cfg.TimeoutSeconds.Get(),
timeout: cfg.Timeout,
env: env,
}

config := smartconnpool.Config[*Conn]{
Capacity: int64(cfg.Size),
IdleTimeout: cfg.IdleTimeoutSeconds.Get(),
MaxLifetime: cfg.MaxLifetimeSeconds.Get(),
IdleTimeout: cfg.IdleTimeout,
MaxLifetime: cfg.MaxLifetime,
RefreshInterval: mysqlctl.PoolDynamicHostnameResolution,
}

Expand Down
13 changes: 6 additions & 7 deletions go/vt/vttablet/tabletserver/connpool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func TestConnPoolTimeout(t *testing.T) {
cfg := tabletenv.ConnPoolConfig{
Size: 1,
}
_ = cfg.TimeoutSeconds.Set("1s")
_ = cfg.IdleTimeoutSeconds.Set("10s")
cfg.Timeout = time.Second
cfg.IdleTimeout = 10 * time.Second
connPool := NewPool(tabletenv.NewEnv(nil, "PoolTest"), "TestPool", cfg)
connPool.Open(db.ConnParams(), db.ConnParams(), db.ConnParams())
defer connPool.Close()
Expand Down Expand Up @@ -325,9 +325,8 @@ func newPool() *Pool {
}

func newPoolWithCapacity(capacity int) *Pool {
cfg := tabletenv.ConnPoolConfig{
Size: capacity,
}
_ = cfg.IdleTimeoutSeconds.Set("10s")
return NewPool(tabletenv.NewEnv(nil, "PoolTest"), "TestPool", cfg)
return NewPool(tabletenv.NewEnv(nil, "PoolTest"), "TestPool", tabletenv.ConnPoolConfig{
Size: capacity,
IdleTimeout: 10 * time.Second,
})
}
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/debugenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func debugEnvHandler(tsv *TabletServer, w http.ResponseWriter, r *http.Request)
case "RowStreamerMaxMySQLReplLagSecs":
setInt64Val(func(val int64) { tsv.Config().RowStreamer.MaxMySQLReplLagSecs = val })
case "UnhealthyThreshold":
setDurationVal(func(d time.Duration) { _ = tsv.Config().Healthcheck.UnhealthyThresholdSeconds.Set(d.String()) })
setDurationVal(func(d time.Duration) { tsv.Config().Healthcheck.UnhealthyThreshold = d })
setDurationVal(tsv.hs.SetUnhealthyThreshold)
setDurationVal(tsv.sm.SetUnhealthyThreshold)
case "ThrottleMetricThreshold":
Expand All @@ -145,7 +145,7 @@ func debugEnvHandler(tsv *TabletServer, w http.ResponseWriter, r *http.Request)
vars = addVar(vars, "WarnResultSize", tsv.WarnResultSize)
vars = addVar(vars, "RowStreamerMaxInnoDBTrxHistLen", func() int64 { return tsv.Config().RowStreamer.MaxInnoDBTrxHistLen })
vars = addVar(vars, "RowStreamerMaxMySQLReplLagSecs", func() int64 { return tsv.Config().RowStreamer.MaxMySQLReplLagSecs })
vars = addVar(vars, "UnhealthyThreshold", tsv.Config().Healthcheck.UnhealthyThresholdSeconds.Get)
vars = addVar(vars, "UnhealthyThreshold", func() time.Duration { return tsv.Config().Healthcheck.UnhealthyThreshold })
vars = addVar(vars, "ThrottleMetricThreshold", tsv.ThrottleMetricThreshold)
vars = append(vars, envValue{
Name: "Consolidator",
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/gc/tablegc.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ func NewTableGC(env tabletenv.Env, ts *topo.Server, lagThrottler *throttle.Throt
env: env,
ts: ts,
pool: connpool.NewPool(env, "TableGCPool", tabletenv.ConnPoolConfig{
Size: 2,
IdleTimeoutSeconds: env.Config().OltpReadPool.IdleTimeoutSeconds,
Size: 2,
IdleTimeout: env.Config().OltpReadPool.IdleTimeout,
}),

purgingTables: map[string]bool{},
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vttablet/tabletserver/health_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ func newHealthStreamer(env tabletenv.Env, alias *topodatapb.TabletAlias, engine
if env.Config().SignalWhenSchemaChange {
// We need one connection for the reloader.
pool = connpool.NewPool(env, "", tabletenv.ConnPoolConfig{
Size: 1,
IdleTimeoutSeconds: env.Config().OltpReadPool.IdleTimeoutSeconds,
Size: 1,
IdleTimeout: env.Config().OltpReadPool.IdleTimeout,
})
}
hs := &healthStreamer{
stats: env.Stats(),
degradedThreshold: env.Config().Healthcheck.DegradedThresholdSeconds.Get(),
degradedThreshold: env.Config().Healthcheck.DegradedThreshold,
clients: make(map[chan *querypb.StreamHealthResponse]struct{}),

state: &querypb.StreamHealthResponse{
Expand All @@ -122,7 +122,7 @@ func newHealthStreamer(env tabletenv.Env, alias *topodatapb.TabletAlias, engine
viewsEnabled: env.Config().EnableViews,
se: engine,
}
hs.unhealthyThreshold.Store(env.Config().Healthcheck.UnhealthyThresholdSeconds.Get().Nanoseconds())
hs.unhealthyThreshold.Store(env.Config().Healthcheck.UnhealthyThreshold.Nanoseconds())
return hs
}

Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/health_streamer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func TestReloadSchema(t *testing.T) {
defer db.Close()
config := newConfig(db)
config.SignalWhenSchemaChange = testcase.enableSchemaChange
_ = config.SchemaReloadIntervalSeconds.Set("100ms")
config.SchemaReloadInterval = 100 * time.Millisecond

env := tabletenv.NewEnv(config, "ReplTrackerTest")
alias := &topodatapb.TabletAlias{
Expand Down Expand Up @@ -333,7 +333,7 @@ func TestReloadView(t *testing.T) {
defer db.Close()
config := newConfig(db)
config.SignalWhenSchemaChange = true
_ = config.SchemaReloadIntervalSeconds.Set("100ms")
config.SchemaReloadInterval = 100 * time.Millisecond
config.EnableViews = true

env := tabletenv.NewEnv(config, "TestReloadView")
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletserver/query_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ func TestStatsURL(t *testing.T) {
func newTestQueryEngine(idleTimeout time.Duration, strict bool, dbcfgs *dbconfigs.DBConfigs) *QueryEngine {
config := tabletenv.NewDefaultConfig()
config.DB = dbcfgs
_ = config.OltpReadPool.IdleTimeoutSeconds.Set(idleTimeout.String())
_ = config.OlapReadPool.IdleTimeoutSeconds.Set(idleTimeout.String())
_ = config.TxPool.IdleTimeoutSeconds.Set(idleTimeout.String())
config.OltpReadPool.IdleTimeout = idleTimeout
config.OlapReadPool.IdleTimeout = idleTimeout
config.TxPool.IdleTimeout = idleTimeout
env := tabletenv.NewEnv(config, "TabletServerTest")
se := schema.NewEngine(env)
qe := NewQueryEngine(env, se)
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletserver/repltracker/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func newHeartbeatReader(env tabletenv.Env) *heartbeatReader {
return &heartbeatReader{}
}

heartbeatInterval := config.ReplicationTracker.HeartbeatIntervalSeconds.Get()
heartbeatInterval := config.ReplicationTracker.HeartbeatInterval
return &heartbeatReader{
env: env,
enabled: true,
Expand All @@ -80,8 +80,8 @@ func newHeartbeatReader(env tabletenv.Env) *heartbeatReader {
ticks: timer.NewTimer(heartbeatInterval),
errorLog: logutil.NewThrottledLogger("HeartbeatReporter", 60*time.Second),
pool: connpool.NewPool(env, "HeartbeatReadPool", tabletenv.ConnPoolConfig{
Size: 1,
IdleTimeoutSeconds: env.Config().OltpReadPool.IdleTimeoutSeconds,
Size: 1,
IdleTimeout: env.Config().OltpReadPool.IdleTimeout,
}),
}
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/repltracker/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestReaderReadHeartbeatError(t *testing.T) {
func newReader(db *fakesqldb.DB, frozenTime *time.Time) *heartbeatReader {
config := tabletenv.NewDefaultConfig()
config.ReplicationTracker.Mode = tabletenv.Heartbeat
_ = config.ReplicationTracker.HeartbeatIntervalSeconds.Set("1s")
config.ReplicationTracker.HeartbeatInterval = time.Second
params, _ := db.ConnParams().MysqlParams()
cp := *params
dbc := dbconfigs.NewTestDBConfigs(cp, cp, "")
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/repltracker/repltracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type ReplTracker struct {
func NewReplTracker(env tabletenv.Env, alias *topodatapb.TabletAlias) *ReplTracker {
return &ReplTracker{
mode: env.Config().ReplicationTracker.Mode,
forceHeartbeat: env.Config().ReplicationTracker.HeartbeatOnDemandSeconds.Get() > 0,
forceHeartbeat: env.Config().ReplicationTracker.HeartbeatOnDemand > 0,
hw: newHeartbeatWriter(env, alias),
hr: newHeartbeatReader(env),
poller: &poller{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestReplTracker(t *testing.T) {

config := tabletenv.NewDefaultConfig()
config.ReplicationTracker.Mode = tabletenv.Heartbeat
_ = config.ReplicationTracker.HeartbeatIntervalSeconds.Set("1s")
config.ReplicationTracker.HeartbeatInterval = time.Second
params, _ := db.ConnParams().MysqlParams()
cp := *params
config.DB = dbconfigs.NewTestDBConfigs(cp, cp, "")
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletserver/repltracker/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ func newHeartbeatWriter(env tabletenv.Env, alias *topodatapb.TabletAlias) *heart
config := env.Config()

// config.EnableLagThrottler is a feature flag for the throttler; if throttler runs, then heartbeat must also run
if config.ReplicationTracker.Mode != tabletenv.Heartbeat && config.ReplicationTracker.HeartbeatOnDemandSeconds.Get() == 0 {
if config.ReplicationTracker.Mode != tabletenv.Heartbeat && config.ReplicationTracker.HeartbeatOnDemand == 0 {
return &heartbeatWriter{}
}
heartbeatInterval := config.ReplicationTracker.HeartbeatIntervalSeconds.Get()
heartbeatInterval := config.ReplicationTracker.HeartbeatInterval
w := &heartbeatWriter{
env: env,
enabled: true,
tabletAlias: alias.CloneVT(),
now: time.Now,
interval: heartbeatInterval,
onDemandDuration: config.ReplicationTracker.HeartbeatOnDemandSeconds.Get(),
onDemandDuration: config.ReplicationTracker.HeartbeatOnDemand,
ticks: timer.NewTimer(heartbeatInterval),
errorLog: logutil.NewThrottledLogger("HeartbeatWriter", 60*time.Second),
// We make this pool size 2; to prevent pool exhausted
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/repltracker/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestWriteHeartbeatError(t *testing.T) {
func newTestWriter(db *fakesqldb.DB, frozenTime *time.Time) *heartbeatWriter {
config := tabletenv.NewDefaultConfig()
config.ReplicationTracker.Mode = tabletenv.Heartbeat
_ = config.ReplicationTracker.HeartbeatIntervalSeconds.Set("1s")
config.ReplicationTracker.HeartbeatInterval = time.Second

params, _ := db.ConnParams().MysqlParams()
cp := *params
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletserver/schema/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ type Engine struct {

// NewEngine creates a new Engine.
func NewEngine(env tabletenv.Env) *Engine {
reloadTime := env.Config().SchemaReloadIntervalSeconds.Get()
reloadTime := env.Config().SchemaReloadInterval
se := &Engine{
env: env,
// We need three connections: one for the reloader, one for
// the historian, and one for the tracker.
conns: connpool.NewPool(env, "", tabletenv.ConnPoolConfig{
Size: 3,
IdleTimeoutSeconds: env.Config().OltpReadPool.IdleTimeoutSeconds,
Size: 3,
IdleTimeout: env.Config().OltpReadPool.IdleTimeout,
}),
ticks: timer.NewTimer(reloadTime),
}
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vttablet/tabletserver/schema/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,10 @@ func TestSchemaEngineCloseTickRace(t *testing.T) {

func newEngine(reloadTime time.Duration, idleTimeout time.Duration, schemaMaxAgeSeconds int64, db *fakesqldb.DB) *Engine {
config := tabletenv.NewDefaultConfig()
_ = config.SchemaReloadIntervalSeconds.Set(reloadTime.String())
_ = config.OltpReadPool.IdleTimeoutSeconds.Set(idleTimeout.String())
_ = config.OlapReadPool.IdleTimeoutSeconds.Set(idleTimeout.String())
_ = config.TxPool.IdleTimeoutSeconds.Set(idleTimeout.String())
config.SchemaReloadInterval = reloadTime
config.OltpReadPool.IdleTimeout = idleTimeout
config.OlapReadPool.IdleTimeout = idleTimeout
config.TxPool.IdleTimeout = idleTimeout
config.SchemaVersionMaxAgeSeconds = schemaMaxAgeSeconds
se := NewEngine(tabletenv.NewEnv(config, "SchemaTest"))
se.InitDBConfig(newDBConfigs(db).DbaWithDB())
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/schema/load_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ func newTestLoadTable(tableType string, comment string, db *fakesqldb.DB) (*Tabl
appParams := db.ConnParams()
dbaParams := db.ConnParams()
cfg := tabletenv.ConnPoolConfig{
Size: 2,
Size: 2,
IdleTimeout: 10 * time.Second,
}
_ = cfg.IdleTimeoutSeconds.Set("10s")
connPool := connpool.NewPool(tabletenv.NewEnv(nil, "SchemaTest"), "", cfg)
connPool.Open(appParams, dbaParams, appParams)
conn, err := connPool.Get(ctx, nil)
Expand Down
10 changes: 5 additions & 5 deletions go/vt/vttablet/tabletserver/state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ func (sm *stateManager) Init(env tabletenv.Env, target *querypb.Target) {
sm.target = target.CloneVT()
sm.transitioning = semaphore.NewWeighted(1)
sm.checkMySQLThrottler = semaphore.NewWeighted(1)
sm.timebombDuration = env.Config().OltpReadPool.TimeoutSeconds.Get() * 10
sm.hcticks = timer.NewTimer(env.Config().Healthcheck.IntervalSeconds.Get())
sm.unhealthyThreshold.Store(env.Config().Healthcheck.UnhealthyThresholdSeconds.Get().Nanoseconds())
sm.shutdownGracePeriod = env.Config().GracePeriods.ShutdownSeconds.Get()
sm.transitionGracePeriod = env.Config().GracePeriods.TransitionSeconds.Get()
sm.timebombDuration = env.Config().OltpReadPool.Timeout * 10
sm.hcticks = timer.NewTimer(env.Config().Healthcheck.Interval)
sm.unhealthyThreshold.Store(env.Config().Healthcheck.UnhealthyThreshold.Nanoseconds())
sm.shutdownGracePeriod = env.Config().GracePeriods.Shutdown
sm.transitionGracePeriod = env.Config().GracePeriods.Transition
}

// SetServingType changes the state to the specified settings.
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ func (tsv *TabletServer) AddStatusHeader() {
// AddStatusPart registers the status part for the status page.
func (tsv *TabletServer) AddStatusPart() {
// Save the threshold values for reporting.
degradedThreshold.Store(tsv.config.Healthcheck.DegradedThresholdSeconds.Get().Nanoseconds())
unhealthyThreshold.Store(tsv.config.Healthcheck.UnhealthyThresholdSeconds.Get().Nanoseconds())
degradedThreshold.Store(tsv.config.Healthcheck.DegradedThreshold.Nanoseconds())
unhealthyThreshold.Store(tsv.config.Healthcheck.UnhealthyThreshold.Nanoseconds())

tsv.exporter.AddStatusPart("Health", queryserviceStatusTemplate, func() any {
status := queryserviceStatus{
Expand Down
Loading

0 comments on commit a196203

Please sign in to comment.