diff --git a/changelog/21.0/21.0.0/summary.md b/changelog/21.0/21.0.0/summary.md index b1ae99eb3cf..0d046ae9d75 100644 --- a/changelog/21.0/21.0.0/summary.md +++ b/changelog/21.0/21.0.0/summary.md @@ -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)** @@ -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. +#### 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` | + + ### 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. diff --git a/config/tablet/default.yaml b/config/tablet/default.yaml index ec9d1f94833..d0e4eca477b 100644 --- a/config/tablet/default.yaml +++ b/config/tablet/default.yaml @@ -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 schemaReloadIntervalSeconds: 1800 # queryserver-config-schema-reload-time watchReplication: false # watch_replication_stream terseErrors: false # queryserver-config-terse-errors diff --git a/doc/design-docs/TabletServerParamsAsYAML.md b/doc/design-docs/TabletServerParamsAsYAML.md index 52d48a5e6f6..e14712f4ff8 100644 --- a/doc/design-docs/TabletServerParamsAsYAML.md +++ b/doc/design-docs/TabletServerParamsAsYAML.md @@ -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 diff --git a/go/vt/vttablet/endtoend/config_test.go b/go/vt/vttablet/endtoend/config_test.go index b1dc7f5dcb9..3902113f354 100644 --- a/go/vt/vttablet/endtoend/config_test.go +++ b/go/vt/vttablet/endtoend/config_test.go @@ -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 @@ -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) { diff --git a/go/vt/vttablet/endtoend/misc_test.go b/go/vt/vttablet/endtoend/misc_test.go index 768399572db..29bbba56873 100644 --- a/go/vt/vttablet/endtoend/misc_test.go +++ b/go/vt/vttablet/endtoend/misc_test.go @@ -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) } } } diff --git a/go/vt/vttablet/tabletserver/debugenv.go b/go/vt/vttablet/tabletserver/debugenv.go index 924d5acbebb..54cf09db7d6 100644 --- a/go/vt/vttablet/tabletserver/debugenv.go +++ b/go/vt/vttablet/tabletserver/debugenv.go @@ -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 }) diff --git a/go/vt/vttablet/tabletserver/query_engine.go b/go/vt/vttablet/tabletserver/query_engine.go index f8245ac8e2f..d0542165878 100644 --- a/go/vt/vttablet/tabletserver/query_engine.go +++ b/go/vt/vttablet/tabletserver/query_engine.go @@ -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 @@ -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() }) diff --git a/go/vt/vttablet/tabletserver/query_engine_test.go b/go/vt/vttablet/tabletserver/query_engine_test.go index 199dc0cf334..a1c293ea8ba 100644 --- a/go/vt/vttablet/tabletserver/query_engine_test.go +++ b/go/vt/vttablet/tabletserver/query_engine_test.go @@ -197,8 +197,10 @@ func TestQueryPlanCache(t *testing.T) { ctx := context.Background() logStats := tabletenv.NewLogStats(ctx, "GetPlanStats") - initialHits := qe.queryCacheHits.Get() - initialMisses := qe.queryCacheMisses.Get() + 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) @@ -206,8 +208,11 @@ func TestQueryPlanCache(t *testing.T) { 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) @@ -215,8 +220,11 @@ func TestQueryPlanCache(t *testing.T) { 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() }