Skip to content

Commit

Permalink
executor: support left outer semi join for hash join v2 (pingcap#57053)
Browse files Browse the repository at this point in the history
ref pingcap#53127

handle key-too-large error from MemBuffer

Signed-off-by: you06 <[email protected]>

test MemBuffer's oversize error to tidb error

Signed-off-by: you06 <[email protected]>

update errdoc

Signed-off-by: you06 <[email protected]>
  • Loading branch information
wshwsh12 authored and ti-chi-bot committed Nov 20, 2024
1 parent 9398d00 commit 8cf9fcc
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 2 deletions.
5 changes: 5 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2171,6 +2171,11 @@ error = '''
not implemented
'''

["kv:8178"]
error = '''
key is too large, the size of given key is %d
'''

["kv:9007"]
error = '''
Write conflict, txnStartTS=%d, conflictStartTS=%d, conflictCommitTS=%d, key=%s%s%s%s, reason=%s [try again later]
Expand Down
1 change: 1 addition & 0 deletions pkg/errno/errcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ const (
ErrMemoryExceedForQuery = 8175
ErrMemoryExceedForInstance = 8176
ErrDeleteNotFoundColumn = 8177
ErrKeyTooLarge = 8178

// Error codes used by TiDB ddl package
ErrUnsupportedDDLOperation = 8200
Expand Down
4 changes: 3 additions & 1 deletion pkg/errno/errname.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,9 @@ var MySQLErrName = map[uint16]*mysql.ErrMessage{
ErrMemoryExceedForQuery: mysql.Message("Your query has been cancelled due to exceeding the allowed memory limit for a single SQL query. Please try narrowing your query scope or increase the tidb_mem_quota_query limit and try again.[conn=%d]", nil),
ErrMemoryExceedForInstance: mysql.Message("Your query has been cancelled due to exceeding the allowed memory limit for the tidb-server instance and this query is currently using the most memory. Please try narrowing your query scope or increase the tidb_server_memory_limit and try again.[conn=%d]", nil),
ErrDeleteNotFoundColumn: mysql.Message("Delete can not find column %s for table %s", nil),
ErrHTTPServiceError: mysql.Message("HTTP request failed with status %s", nil),
ErrKeyTooLarge: mysql.Message("key is too large, the size of given key is %d", nil),

ErrHTTPServiceError: mysql.Message("HTTP request failed with status %s", nil),

ErrWarnOptimizerHintInvalidInteger: mysql.Message("integer value is out of range in '%s'", nil),
ErrWarnOptimizerHintUnsupportedHint: mysql.Message("Optimizer hint %s is not supported by TiDB and is ignored", nil),
Expand Down
2 changes: 2 additions & 0 deletions pkg/kv/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ var (
ErrTxnTooLarge = dbterror.ClassKV.NewStd(mysql.ErrTxnTooLarge)
// ErrEntryTooLarge is the error when a key value entry is too large.
ErrEntryTooLarge = dbterror.ClassKV.NewStd(mysql.ErrEntryTooLarge)
// ErrKeyTooLarge is the error when a key is too large to be handled by MemBuffer.
ErrKeyTooLarge = dbterror.ClassKV.NewStd(mysql.ErrKeyTooLarge)
// ErrKeyExists returns when key is already exist. Caller should try to use
// GenKeyExistsErr to generate this error for correct format.
ErrKeyExists = dbterror.ClassKV.NewStd(mysql.ErrDupEntry)
Expand Down
5 changes: 5 additions & 0 deletions pkg/store/driver/error/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ func ToTiDBErr(err error) error {
return kv.ErrEntryTooLarge.GenWithStackByArgs(entryTooLarge.Limit, entryTooLarge.Size)
}

var keyTooLarge *tikverr.ErrKeyTooLarge
if stderrs.As(err, &keyTooLarge) {
return kv.ErrKeyTooLarge.GenWithStackByArgs(keyTooLarge.KeySize)
}

if stderrs.Is(err, tikverr.ErrInvalidTxn) {
return kv.ErrInvalidTxn
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/store/driver/error/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package error //nolint: predeclared

import (
"math"
"testing"

"github.com/pingcap/errors"
Expand Down Expand Up @@ -52,3 +53,16 @@ func TestConvertError(t *testing.T) {
assert.True(t, errors.ErrorEqual(tidbErr, terror.ErrResultUndetermined))
}
}

func TestMemBufferOversizeError(t *testing.T) {
err2str := map[error]string{
&tikverr.ErrTxnTooLarge{Size: 100}: "Transaction is too large, size: 100",
&tikverr.ErrEntryTooLarge{Limit: 10, Size: 20}: "entry too large, the max entry size is 10, the size of data is 20",
&tikverr.ErrKeyTooLarge{KeySize: math.MaxUint16 + 1}: "key is too large, the size of given key is 65536",
}
for err, errString := range err2str {
tidbErr := ToTiDBErr(err)
assert.NotNil(t, tidbErr)
assert.Contains(t, tidbErr.Error(), errString)
}
}
2 changes: 1 addition & 1 deletion pkg/store/driver/txn/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ go_test(
],
embed = [":txn"],
flaky = True,
shard_count = 5,
shard_count = 6,
deps = [
"//pkg/kv",
"//pkg/testkit/testsetup",
Expand Down
4 changes: 4 additions & 0 deletions pkg/store/driver/txn/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,7 @@ func TestWriteConflictPrettyFormat(t *testing.T) {
"key=‹›‹{metaKey=true, key=DB:56, field=TID:108}, originalKey=6d44423a3536000000fc00000000000000685449443a31303800fe, primary=›‹›‹{metaKey=true, key=DB:56, field=TID:108}, originalPrimaryKey=6d44423a3536000000fc00000000000000685449443a31303800fe›, reason=Optimistic " + kv.TxnRetryableMark
require.EqualError(t, newWriteConflictError(conflict), expectedStr)
}

func TestKeyValueOversize(t *testing.T) {
//key := make([]byte, math.MaxUint16+1)
}

0 comments on commit 8cf9fcc

Please sign in to comment.