From db5aedd1e76d9ecbbdc630017e61ac1e8a5d461c Mon Sep 17 00:00:00 2001 From: Tyler Date: Wed, 14 Feb 2024 08:09:23 -0800 Subject: [PATCH] VTGate Warnings: Add `WarnUnshardedOnly` to warnings counter (#15033) Signed-off-by: Tyler Coleman --- go/vt/vtgate/executor_test.go | 4 +++- go/vt/vtgate/vcursor_impl.go | 1 + go/vt/vtgate/vtgate.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/go/vt/vtgate/executor_test.go b/go/vt/vtgate/executor_test.go index 1670d64b6fc..5df4c7887f6 100644 --- a/go/vt/vtgate/executor_test.go +++ b/go/vt/vtgate/executor_test.go @@ -1216,7 +1216,7 @@ func TestExecutorDDL(t *testing.T) { "drop table t2", `create table test_partitioned ( id bigint, - date_create int, + date_create int, primary key(id) ) Engine=InnoDB /*!50100 PARTITION BY RANGE (date_create) (PARTITION p2018_06_14 VALUES LESS THAN (1528959600) ENGINE = InnoDB, @@ -2619,6 +2619,7 @@ func TestExecutorCallProc(t *testing.T) { func TestExecutorTempTable(t *testing.T) { executor, _, _, sbcUnsharded, ctx := createExecutorEnv(t) + initialWarningsCount := warnings.Counts()["WarnUnshardedOnly"] executor.warnShardedOnly = true creatQuery := "create temporary table temp_t(id bigint primary key)" session := NewSafeSession(&vtgatepb.Session{TargetString: KsTestUnsharded}) @@ -2626,6 +2627,7 @@ func TestExecutorTempTable(t *testing.T) { require.NoError(t, err) assert.EqualValues(t, 1, sbcUnsharded.ExecCount.Load()) assert.NotEmpty(t, session.Warnings) + assert.Equal(t, initialWarningsCount+1, warnings.Counts()["WarnUnshardedOnly"], "warnings count") before := executor.plans.Len() diff --git a/go/vt/vtgate/vcursor_impl.go b/go/vt/vtgate/vcursor_impl.go index 67093046ded..18508a2e94c 100644 --- a/go/vt/vtgate/vcursor_impl.go +++ b/go/vt/vtgate/vcursor_impl.go @@ -1040,6 +1040,7 @@ func (vc *vcursorImpl) WarnUnshardedOnly(format string, params ...any) { Code: uint32(sqlerror.ERNotSupportedYet), Message: fmt.Sprintf(format, params...), }) + warnings.Add("WarnUnshardedOnly", 1) } } diff --git a/go/vt/vtgate/vtgate.go b/go/vt/vtgate/vtgate.go index c8c0df217af..477a1e40cae 100644 --- a/go/vt/vtgate/vtgate.go +++ b/go/vt/vtgate/vtgate.go @@ -187,7 +187,7 @@ var ( // Error counters should be global so they can be set from anywhere errorCounts = stats.NewCountersWithMultiLabels("VtgateApiErrorCounts", "Vtgate API error counts per error type", []string{"Operation", "Keyspace", "DbType", "Code"}) - warnings = stats.NewCountersWithSingleLabel("VtGateWarnings", "Vtgate warnings", "type", "IgnoredSet", "ResultsExceeded", "WarnPayloadSizeExceeded", "NonAtomicCommit") + warnings = stats.NewCountersWithSingleLabel("VtGateWarnings", "Vtgate warnings", "type", "IgnoredSet", "NonAtomicCommit", "ResultsExceeded", "WarnPayloadSizeExceeded", "WarnUnshardedOnly") vstreamSkewDelayCount = stats.NewCounter("VStreamEventsDelayedBySkewAlignment", "Number of events that had to wait because the skew across shards was too high")