diff --git a/go/vt/vttablet/heartbeat/reader.go b/go/vt/vttablet/heartbeat/reader.go index 0df09195e60..0f1f487b9b3 100644 --- a/go/vt/vttablet/heartbeat/reader.go +++ b/go/vt/vttablet/heartbeat/reader.go @@ -70,11 +70,11 @@ type Reader struct { // NewReader returns a new heartbeat reader. func NewReader(env tabletenv.Env) *Reader { config := env.Config() - if config.HeartbeatIntervalMilliseconds == 0 { + if config.HeartbeatIntervalSeconds == 0 { return &Reader{} } - heartbeatInterval := time.Duration(config.HeartbeatIntervalMilliseconds) * time.Millisecond + heartbeatInterval := time.Duration(config.HeartbeatIntervalSeconds * 1e9) return &Reader{ env: env, enabled: true, diff --git a/go/vt/vttablet/heartbeat/reader_test.go b/go/vt/vttablet/heartbeat/reader_test.go index ddfe0a23215..e22d28d8094 100644 --- a/go/vt/vttablet/heartbeat/reader_test.go +++ b/go/vt/vttablet/heartbeat/reader_test.go @@ -100,7 +100,7 @@ func TestReaderReadHeartbeatError(t *testing.T) { func newReader(db *fakesqldb.DB, nowFunc func() time.Time) *Reader { config := tabletenv.NewDefaultConfig() - config.HeartbeatIntervalMilliseconds = 1000 + config.HeartbeatIntervalSeconds = 1 params, _ := db.ConnParams().MysqlParams() cp := *params dbc := dbconfigs.NewTestDBConfigs(cp, cp, "") diff --git a/go/vt/vttablet/heartbeat/writer.go b/go/vt/vttablet/heartbeat/writer.go index e1f649486f3..ba853d2bc7e 100644 --- a/go/vt/vttablet/heartbeat/writer.go +++ b/go/vt/vttablet/heartbeat/writer.go @@ -71,10 +71,10 @@ type Writer struct { // NewWriter creates a new Writer. func NewWriter(env tabletenv.Env, alias topodatapb.TabletAlias) *Writer { config := env.Config() - if config.HeartbeatIntervalMilliseconds == 0 { + if config.HeartbeatIntervalSeconds == 0 { return &Writer{} } - heartbeatInterval := time.Duration(config.HeartbeatIntervalMilliseconds) * time.Millisecond + heartbeatInterval := time.Duration(config.HeartbeatIntervalSeconds * 1e9) return &Writer{ env: env, enabled: true, diff --git a/go/vt/vttablet/heartbeat/writer_test.go b/go/vt/vttablet/heartbeat/writer_test.go index 33b6a4cc506..d0d8303d467 100644 --- a/go/vt/vttablet/heartbeat/writer_test.go +++ b/go/vt/vttablet/heartbeat/writer_test.go @@ -104,7 +104,7 @@ func TestWriteHeartbeatError(t *testing.T) { func newTestWriter(db *fakesqldb.DB, nowFunc func() time.Time) *Writer { config := tabletenv.NewDefaultConfig() - config.HeartbeatIntervalMilliseconds = 1000 + config.HeartbeatIntervalSeconds = 1 params, _ := db.ConnParams().MysqlParams() cp := *params diff --git a/go/vt/vttablet/tabletmanager/heartbeat_reporter.go b/go/vt/vttablet/tabletmanager/heartbeat_reporter.go index 4db1aa8ac0f..93374008688 100644 --- a/go/vt/vttablet/tabletmanager/heartbeat_reporter.go +++ b/go/vt/vttablet/tabletmanager/heartbeat_reporter.go @@ -34,7 +34,7 @@ type Reporter struct { // RegisterReporter registers the heartbeat reader as a healthcheck reporter so that its // measurements will be picked up in healthchecks. func registerHeartbeatReporter(controller tabletserver.Controller) { - if tabletenv.NewCurrentConfig().HeartbeatIntervalMilliseconds == 0 { + if tabletenv.NewCurrentConfig().HeartbeatIntervalSeconds == 0 { return } diff --git a/go/vt/vttablet/tabletserver/query_engine_test.go b/go/vt/vttablet/tabletserver/query_engine_test.go index bcbaa61554f..902ce858202 100644 --- a/go/vt/vttablet/tabletserver/query_engine_test.go +++ b/go/vt/vttablet/tabletserver/query_engine_test.go @@ -277,9 +277,9 @@ func newTestQueryEngine(queryCacheSize int, idleTimeout time.Duration, strict bo config := tabletenv.NewDefaultConfig() config.DB = dbcfgs config.QueryCacheSize = queryCacheSize - config.OltpReadPool.IdleTimeoutSeconds = int(idleTimeout / 1e9) - config.OlapReadPool.IdleTimeoutSeconds = int(idleTimeout / 1e9) - config.TxPool.IdleTimeoutSeconds = int(idleTimeout / 1e9) + config.OltpReadPool.IdleTimeoutSeconds = float64(idleTimeout / 1e9) + config.OlapReadPool.IdleTimeoutSeconds = float64(idleTimeout / 1e9) + config.TxPool.IdleTimeoutSeconds = float64(idleTimeout / 1e9) env := tabletenv.NewEnv(config, "TabletServerTest") se := schema.NewEngine(env) qe := NewQueryEngine(env, se) diff --git a/go/vt/vttablet/tabletserver/schema/engine_test.go b/go/vt/vttablet/tabletserver/schema/engine_test.go index eb3b95f17e1..bfff13f3730 100644 --- a/go/vt/vttablet/tabletserver/schema/engine_test.go +++ b/go/vt/vttablet/tabletserver/schema/engine_test.go @@ -344,10 +344,10 @@ func TestStatsURL(t *testing.T) { func newEngine(queryCacheSize int, reloadTime time.Duration, idleTimeout time.Duration, strict bool, db *fakesqldb.DB) *Engine { config := tabletenv.NewDefaultConfig() config.QueryCacheSize = queryCacheSize - config.SchemaReloadIntervalSeconds = int(reloadTime) / 1e9 - config.OltpReadPool.IdleTimeoutSeconds = int(idleTimeout / 1e9) - config.OlapReadPool.IdleTimeoutSeconds = int(idleTimeout / 1e9) - config.TxPool.IdleTimeoutSeconds = int(idleTimeout / 1e9) + config.SchemaReloadIntervalSeconds = float64(reloadTime) / 1e9 + config.OltpReadPool.IdleTimeoutSeconds = float64(idleTimeout / 1e9) + config.OlapReadPool.IdleTimeoutSeconds = float64(idleTimeout / 1e9) + config.TxPool.IdleTimeoutSeconds = float64(idleTimeout / 1e9) se := NewEngine(tabletenv.NewEnv(config, "SchemaTest")) se.InitDBConfig(newDBConfigs(db).DbaWithDB()) return se diff --git a/go/vt/vttablet/tabletserver/tabletenv/config.go b/go/vt/vttablet/tabletserver/tabletenv/config.go index 359eada15c9..3979482b99e 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config.go @@ -85,8 +85,8 @@ func init() { flag.IntVar(¤tConfig.TxPool.PrefillParallelism, "queryserver-config-transaction-prefill-parallelism", defaultConfig.TxPool.PrefillParallelism, "query server transaction prefill parallelism, a non-zero value will prefill the pool using the specified parallism.") flag.IntVar(¤tConfig.MessagePostponeParallelism, "queryserver-config-message-postpone-cap", defaultConfig.MessagePostponeParallelism, "query server message postpone cap is the maximum number of messages that can be postponed at any given time. Set this number to substantially lower than transaction cap, so that the transaction pool isn't exhausted by the message subsystem.") flag.IntVar(&deprecatedFoundRowsPoolSize, "client-found-rows-pool-size", 0, "DEPRECATED: queryserver-config-transaction-cap will be used instead.") - flag.IntVar(¤tConfig.Oltp.TxTimeoutSeconds, "queryserver-config-transaction-timeout", defaultConfig.Oltp.TxTimeoutSeconds, "query server transaction timeout (in seconds), a transaction will be killed if it takes longer than this value") - flag.IntVar(¤tConfig.ShutdownGracePeriodSeconds, "transaction_shutdown_grace_period", defaultConfig.ShutdownGracePeriodSeconds, "how long to wait (in seconds) for transactions to complete during graceful shutdown.") + flag.Float64Var(¤tConfig.Oltp.TxTimeoutSeconds, "queryserver-config-transaction-timeout", defaultConfig.Oltp.TxTimeoutSeconds, "query server transaction timeout (in seconds), a transaction will be killed if it takes longer than this value") + flag.Float64Var(¤tConfig.ShutdownGracePeriodSeconds, "transaction_shutdown_grace_period", defaultConfig.ShutdownGracePeriodSeconds, "how long to wait (in seconds) for transactions to complete during graceful shutdown.") flag.IntVar(¤tConfig.Oltp.MaxRows, "queryserver-config-max-result-size", defaultConfig.Oltp.MaxRows, "query server max result size, maximum number of rows allowed to return from vttablet for non-streaming queries.") flag.IntVar(¤tConfig.Oltp.WarnRows, "queryserver-config-warn-result-size", defaultConfig.Oltp.WarnRows, "query server result size warning threshold, warn if number of rows returned from vttablet for non-streaming queries exceeds this") flag.IntVar(&deprecatedMaxDMLRows, "queryserver-config-max-dml-rows", 0, "query server max dml rows per statement, maximum number of rows allowed to return at a time for an update or delete with either 1) an equality where clauses on primary keys, or 2) a subselect statement. For update and delete statements in above two categories, vttablet will split the original query into multiple small queries based on this configuration value. ") @@ -95,11 +95,12 @@ func init() { flag.IntVar(¤tConfig.StreamBufferSize, "queryserver-config-stream-buffer-size", defaultConfig.StreamBufferSize, "query server stream buffer size, the maximum number of bytes sent from vttablet for each stream call. It's recommended to keep this value in sync with vtgate's stream_buffer_size.") flag.IntVar(¤tConfig.QueryCacheSize, "queryserver-config-query-cache-size", defaultConfig.QueryCacheSize, "query server query cache size, maximum number of queries to be cached. vttablet analyzes every incoming query and generate a query plan, these plans are being cached in a lru cache. This config controls the capacity of the lru cache.") - flag.IntVar(¤tConfig.SchemaReloadIntervalSeconds, "queryserver-config-schema-reload-time", defaultConfig.SchemaReloadIntervalSeconds, "query server schema reload time, how often vttablet reloads schemas from underlying MySQL instance in seconds. vttablet keeps table schemas in its own memory and periodically refreshes it from MySQL. This config controls the reload time.") - flag.IntVar(¤tConfig.Oltp.QueryTimeoutSeconds, "queryserver-config-query-timeout", defaultConfig.Oltp.QueryTimeoutSeconds, "query server query timeout (in seconds), this is the query timeout in vttablet side. If a query takes more than this timeout, it will be killed.") - flag.IntVar(¤tConfig.OltpReadPool.TimeoutSeconds, "queryserver-config-query-pool-timeout", defaultConfig.OltpReadPool.TimeoutSeconds, "query server query pool timeout (in seconds), it is how long vttablet waits for a connection from the query pool. If set to 0 (default) then the overall query timeout is used instead.") - flag.IntVar(¤tConfig.TxPool.TimeoutSeconds, "queryserver-config-txpool-timeout", defaultConfig.TxPool.TimeoutSeconds, "query server transaction pool timeout, it is how long vttablet waits if tx pool is full") - flag.IntVar(¤tConfig.OltpReadPool.IdleTimeoutSeconds, "queryserver-config-idle-timeout", defaultConfig.OltpReadPool.IdleTimeoutSeconds, "query server idle timeout (in seconds), vttablet manages various mysql connection pools. This config means if a connection has not been used in given idle timeout, this connection will be removed from pool. This effectively manages number of connection objects and optimize the pool performance.") + flag.Float64Var(¤tConfig.SchemaReloadIntervalSeconds, "queryserver-config-schema-reload-time", defaultConfig.SchemaReloadIntervalSeconds, "query server schema reload time, how often vttablet reloads schemas from underlying MySQL instance in seconds. vttablet keeps table schemas in its own memory and periodically refreshes it from MySQL. This config controls the reload time.") + flag.Float64Var(¤tConfig.Oltp.QueryTimeoutSeconds, "queryserver-config-query-timeout", defaultConfig.Oltp.QueryTimeoutSeconds, "query server query timeout (in seconds), this is the query timeout in vttablet side. If a query takes more than this timeout, it will be killed.") + flag.Float64Var(¤tConfig.OltpReadPool.TimeoutSeconds, "queryserver-config-query-pool-timeout", defaultConfig.OltpReadPool.TimeoutSeconds, "query server query pool timeout (in seconds), it is how long vttablet waits for a connection from the query pool. If set to 0 (default) then the overall query timeout is used instead.") + flag.Float64Var(¤tConfig.OlapReadPool.TimeoutSeconds, "queryserver-config-stream-pool-timeout", defaultConfig.OlapReadPool.TimeoutSeconds, "query server stream pool timeout (in seconds), it is how long vttablet waits for a connection from the stream pool. If set to 0 (default) then there is no timeout.") + flag.Float64Var(¤tConfig.TxPool.TimeoutSeconds, "queryserver-config-txpool-timeout", defaultConfig.TxPool.TimeoutSeconds, "query server transaction pool timeout, it is how long vttablet waits if tx pool is full") + flag.Float64Var(¤tConfig.OltpReadPool.IdleTimeoutSeconds, "queryserver-config-idle-timeout", defaultConfig.OltpReadPool.IdleTimeoutSeconds, "query server idle timeout (in seconds), vttablet manages various mysql connection pools. This config means if a connection has not been used in given idle timeout, this connection will be removed from pool. This effectively manages number of connection objects and optimize the pool performance.") flag.IntVar(¤tConfig.OltpReadPool.MaxWaiters, "queryserver-config-query-pool-waiter-cap", defaultConfig.OltpReadPool.MaxWaiters, "query server query pool waiter limit, this is the maximum number of queries that can be queued waiting to get a connection") flag.IntVar(¤tConfig.TxPool.MaxWaiters, "queryserver-config-txpool-waiter-cap", defaultConfig.TxPool.MaxWaiters, "query server transaction pool waiter limit, this is the maximum number of transactions that can be queued waiting to get a connection") // tableacl related configurations. @@ -168,7 +169,7 @@ func Init() { } if enableHeartbeat { - currentConfig.HeartbeatIntervalMilliseconds = int(heartbeatInterval / time.Millisecond) + currentConfig.HeartbeatIntervalSeconds = float64(heartbeatInterval) / float64(time.Millisecond) } switch *streamlog.QueryLogFormat { @@ -198,18 +199,18 @@ type TabletConfig struct { Oltp OltpConfig `json:"oltp,omitempty"` HotRowProtection HotRowProtectionConfig `json:"hotRowProtection,omitempty"` - Consolidator string `json:"consolidator,omitempty"` - HeartbeatIntervalMilliseconds int `json:"heartbeatIntervalMilliseconds,omitempty"` - ShutdownGracePeriodSeconds int `json:"shutdownGracePeriodSeconds,omitempty"` - PassthroughDML bool `json:"passthroughDML,omitempty"` - StreamBufferSize int `json:"streamBufferSize,omitempty"` - QueryCacheSize int `json:"queryCacheSize,omitempty"` - SchemaReloadIntervalSeconds int `json:"schemaReloadIntervalSeconds,omitempty"` - WatchReplication bool `json:"watchReplication,omitempty"` - TrackSchemaVersions bool `json:"trackSchemaVersions,omitempty"` - TerseErrors bool `json:"terseErrors,omitempty"` - MessagePostponeParallelism int `json:"messagePostponeParallelism,omitempty"` - CacheResultFields bool `json:"cacheResultFields,omitempty"` + Consolidator string `json:"consolidator,omitempty"` + HeartbeatIntervalSeconds float64 `json:"heartbeatIntervalSeconds,omitempty"` + ShutdownGracePeriodSeconds float64 `json:"shutdownGracePeriodSeconds,omitempty"` + PassthroughDML bool `json:"passthroughDML,omitempty"` + StreamBufferSize int `json:"streamBufferSize,omitempty"` + QueryCacheSize int `json:"queryCacheSize,omitempty"` + SchemaReloadIntervalSeconds float64 `json:"schemaReloadIntervalSeconds,omitempty"` + WatchReplication bool `json:"watchReplication,omitempty"` + TrackSchemaVersions bool `json:"trackSchemaVersions,omitempty"` + TerseErrors bool `json:"terseErrors,omitempty"` + MessagePostponeParallelism int `json:"messagePostponeParallelism,omitempty"` + CacheResultFields bool `json:"cacheResultFields,omitempty"` ExternalConnections map[string]*dbconfigs.DBConfigs `json:"externalConnections,omitempty"` @@ -231,19 +232,19 @@ type TabletConfig struct { // ConnPoolConfig contains the config for a conn pool. type ConnPoolConfig struct { - Size int `json:"size,omitempty"` - TimeoutSeconds int `json:"timeoutSeconds,omitempty"` - IdleTimeoutSeconds int `json:"idleTimeoutSeconds,omitempty"` - PrefillParallelism int `json:"prefillParallelism,omitempty"` - MaxWaiters int `json:"maxWaiters,omitempty"` + Size int `json:"size,omitempty"` + TimeoutSeconds float64 `json:"timeoutSeconds,omitempty"` + IdleTimeoutSeconds float64 `json:"idleTimeoutSeconds,omitempty"` + PrefillParallelism int `json:"prefillParallelism,omitempty"` + MaxWaiters int `json:"maxWaiters,omitempty"` } // OltpConfig contains the config for oltp settings. type OltpConfig struct { - QueryTimeoutSeconds int `json:"queryTimeoutSeconds,omitempty"` - TxTimeoutSeconds int `json:"txTimeoutSeconds,omitempty"` - MaxRows int `json:"maxRpws,omitempty"` - WarnRows int `json:"warnRows,omitempty"` + QueryTimeoutSeconds float64 `json:"queryTimeoutSeconds,omitempty"` + TxTimeoutSeconds float64 `json:"txTimeoutSeconds,omitempty"` + MaxRows int `json:"maxRpws,omitempty"` + WarnRows int `json:"warnRows,omitempty"` } // HotRowProtectionConfig contains the config for hot row protection.