Skip to content

Commit

Permalink
address
Browse files Browse the repository at this point in the history
Signed-off-by: nolouch <nolouch@gmail.com>
  • Loading branch information
nolouch committed Jul 5, 2023
1 parent 07791ab commit 2deabb3
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 18 deletions.
5 changes: 3 additions & 2 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3871,8 +3871,9 @@ def go_deps():
name = "com_github_tikv_client_go_v2",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/client-go/v2",
sum = "h1:KIqPtZ+U4RLuqL6wjobTnNn+111esFtu7+bY/50KKP4=",
version = "v2.0.8-0.20230621031026-864a5fc0c482",
replace = "github.com/nolouch/client-go/v2",
sum = "h1:T7YjnmguXAvSLXmV7+sIeMllYdDBLGOyGK13AyFVjRs=",
version = "v2.0.0-alpha.0.20230705081011-2596ac95a7c0",
)

go_repository(
Expand Down
2 changes: 1 addition & 1 deletion distsql/request_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (builder *RequestBuilder) SetFromSessionVars(sv *variable.SessionVars) *Req
}
builder.RequestSource.RequestSourceInternal = sv.InRestrictedSQL
builder.RequestSource.RequestSourceType = sv.RequestSourceType
builder.RequestSource.ExplicitRequestSoureType = sv.ExplicitRequestSoureType
builder.RequestSource.ExplicitRequestSourceType = sv.ExplicitRequestSourceType
builder.StoreBatchSize = sv.StoreBatchSize
builder.Request.ResourceGroupName = sv.ResourceGroupName
builder.Request.StoreBusyThreshold = sv.LoadBasedReplicaReadThreshold
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,4 @@ replace (
go.opencensus.io => go.opencensus.io v0.23.1-0.20220331163232-052120675fac
)

