Skip to content

Commit

Permalink
VTGate Warnings: Add WarnUnshardedOnly to warnings counter (#15033)
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Coleman <tyler@planetscale.com>
  • Loading branch information
tycol7 committed Feb 14, 2024
1 parent c4d2a5a commit db5aedd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion go/vt/vtgate/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -2619,13 +2619,15 @@ 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})
_, err := executor.Execute(ctx, nil, "TestExecutorTempTable", session, creatQuery, nil)
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()

Expand Down
1 change: 1 addition & 0 deletions go/vt/vtgate/vcursor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/vtgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit db5aedd

Please sign in to comment.