Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions changelog/21.0/21.0.0/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- **[Deprecations and Deletions](#deprecations-and-deletions)**
- [Deletion of deprecated metrics](#metric-deletion)
- [VTTablet Flags](#vttablet-flags)
- [Metrics](#deprecations-metrics)
- **[Traffic Mirroring](#traffic-mirroring)**
- **[New VTGate Shutdown Behavior](#new-vtgate-shutdown-behavior)**
- **[Tablet Throttler: Multi-Metric support](#tablet-throttler)**
Expand Down Expand Up @@ -40,6 +41,20 @@ The following metrics that were deprecated in the previous release, have now bee
- `queryserver-enable-settings-pool` flag, added in v15, has been on by default since v17.
It is now deprecated and will be removed in a future release.

#### <a id="deprecations-metrics"/>Metrics

The following metrics are now deprecated, if provided please use their replacement.

| Component | Metric Name | Replaced By |
|------------|:---------------------:|:-------------------------------:|
| `vttablet` | `QueryCacheLength` | `QueryEnginePlanCacheLength` |
| `vttablet` | `QueryCacheSize` | `QueryEnginePlanCacheSize` |
| `vttablet` | `QueryCacheCapacity` | `QueryEnginePlanCacheCapacity` |
| `vttablet` | `QueryCacheEvictions` | `QueryEnginePlanCacheEvictions` |
| `vttablet` | `QueryCacheHits` | `QueryEnginePlanCacheHits` |
| `vttablet` | `QueryCacheMisses` | `QueryEnginePlanCacheMisses` |


### <a id="traffic-mirroring"/>Traffic Mirroring

Traffic mirroring is intended to help reduce some of the uncertainty inherent to `MoveTables SwitchTraffic`. When traffic mirroring is enabled, VTGate will mirror a percentage of traffic from one keyspace to another.
Expand Down
1 change: 0 additions & 1 deletion config/tablet/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ hotRowProtection:
consolidator: enable|disable|notOnPrimary # enable-consolidator, enable-consolidator-replicas
passthroughDML: false # queryserver-config-passthrough-dmls
streamBufferSize: 32768 # queryserver-config-stream-buffer-size
queryCacheSize: 5000 # queryserver-config-query-cache-size
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag was removed a while ago, I took the liberty of removing this from the config file.

schemaReloadIntervalSeconds: 1800 # queryserver-config-schema-reload-time
watchReplication: false # watch_replication_stream
terseErrors: false # queryserver-config-terse-errors
Expand Down
1 change: 0 additions & 1 deletion doc/design-docs/TabletServerParamsAsYAML.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ heartbeatIntervalMilliseconds: 0 # heartbeat_enable, heartbeat_interval
shutdownGracePeriodSeconds: 0 # transaction_shutdown_grace_period
passthroughDML: false # queryserver-config-passthrough-dmls
streamBufferSize: 32768 # queryserver-config-stream-buffer-size
queryCacheSize: 5000 # queryserver-config-query-cache-size
schemaReloadIntervalSeconds: 1800 # queryserver-config-schema-reload-time
watchReplication: false # watch_replication_stream
terseErrors: false # queryserver-config-terse-errors
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vttablet/endtoend/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func TestConsolidatorReplicasOnly(t *testing.T) {
}
}

func TestQueryPlanCache(t *testing.T) {
func TestQueryEnginePlanCacheSize(t *testing.T) {
var cachedPlanSize = int((&tabletserver.TabletPlan{}).CachedSize(true))

// sleep to avoid race between SchemaChanged event clearing out the plans cache which breaks this test
Expand All @@ -211,19 +211,19 @@ func TestQueryPlanCache(t *testing.T) {
assert.Equal(t, 1, framework.Server.QueryPlanCacheLen())

vend := framework.DebugVars()
assert.GreaterOrEqual(t, framework.FetchInt(vend, "QueryCacheSize"), cachedPlanSize)
assert.GreaterOrEqual(t, framework.FetchInt(vend, "QueryEnginePlanCacheSize"), cachedPlanSize)

_, _ = client.Execute("select * from vitess_test where intval=:ival2", bindVars)
require.Equal(t, 2, framework.Server.QueryPlanCacheLen())

vend = framework.DebugVars()
assert.GreaterOrEqual(t, framework.FetchInt(vend, "QueryCacheSize"), 2*cachedPlanSize)
assert.GreaterOrEqual(t, framework.FetchInt(vend, "QueryEnginePlanCacheSize"), 2*cachedPlanSize)

_, _ = client.Execute("select * from vitess_test where intval=1", bindVars)
require.Equal(t, 3, framework.Server.QueryPlanCacheLen())

vend = framework.DebugVars()
assert.GreaterOrEqual(t, framework.FetchInt(vend, "QueryCacheSize"), 3*cachedPlanSize)
assert.GreaterOrEqual(t, framework.FetchInt(vend, "QueryEnginePlanCacheSize"), 3*cachedPlanSize)
}

func TestMaxResultSize(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/endtoend/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func TestTrailingComment(t *testing.T) {
}
v2 := framework.Server.QueryPlanCacheLen()
if v2 != v1+1 {
t.Errorf("QueryCacheLength(%s): %d, want %d", query, v2, v1+1)
t.Errorf("QueryEnginePlanCacheLength(%s): %d, want %d", query, v2, v1+1)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion go/vt/vttablet/tabletserver/debugenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ func debugEnvHandler(tsv *TabletServer, w http.ResponseWriter, r *http.Request)
vars = addVar(vars, "PoolSize", tsv.PoolSize)
vars = addVar(vars, "StreamPoolSize", tsv.StreamPoolSize)
vars = addVar(vars, "TxPoolSize", tsv.TxPoolSize)
vars = addVar(vars, "QueryCacheCapacity", tsv.QueryPlanCacheCap)
vars = addVar(vars, "QueryCacheCapacity", tsv.QueryPlanCacheCap) // QueryCacheCapacity is deprecated in v21, it is replaced by QueryEnginePlanCacheCapacity
vars = addVar(vars, "QueryEnginePlanCacheCapacity", tsv.QueryPlanCacheCap)
vars = addVar(vars, "MaxResultSize", tsv.MaxResultSize)
vars = addVar(vars, "WarnResultSize", tsv.WarnResultSize)
vars = addVar(vars, "RowStreamerMaxInnoDBTrxHistLen", func() int64 { return tsv.Config().RowStreamer.MaxInnoDBTrxHistLen })
Expand Down
44 changes: 37 additions & 7 deletions go/vt/vttablet/tabletserver/query_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ type QueryEngine struct {
// stats
// Note: queryErrorCountsWithCode is similar to queryErrorCounts except it contains error code as an additional dimension
queryCounts, queryCountsWithTabletType, queryTimes, queryErrorCounts, queryErrorCountsWithCode, queryRowsAffected, queryRowsReturned, queryTextCharsProcessed *stats.CountersWithMultiLabels
queryCacheHits, queryCacheMisses *stats.CounterFunc
queryEnginePlanCacheHits, queryEnginePlanCacheMisses *stats.CounterFunc
queryCacheHitsDeprecated, queryCacheMissesDeprecated *stats.CounterFunc

// stats flags
enablePerWorkloadTableMetrics bool
Expand Down Expand Up @@ -269,22 +270,51 @@ func NewQueryEngine(env tabletenv.Env, se *schema.Engine) *QueryEngine {
env.Exporter().NewGaugeFunc("StreamBufferSize", "Query engine stream buffer size", qe.streamBufferSize.Load)
env.Exporter().NewCounterFunc("TableACLExemptCount", "Query engine table ACL exempt count", qe.tableaclExemptCount.Load)

env.Exporter().NewGaugeFunc("QueryCacheLength", "Query engine query plan cache length", func() int64 {
// QueryCacheLength is deprecated in v21 and will be removed in >=v22. This metric is replaced by QueryEnginePlanCacheLength.
env.Exporter().NewGaugeFunc("QueryCacheLength", "Query engine query plan cache length (deprecated: please use QueryEnginePlanCacheLength)", func() int64 {
return int64(qe.plans.Len())
})
env.Exporter().NewGaugeFunc("QueryCacheSize", "Query engine query plan cache size", func() int64 {
env.Exporter().NewGaugeFunc("QueryEnginePlanCacheLength", "Query engine query plan cache length", func() int64 {
return int64(qe.plans.Len())
})

// QueryCacheSize is deprecated in v21 and will be removed in >=v22. This metric is replaced QueryEnginePlanCacheSize.
env.Exporter().NewGaugeFunc("QueryCacheSize", "Query engine query plan cache size (deprecated: please use QueryEnginePlanCacheSize)", func() int64 {
return int64(qe.plans.UsedCapacity())
})
env.Exporter().NewGaugeFunc("QueryEnginePlanCacheSize", "Query engine query plan cache size", func() int64 {
return int64(qe.plans.UsedCapacity())
})
env.Exporter().NewGaugeFunc("QueryCacheCapacity", "Query engine query plan cache capacity", func() int64 {

// QueryCacheCapacity is deprecated in v21 and will be removed in >=v22. This metric is replaced by QueryEnginePlanCacheCapacity.
env.Exporter().NewGaugeFunc("QueryCacheCapacity", "Query engine query plan cache capacity (deprecated: please use QueryEnginePlanCacheCapacity)", func() int64 {
return int64(qe.plans.MaxCapacity())
})
env.Exporter().NewGaugeFunc("QueryEnginePlanCacheCapacity", "Query engine query plan cache capacity", func() int64 {
return int64(qe.plans.MaxCapacity())
})
env.Exporter().NewCounterFunc("QueryCacheEvictions", "Query engine query plan cache evictions", func() int64 {

// QueryCacheEvictions is deprecated in v21 and will be removed in >=v22. This metric is replaced by QueryEnginePlanCacheEvictions.
env.Exporter().NewCounterFunc("QueryCacheEvictions", "Query engine query plan cache evictions (deprecated: please use QueryEnginePlanCacheEvictions)", func() int64 {
return qe.plans.Metrics.Evicted()
})
qe.queryCacheHits = env.Exporter().NewCounterFunc("QueryCacheHits", "Query engine query plan cache hits", func() int64 {
env.Exporter().NewCounterFunc("QueryEnginePlanCacheEvictions", "Query engine query plan cache evictions", func() int64 {
return qe.plans.Metrics.Evicted()
})

// QueryCacheHits is deprecated in v21 and will be removed in >=v22. This metric is replaced by QueryEnginePlanCacheHits.
qe.queryCacheHitsDeprecated = env.Exporter().NewCounterFunc("QueryCacheHits", "Query engine query plan cache hits (deprecated: please use QueryEnginePlanCacheHits)", func() int64 {
return qe.plans.Metrics.Hits()
})
qe.queryEnginePlanCacheHits = env.Exporter().NewCounterFunc("QueryEnginePlanCacheHits", "Query engine query plan cache hits", func() int64 {
return qe.plans.Metrics.Hits()
})
qe.queryCacheMisses = env.Exporter().NewCounterFunc("QueryCacheMisses", "Query engine query plan cache misses", func() int64 {

// QueryCacheMisses is deprecated in v21 and will be removed in >=v22. This metric is replaced by QueryEnginePlanCacheMisses.
qe.queryCacheMissesDeprecated = env.Exporter().NewCounterFunc("QueryCacheMisses", "Query engine query plan cache misses (deprecated: please use QueryEnginePlanCacheMisses)", func() int64 {
return qe.plans.Metrics.Misses()
})
qe.queryEnginePlanCacheMisses = env.Exporter().NewCounterFunc("QueryEnginePlanCacheMisses", "Query engine query plan cache misses", func() int64 {
return qe.plans.Metrics.Misses()
})

Expand Down
20 changes: 14 additions & 6 deletions go/vt/vttablet/tabletserver/query_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,26 +197,34 @@ func TestQueryPlanCache(t *testing.T) {
ctx := context.Background()
logStats := tabletenv.NewLogStats(ctx, "GetPlanStats")

initialHits := qe.queryCacheHits.Get()
initialMisses := qe.queryCacheMisses.Get()
Comment on lines -200 to -201
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to ensure that we keep testing the old metrics until we delete them, we should keep the tests for them. That will require keeping the struct members also around until the metrics are deleted. Each vttablet has one instance of the queryEngine, so it should not be a big deal.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done via ade9210

initialHits := qe.queryEnginePlanCacheHits.Get()
initialMisses := qe.queryEnginePlanCacheMisses.Get()
initialHitsDeprecated := qe.queryCacheHitsDeprecated.Get()
initialMissesDeprecated := qe.queryCacheMissesDeprecated.Get()

firstPlan, err := qe.GetPlan(ctx, logStats, firstQuery, false)
require.NoError(t, err)
require.NotNil(t, firstPlan, "plan should not be nil")

assertPlanCacheSize(t, qe, 1)

require.Equal(t, int64(0), qe.queryCacheHits.Get()-initialHits)
require.Equal(t, int64(1), qe.queryCacheMisses.Get()-initialMisses)
require.Equal(t, int64(0), qe.queryEnginePlanCacheHits.Get()-initialHits)
require.Equal(t, int64(1), qe.queryEnginePlanCacheMisses.Get()-initialMisses)

require.Equal(t, int64(0), qe.queryCacheHitsDeprecated.Get()-initialHitsDeprecated)
require.Equal(t, int64(1), qe.queryCacheMissesDeprecated.Get()-initialMissesDeprecated)

secondPlan, err := qe.GetPlan(ctx, logStats, firstQuery, false)
require.NoError(t, err)
require.NotNil(t, secondPlan, "plan should not be nil")

assertPlanCacheSize(t, qe, 1)

require.Equal(t, int64(1), qe.queryCacheHits.Get()-initialHits)
require.Equal(t, int64(1), qe.queryCacheMisses.Get()-initialMisses)
require.Equal(t, int64(1), qe.queryEnginePlanCacheHits.Get()-initialHits)
require.Equal(t, int64(1), qe.queryEnginePlanCacheMisses.Get()-initialMisses)

require.Equal(t, int64(1), qe.queryCacheHitsDeprecated.Get()-initialHitsDeprecated)
require.Equal(t, int64(1), qe.queryCacheMissesDeprecated.Get()-initialMissesDeprecated)

qe.ClearQueryPlanCache()
}
Expand Down