Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport #6250 to 6.0 release branch #6320

Merged
merged 4 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go/vt/vttablet/heartbeat/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/heartbeat/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/heartbeat/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/heartbeat/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletmanager/heartbeat_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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 @@ -275,9 +275,9 @@ func TestStatsURL(t *testing.T) {
func newTestQueryEngine(queryCacheSize int, idleTimeout time.Duration, strict bool, dbcfgs *dbconfigs.DBConfigs) *QueryEngine {
config := tabletenv.NewDefaultConfig()
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.NewTestEnv(config, dbcfgs, "TabletServerTest")
se := schema.NewEngine(env)
qe := NewQueryEngine(env, se)
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 @@ -301,10 +301,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.NewTestEnv(config, nil, "SchemaTest"))
se.InitDBConfig(newDBConfigs(db).DbaWithDB())
return se
Expand Down
69 changes: 36 additions & 33 deletions go/vt/vttablet/tabletserver/tabletenv/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ func init() {
flag.IntVar(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.ShutdownGracePeriodSeconds, "transaction_shutdown_grace_period", defaultConfig.ShutdownGracePeriodSeconds, "how long to wait (in seconds) for transactions to complete during graceful shutdown.")
flag.Float64Var(&currentConfig.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(&currentConfig.ShutdownGracePeriodSeconds, "transaction_shutdown_grace_period", defaultConfig.ShutdownGracePeriodSeconds, "how long to wait (in seconds) for transactions to complete during graceful shutdown.")
flag.IntVar(&currentConfig.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(&currentConfig.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. ")
Expand All @@ -95,11 +95,12 @@ func init() {

flag.IntVar(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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(&currentConfig.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.
Expand Down Expand Up @@ -167,7 +168,7 @@ func Init() {
}

if enableHeartbeat {
currentConfig.HeartbeatIntervalMilliseconds = int(heartbeatInterval / time.Millisecond)
currentConfig.HeartbeatIntervalSeconds = float64(heartbeatInterval) / float64(time.Millisecond)
}

switch *streamlog.QueryLogFormat {
Expand All @@ -190,22 +191,24 @@ func Init() {
type TabletConfig struct {
DB *dbconfigs.DBConfigs `json:"db,omitempty"`

OltpReadPool ConnPoolConfig `json:"oltpReadPool,omitempty"`
OlapReadPool ConnPoolConfig `json:"olapReadPool,omitempty"`
TxPool ConnPoolConfig `json:"txPool,omitempty"`
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"`
TerseErrors bool `json:"terseErrors,omitempty"`
MessagePostponeParallelism int `json:"messagePostponeParallelism,omitempty"`
CacheResultFields bool `json:"cacheResultFields,omitempty"`
OltpReadPool ConnPoolConfig `json:"oltpReadPool,omitempty"`
OlapReadPool ConnPoolConfig `json:"olapReadPool,omitempty"`
TxPool ConnPoolConfig `json:"txPool,omitempty"`

Oltp OltpConfig `json:"oltp,omitempty"`
HotRowProtection HotRowProtectionConfig `json:"hotRowProtection,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"`
TerseErrors bool `json:"terseErrors,omitempty"`
MessagePostponeParallelism int `json:"messagePostponeParallelism,omitempty"`
CacheResultFields bool `json:"cacheResultFields,omitempty"`

StrictTableACL bool `json:"-"`
EnableTableACLDryRun bool `json:"-"`
Expand All @@ -225,19 +228,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.
Expand Down