replace github.com/tikv/client-go/v2 => github.com/nolouch/client-go/v2 v2.0.0-alpha.0.20230705075110-157d072330bf
replace github.com/tikv/client-go/v2 => github.com/nolouch/client-go/v2 v2.0.0-alpha.0.20230705081011-2596ac95a7c0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,8 @@ github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef/go.mod h1:7WjlapSfwQyo
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk=
github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c=
github.com/nolouch/client-go/v2 v2.0.0-alpha.0.20230705075110-157d072330bf h1:N1wvE/FIEU1Ak3kBPIoOBFsMeUf0raxAekqOnYHqrCQ=
github.com/nolouch/client-go/v2 v2.0.0-alpha.0.20230705075110-157d072330bf/go.mod h1:4KkKqjJgKlvvWMyNqdnAlYFfV4QjEj1fEb5Hb/FoT88=
github.com/nolouch/client-go/v2 v2.0.0-alpha.0.20230705081011-2596ac95a7c0 h1:T7YjnmguXAvSLXmV7+sIeMllYdDBLGOyGK13AyFVjRs=
github.com/nolouch/client-go/v2 v2.0.0-alpha.0.20230705081011-2596ac95a7c0/go.mod h1:4KkKqjJgKlvvWMyNqdnAlYFfV4QjEj1fEb5Hb/FoT88=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
Expand Down
4 changes: 2 additions & 2 deletions kv/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ const (
RequestSourceInternal
// RequestSourceType set request source type of the current statement.
RequestSourceType
// ExplicitRequestSoureType is a complement of RequestSourceType, it may specified by the client or users.
ExplicitRequestSoureType
// ExplicitRequestSourceType is a complement of RequestSourceType, it may specified by the client or users.
ExplicitRequestSourceType
// ReplicaReadAdjuster set the adjust function of cop requsts.
ReplicaReadAdjuster
// ScanBatchSize set the iter scan batch size.
Expand Down
2 changes: 1 addition & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ func (s *session) doCommit(ctx context.Context) error {
s.txn.SetOption(kv.EnableAsyncCommit, sessVars.EnableAsyncCommit)
s.txn.SetOption(kv.Enable1PC, sessVars.Enable1PC)
s.txn.SetOption(kv.ResourceGroupTagger, sessVars.StmtCtx.GetResourceGroupTagger())
s.txn.SetOption(kv.ExplicitRequestSoureType, sessVars.ExplicitRequestSoureType)
s.txn.SetOption(kv.ExplicitRequestSourceType, sessVars.ExplicitRequestSourceType)
if sessVars.StmtCtx.KvExecCounter != nil {
// Bind an interceptor for client-go to count the number of SQL executions of each TiKV.
s.txn.SetOption(kv.RPCInterceptor, sessVars.StmtCtx.KvExecCounter.RPCInterceptor())
Expand Down
4 changes: 4 additions & 0 deletions session/sessiontest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ go_test(
"//util/memory",
"//util/sqlexec",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_kvproto//pkg/coprocessor",
"@com_github_pingcap_kvproto//pkg/kvrpcpb",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//tikv",
"@com_github_tikv_client_go_v2//tikvrpc",
"@com_github_tikv_client_go_v2//tikvrpc/interceptor",
"@com_github_tikv_client_go_v2//txnkv/transaction",
"@org_uber_go_goleak//:goleak",
],
Expand Down
6 changes: 3 additions & 3 deletions sessionctx/sessionstates/session_states_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,13 @@ func TestSessionCtx(t *testing.T) {
{
// check reqest source
setFunc: func(tk *testkit.TestKit) any {
tk.MustExec(`set @@tidb_reqest_source="BR"`)
require.Equal(t, "BR", tk.Session().GetSessionVars().RequestSourceType)
tk.MustExec(`set @@tidb_request_source_type="lightning"`)
require.Equal(t, "lightning", tk.Session().GetSessionVars().ExplicitRequestSourceType)
return nil
},
checkFunc: func(tk *testkit.TestKit, param any) {
tk.MustExec(`select count(*) from test.t1`)
tk.MustQuery(`select @@tidb_reqest_source`).Check(testkit.Rows("BR"))
tk.MustQuery(`select @@tidb_request_source_type`).Check(testkit.Rows("lightning"))
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1323,8 +1323,8 @@ type SessionVars struct {

// RequestSourceType is the type of inner request.
RequestSourceType string
// ExplicitRequestSoureType is the type of origin external request.
ExplicitRequestSoureType string
// ExplicitRequestSourceType is the type of origin external request.
ExplicitRequestSourceType string

// MemoryDebugModeMinHeapInUse indicated the minimum heapInUse threshold that triggers the memoryDebugMode.
MemoryDebugModeMinHeapInUse int64
Expand Down
7 changes: 4 additions & 3 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import (
"github.com/pingcap/tidb/util/versioninfo"
tikvcfg "github.com/tikv/client-go/v2/config"
tikvstore "github.com/tikv/client-go/v2/kv"
tikvcliutil "github.com/tikv/client-go/v2/util"
atomic2 "go.uber.org/atomic"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -384,10 +385,10 @@ var defaultSysVars = []*SysVar{
{Scope: ScopeSession, Name: TiDBUseAlloc, Value: BoolToOnOff(DefTiDBUseAlloc), Type: TypeBool, ReadOnly: true, GetSession: func(s *SessionVars) (string, error) {
return BoolToOnOff(s.preUseChunkAlloc), nil
}},
{Scope: ScopeSession, Name: TiDBExplicitRequestSourceType, Value: "", Type: TypeEnum, PossibleValues: []string{"", "lightning", "br", "dumping", "tispark", "background"}, GetSession: func(s *SessionVars) (string, error) {
return s.ExplicitRequestSoureType, nil
{Scope: ScopeSession, Name: TiDBExplicitRequestSourceType, Value: "", Type: TypeEnum, PossibleValues: tikvcliutil.ExplictTypeList, GetSession: func(s *SessionVars) (string, error) {
return s.ExplicitRequestSourceType, nil
}, SetSession: func(s *SessionVars, val string) error {
s.ExplicitRequestSoureType = val
s.ExplicitRequestSourceType = val
return nil
}},
/* The system variables below have INSTANCE scope */
Expand Down
1 change: 1 addition & 0 deletions store/copr/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ go_library(
"@com_github_tikv_client_go_v2//metrics",
"@com_github_tikv_client_go_v2//tikv",
"@com_github_tikv_client_go_v2//tikvrpc",
"@com_github_tikv_client_go_v2//tikvrpc/interceptor",
"@com_github_tikv_client_go_v2//txnkv/txnlock",
"@com_github_tikv_client_go_v2//txnkv/txnsnapshot",
"@com_github_tikv_client_go_v2//util",
Expand Down
2 changes: 1 addition & 1 deletion store/driver/txn/txn_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (txn *tikvTxn) SetOption(opt int, val interface{}) {
txn.KVTxn.SetRequestSourceInternal(val.(bool))
case kv.RequestSourceType:
txn.KVTxn.SetRequestSourceType(val.(string))
case kv.ExplicitRequestSoureType:
case kv.ExplicitRequestSourceType:
txn.KVTxn.SetExplicitRequestSourceType(val.(string))
case kv.ReplicaReadAdjuster:
txn.KVTxn.GetSnapshot().SetReplicaReadAdjuster(val.(txnkv.ReplicaReadAdjuster))
Expand Down

0 comments on commit 2deabb3

Please sign in to comment.