diff --git a/config/client.go b/config/client.go index 29ad176670..ad75122eb7 100644 --- a/config/client.go +++ b/config/client.go @@ -92,7 +92,8 @@ type TiKVClient struct { ResolveLockLiteThreshold uint64 `toml:"resolve-lock-lite-threshold" json:"resolve-lock-lite-threshold"` // MaxConcurrencyRequestLimit is the max concurrency number of request to be sent the tikv // 0 means auto adjust by feedback. - MaxConcurrencyRequestLimit int64 `toml:"max-concurrency-request-limit" json:"max-concurrency-request-limit"` + MaxConcurrencyRequestLimit int64 `toml:"max-concurrency-request-limit" json:"max-concurrency-request-limit"` + GrpcExpectDuration uint64 `toml:"grpc-expect-duration" json:"grpc-expect-duration"` } // AsyncCommit is the config for the async commit feature. The switch to enable it is a system variable. @@ -164,6 +165,7 @@ func DefaultTiKVClient() TiKVClient { ResolveLockLiteThreshold: 16, MaxConcurrencyRequestLimit: math.MaxInt64, + GrpcExpectDuration: 2, } } diff --git a/examples/gcworker/go.mod b/examples/gcworker/go.mod index b9cd464356..c03367da67 100644 --- a/examples/gcworker/go.mod +++ b/examples/gcworker/go.mod @@ -20,7 +20,7 @@ require ( github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c // indirect - github.com/pingcap/kvproto v0.0.0-20231222062942-c0c73f41d0b2 // indirect + github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 // indirect github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 // indirect diff --git a/examples/rawkv/go.mod b/examples/rawkv/go.mod index 736a075ae5..095e598505 100644 --- a/examples/rawkv/go.mod +++ b/examples/rawkv/go.mod @@ -5,7 +5,6 @@ go 1.21 require github.com/tikv/client-go/v2 v2.0.0 require ( - github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudfoundry/gosigar v1.3.6 // indirect @@ -18,11 +17,10 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/uuid v1.4.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c // indirect - github.com/pingcap/kvproto v0.0.0-20231222062942-c0c73f41d0b2 // indirect + github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 // indirect github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 // indirect @@ -45,6 +43,7 @@ require ( golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/grpc v1.61.1 // indirect google.golang.org/protobuf v1.32.0 // indirect diff --git a/examples/txnkv/1pc_txn/go.mod b/examples/txnkv/1pc_txn/go.mod index 875ef93704..ade3bd2b4a 100644 --- a/examples/txnkv/1pc_txn/go.mod +++ b/examples/txnkv/1pc_txn/go.mod @@ -5,7 +5,6 @@ go 1.21 require github.com/tikv/client-go/v2 v2.0.0 require ( - github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudfoundry/gosigar v1.3.6 // indirect @@ -18,11 +17,10 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/uuid v1.4.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c // indirect - github.com/pingcap/kvproto v0.0.0-20231222062942-c0c73f41d0b2 // indirect + github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 // indirect github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 // indirect @@ -45,6 +43,8 @@ require ( golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/grpc v1.61.1 // indirect google.golang.org/protobuf v1.32.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/examples/txnkv/async_commit/go.mod b/examples/txnkv/async_commit/go.mod index a85bb7d812..56142e4136 100644 --- a/examples/txnkv/async_commit/go.mod +++ b/examples/txnkv/async_commit/go.mod @@ -5,7 +5,6 @@ go 1.21 require github.com/tikv/client-go/v2 v2.0.0 require ( - github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudfoundry/gosigar v1.3.6 // indirect @@ -18,11 +17,10 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/uuid v1.4.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c // indirect - github.com/pingcap/kvproto v0.0.0-20231222062942-c0c73f41d0b2 // indirect + github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 // indirect github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 // indirect @@ -45,6 +43,8 @@ require ( golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/grpc v1.61.1 // indirect google.golang.org/protobuf v1.32.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/examples/txnkv/delete_range/go.mod b/examples/txnkv/delete_range/go.mod index 1b0a371454..22bf3cdaf7 100644 --- a/examples/txnkv/delete_range/go.mod +++ b/examples/txnkv/delete_range/go.mod @@ -5,7 +5,6 @@ go 1.21 require github.com/tikv/client-go/v2 v2.0.0 require ( - github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudfoundry/gosigar v1.3.6 // indirect @@ -18,11 +17,10 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/uuid v1.4.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c // indirect - github.com/pingcap/kvproto v0.0.0-20231222062942-c0c73f41d0b2 // indirect + github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 // indirect github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 // indirect @@ -45,6 +43,8 @@ require ( golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/grpc v1.61.1 // indirect google.golang.org/protobuf v1.32.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/examples/txnkv/go.mod b/examples/txnkv/go.mod index 2f707b4487..3456855153 100644 --- a/examples/txnkv/go.mod +++ b/examples/txnkv/go.mod @@ -22,7 +22,7 @@ require ( github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c // indirect - github.com/pingcap/kvproto v0.0.0-20231222062942-c0c73f41d0b2 // indirect + github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 // indirect github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 // indirect diff --git a/examples/txnkv/pessimistic_txn/go.mod b/examples/txnkv/pessimistic_txn/go.mod index b662b2b330..07e29bace8 100644 --- a/examples/txnkv/pessimistic_txn/go.mod +++ b/examples/txnkv/pessimistic_txn/go.mod @@ -5,7 +5,6 @@ go 1.21 require github.com/tikv/client-go/v2 v2.0.0 require ( - github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudfoundry/gosigar v1.3.6 // indirect @@ -18,11 +17,10 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/uuid v1.4.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c // indirect - github.com/pingcap/kvproto v0.0.0-20231222062942-c0c73f41d0b2 // indirect + github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 // indirect github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 // indirect @@ -45,6 +43,8 @@ require ( golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/grpc v1.61.1 // indirect google.golang.org/protobuf v1.32.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/examples/txnkv/unsafedestoryrange/go.mod b/examples/txnkv/unsafedestoryrange/go.mod index 9edadb94a4..4c8845a1ce 100644 --- a/examples/txnkv/unsafedestoryrange/go.mod +++ b/examples/txnkv/unsafedestoryrange/go.mod @@ -5,7 +5,6 @@ go 1.21 require github.com/tikv/client-go/v2 v2.0.0 require ( - github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudfoundry/gosigar v1.3.6 // indirect @@ -18,11 +17,10 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/uuid v1.4.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c // indirect - github.com/pingcap/kvproto v0.0.0-20231222062942-c0c73f41d0b2 // indirect + github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 // indirect github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 // indirect @@ -45,6 +43,8 @@ require ( golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/grpc v1.61.1 // indirect google.golang.org/protobuf v1.32.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/go.mod b/go.mod index a86b50f537..46310fbec3 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 - github.com/pingcap/kvproto v0.0.0-20231222062942-c0c73f41d0b2 + github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.18.0 diff --git a/go.sum b/go.sum index 3c2cf8ee5c..3cae13d741 100644 --- a/go.sum +++ b/go.sum @@ -74,8 +74,8 @@ github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c h1:CgbKAHto5CQgW github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c/go.mod h1:4qGtCB0QK0wBzKtFEGDhxXnSnbQApw1gc9siScUl8ew= github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E= github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw= -github.com/pingcap/kvproto v0.0.0-20231222062942-c0c73f41d0b2 h1:364A6VCS+l0oHBKZKotX9LzmfEtIO/NTccTIQcPp3Ug= -github.com/pingcap/kvproto v0.0.0-20231222062942-c0c73f41d0b2/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8= +github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 h1:qsVsCkP/IyrN6Mr4APkJMGkGFsoWszwHiUOdMknOuVs= +github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8= github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8IDP+SZrdhV1Kibl9KrHxJ9eciw= github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/integration_tests/go.mod b/integration_tests/go.mod index 20ca0b9e48..0d308471a5 100644 --- a/integration_tests/go.mod +++ b/integration_tests/go.mod @@ -6,8 +6,8 @@ require ( github.com/ninedraft/israce v0.0.3 github.com/pingcap/errors v0.11.5-0.20231212100244-799fae176cfb github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c - github.com/pingcap/kvproto v0.0.0-20240109063850-932639606bcf - github.com/pingcap/tidb v1.1.0-beta.0.20240131080924-732fa8c98695 + github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 + github.com/pingcap/tidb v1.1.0-beta.0.20240126041650-de177d85b19e github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.8.4 github.com/tidwall/gjson v1.14.1 diff --git a/integration_tests/go.sum b/integration_tests/go.sum index 01b619f728..e378a4113b 100644 --- a/integration_tests/go.sum +++ b/integration_tests/go.sum @@ -10,12 +10,12 @@ cloud.google.com/go/iam v1.1.6/go.mod h1:O0zxdPeGBoFdWW3HWmBxJsk0pfvNM/p/qa82rWO cloud.google.com/go/storage v1.36.0 h1:P0mOkAcaJxhCTvAkMhxMfrTKiNcub4YmmPBtlhAyTr8= cloud.google.com/go/storage v1.36.0/go.mod h1:M6M/3V/D3KpzMTJyPOR/HU6n2Si5QdaXYEsng2xgOs8= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 h1:9kDVnTz3vbfweTqAUmk/a/pH5pWFCHtvRpHYC0G/dcA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0/go.mod h1:3Ug6Qzto9anB6mGlEdgYMDF5zHQ+wwhEaYR4s17PHMw= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0 h1:u/LLAOFgsMv7HmNL4Qufg58y+qElGOt5qv0z1mURkRY= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0/go.mod h1:2e8rMJtl2+2j+HXbTBwnyGpm5Nou7KhvSfxOq8JpTag= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8= @@ -52,8 +52,8 @@ github.com/apache/thrift v0.13.1-0.20201008052519-daf620915714/go.mod h1:cp2SuWM github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/aws/aws-sdk-go v1.48.14 h1:nVLrp+F84SG+xGiFMfe1TE6ZV6smF+42tuuNgYGV30s= -github.com/aws/aws-sdk-go v1.48.14/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.45.25 h1:c4fLlh5sLdK2DCRTY1z0hyuJZU4ygxX8m1FswL6/nF4= +github.com/aws/aws-sdk-go v1.45.25/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -168,8 +168,8 @@ github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AE github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= -github.com/go-resty/resty/v2 v2.11.0 h1:i7jMfNOJYMp69lq7qozJP+bjgzfAzeOhuGlyDrqxT/8= -github.com/go-resty/resty/v2 v2.11.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A= +github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= +github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -413,16 +413,16 @@ github.com/pingcap/fn v1.0.0/go.mod h1:u9WZ1ZiOD1RpNhcI42RucFh/lBuzTu6rw88a+oF2Z github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E= github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw= github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w= -github.com/pingcap/kvproto v0.0.0-20240109063850-932639606bcf h1:n3FMveYjc2VuETjo6YhmsgkDx0P/yLJTvk96BJdCq6Y= -github.com/pingcap/kvproto v0.0.0-20240109063850-932639606bcf/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8= +github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2 h1:qsVsCkP/IyrN6Mr4APkJMGkGFsoWszwHiUOdMknOuVs= +github.com/pingcap/kvproto v0.0.0-20240130020929-9660a33cf0d2/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8= github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM= github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= github.com/pingcap/log v1.1.1-0.20230317032135-a0d097d16e22 h1:2SOzvGvE8beiC1Y4g9Onkvu6UmuBBOeWRGQEjJaT/JY= github.com/pingcap/log v1.1.1-0.20230317032135-a0d097d16e22/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21 h1:QV6jqlfOkh8hqvEAgwBZa+4bSgO0EeKC7s5c6Luam2I= github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21/go.mod h1:QYnjfA95ZaMefyl1NO8oPtKeb8pYUdnDVhQgf+qdpjM= -github.com/pingcap/tidb v1.1.0-beta.0.20240131080924-732fa8c98695 h1:7ELVL+rVzEZrDv4dEC995qHbv9K0dSKm7+wuwotiB8U= -github.com/pingcap/tidb v1.1.0-beta.0.20240131080924-732fa8c98695/go.mod h1:rfdtaBHvL6w0uFmxz0BJIBHHUpR/satNS695+def0y8= +github.com/pingcap/tidb v1.1.0-beta.0.20240126041650-de177d85b19e h1:RX+LBAD8i8wWdwJ0yimxayTJUtwB8oZVcNaHPnmWOZY= +github.com/pingcap/tidb v1.1.0-beta.0.20240126041650-de177d85b19e/go.mod h1:ekt5M11y10od5MxYUSJ2B2bCqulzTd5LPqcJLFADBY4= github.com/pingcap/tidb/pkg/parser v0.0.0-20240111112854-1ad36eb0ef29 h1:OPF0SMFk0O298dzHisYnhotbTcDQC2l+h0Xs7QxUF88= github.com/pingcap/tidb/pkg/parser v0.0.0-20240111112854-1ad36eb0ef29/go.mod h1:yRkiqLFwIqibYg2P7h4bclHjHcJiIFRLKhGRyBcKYus= github.com/pingcap/tipb v0.0.0-20240116032918-9bb28c43bbfc h1:sEp4lbExDfnMX8HXQyhZrhqo2/SgeFY5KOdo5akc8FM= @@ -597,10 +597,10 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo= go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0/go.mod h1:zgBdWWAu7oEEMC06MMKc5NLbA/1YDXV1sMpSqEeLQLg= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 h1:tIqheXEFWAZ7O8A7m+J0aPTmpJN3YQ7qetUAdkkkKpk= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0/go.mod h1:nUeKExfxAQVbiVFn32YXpXZZHZ61Cc3s3Rn1pDBGAb0= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 h1:3d+S281UTjM+AbF31XSOYn1qXn3BgIdWl8HNEpx08Jk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0/go.mod h1:0+KuTDyKL4gjKCF75pHOX4wuzYDUZYfAQdSu43o+Z2I= go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= @@ -857,12 +857,12 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -k8s.io/api v0.28.4 h1:8ZBrLjwosLl/NYgv1P7EQLqoO8MGQApnbgH8tu3BMzY= -k8s.io/api v0.28.4/go.mod h1:axWTGrY88s/5YE+JSt4uUi6NMM+gur1en2REMR7IRj0= -k8s.io/apimachinery v0.28.4 h1:zOSJe1mc+GxuMnFzD4Z/U1wst50X28ZNsn5bhgIIao8= -k8s.io/apimachinery v0.28.4/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg= -k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= -k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= +k8s.io/api v0.28.2 h1:9mpl5mOb6vXZvqbQmankOfPIGiudghwCoLl1EYfUZbw= +k8s.io/api v0.28.2/go.mod h1:RVnJBsjU8tcMq7C3iaRSGMeaKt2TWEUXcpIt/90fjEg= +k8s.io/apimachinery v0.28.2 h1:KCOJLrc6gu+wV1BYgwik4AF4vXOlVJPdiqn0yAWWwXQ= +k8s.io/apimachinery v0.28.2/go.mod h1:RdzF87y/ngqk9H4z3EL2Rppv5jj95vGS/HaFXrLDApU= +k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= +k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/utils v0.0.0-20230711102312-30195339c3c7 h1:ZgnF1KZsYxWIifwSNZFZgNtWE89WI5yiP5WwlfDoIyc= k8s.io/utils v0.0.0-20230711102312-30195339c3c7/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= diff --git a/internal/client/client.go b/internal/client/client.go index b6052a4bc5..9600c6fb64 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -318,7 +318,11 @@ func (a *connArray) Init(addr string, security config.Security, idleNotify *uint dialTimeout: a.dialTimeout, tryLock: tryLock{sync.NewCond(new(sync.Mutex)), false}, } - batchClient.maxConcurrencyRequestLimit.Store(cfg.TiKVClient.MaxConcurrencyRequestLimit) + size := cfg.TiKVClient.MaxConcurrencyRequestLimit + if size <= 0 { + size = 5 + } + batchClient.maxConcurrencyRequestLimit.Store(size) a.batchCommandsClients = append(a.batchCommandsClients, batchClient) } } diff --git a/internal/client/client_batch.go b/internal/client/client_batch.go index d241494b44..8efd743b7d 100644 --- a/internal/client/client_batch.go +++ b/internal/client/client_batch.go @@ -44,6 +44,7 @@ import ( "sync/atomic" "time" + "github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/kvproto/pkg/tikvpb" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -63,7 +64,7 @@ import ( type batchCommandsEntry struct { ctx context.Context req *tikvpb.BatchCommandsRequest_Request - res chan *tikvpb.BatchCommandsResponse_Response + res chan *tikvrpc.Response // forwardedHost is the address of a store which will handle the request. // It's different from the address the request sent to. forwardedHost string @@ -409,6 +410,7 @@ func (a *batchConn) getClientAndSend() { cli = c break } else { + reasons = append(reasons, SendFailedReasonTryLockForSendFail) } } else { @@ -552,8 +554,10 @@ type batchCommandsClient struct { // tryLock protects client when re-create the streaming. tryLock // sent is the number of the requests are processed by tikv server. - sent atomic.Int64 - // maxConcurrencyRequestLimit is the max allowed number of requests to be sent the tikv + sent atomic.Int64 + errorSum float64 + + // limit is the max number of requests can be sent to tikv but not accept response. maxConcurrencyRequestLimit atomic.Int64 } @@ -711,7 +715,9 @@ func (c *batchCommandsClient) batchRecvLoop(cfg config.TiKVClient, tikvTransport logutil.Eventf(entry.ctx, "receive %T response with other %d batched requests from %s", responses[i].GetCmd(), len(responses), c.target) if atomic.LoadInt32(&entry.canceled) == 0 { // Put the response only if the request is not canceled. - entry.res <- responses[i] + rsp, details := tikvrpc.FromBatchCommandsResponse(responses[i]) + c.feedBack(details) + entry.res <- rsp } c.batched.Delete(requestID) c.sent.Add(-1) @@ -725,6 +731,46 @@ func (c *batchCommandsClient) batchRecvLoop(cfg config.TiKVClient, tikvTransport } } +const ( + Kp = 0.01 + Ki = 0.001 +) + +func (c *batchCommandsClient) feedBack(details *kvrpcpb.ExecDetailsV2) { + if details == nil { + return + } + if limit := c.tikvClientCfg.MaxConcurrencyRequestLimit; limit != 0 { + c.maxConcurrencyRequestLimit.Store(limit) + return + } + + expect := c.tikvClientCfg.GrpcExpectDuration + timeDetail := details.GetTimeDetailV2() + if timeDetail == nil || timeDetail.GetKvGrpcExecTimeNs() <= 0 { + return + } + exec := timeDetail.GetKvGrpcExecTimeNs() / 1_000 + wait := timeDetail.GetKvGrpcWaitTimeNs() / 1_000 + + e := float64(exec*expect) - float64(wait) + if e > float64(exec*expect) { + e = float64(exec * expect) + } + + if e < -float64(exec*expect) { + e = -float64(exec * expect) + } + // Not adjust the limit if the client is not busy enough. + if c.maxConcurrencyRequestLimit.Load() >= c.sent.Load()*2 && e > 0 { + return + } + c.errorSum += e + if limit := Kp*c.errorSum + Ki*e; limit > 1 { + c.maxConcurrencyRequestLimit.Store(int64(limit)) + } +} + func (c *batchCommandsClient) recreateStreamingClient(err error, streamClient *batchCommandsStream, epoch *uint64) (stopped bool) { // Forbids the batchSendLoop using the old client and // blocks other streams trying to recreate. @@ -838,7 +884,7 @@ func sendBatchRequest( entry := &batchCommandsEntry{ ctx: ctx, req: req, - res: make(chan *tikvpb.BatchCommandsResponse_Response, 1), + res: make(chan *tikvrpc.Response, 1), forwardedHost: forwardedHost, canceled: 0, err: nil, @@ -865,7 +911,7 @@ func sendBatchRequest( if !ok { return nil, errors.WithStack(entry.err) } - return tikvrpc.FromBatchCommandsResponse(res) + return res, nil case <-ctx.Done(): atomic.StoreInt32(&entry.canceled, 1) logutil.Logger(ctx).Debug("wait response is cancelled", diff --git a/internal/client/client_test.go b/internal/client/client_test.go index d4d22bfe6d..6b27f8b4c9 100644 --- a/internal/client/client_test.go +++ b/internal/client/client_test.go @@ -461,7 +461,7 @@ func TestBatchCommandsBuilder(t *testing.T) { builder.reset() entries = entries[:0] for i := 0; i < 3; i++ { - entry := &batchCommandsEntry{req: req, res: make(chan *tikvpb.BatchCommandsResponse_Response, 1)} + entry := &batchCommandsEntry{req: req, res: make(chan *tikvrpc.Response, 1)} entries = append(entries, entry) builder.push(entry) } @@ -804,6 +804,8 @@ func TestPrioritySentLimit(t *testing.T) { go sendFn(16, &highDur, &highQps) go sendFn(8, &mediumDur, &mediumQps) wait.Wait() - re.Less(highDur.Load()/highQps.Load()*2, mediumDur.Load()/mediumQps.Load()) + highAvg := highDur.Load() / highQps.Load() + mediumAvg := mediumDur.Load() / mediumQps.Load() + re.Less(highAvg, mediumAvg*2) server.Stop() } diff --git a/tikvrpc/tikvrpc.go b/tikvrpc/tikvrpc.go index 7b2a65de1c..f84820c681 100644 --- a/tikvrpc/tikvrpc.go +++ b/tikvrpc/tikvrpc.go @@ -616,29 +616,29 @@ type Response struct { } // FromBatchCommandsResponse converts a BatchCommands response to Response. -func FromBatchCommandsResponse(res *tikvpb.BatchCommandsResponse_Response) (*Response, error) { +func FromBatchCommandsResponse(res *tikvpb.BatchCommandsResponse_Response) (*Response, *kvrpcpb.ExecDetailsV2) { if res.GetCmd() == nil { - return nil, errors.New("Unknown command response") + return nil, nil } switch res := res.GetCmd().(type) { case *tikvpb.BatchCommandsResponse_Response_Get: - return &Response{Resp: res.Get}, nil + return &Response{Resp: res.Get}, res.Get.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_Scan: return &Response{Resp: res.Scan}, nil case *tikvpb.BatchCommandsResponse_Response_Prewrite: - return &Response{Resp: res.Prewrite}, nil + return &Response{Resp: res.Prewrite}, res.Prewrite.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_Commit: - return &Response{Resp: res.Commit}, nil + return &Response{Resp: res.Commit}, res.Commit.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_Cleanup: return &Response{Resp: res.Cleanup}, nil case *tikvpb.BatchCommandsResponse_Response_BatchGet: - return &Response{Resp: res.BatchGet}, nil + return &Response{Resp: res.BatchGet}, res.BatchGet.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_BatchRollback: - return &Response{Resp: res.BatchRollback}, nil + return &Response{Resp: res.BatchRollback}, res.BatchRollback.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_ScanLock: - return &Response{Resp: res.ScanLock}, nil + return &Response{Resp: res.ScanLock}, res.ScanLock.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_ResolveLock: - return &Response{Resp: res.ResolveLock}, nil + return &Response{Resp: res.ResolveLock}, res.ResolveLock.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_GC: return &Response{Resp: res.GC}, nil case *tikvpb.BatchCommandsResponse_Response_DeleteRange: @@ -664,19 +664,19 @@ func FromBatchCommandsResponse(res *tikvpb.BatchCommandsResponse_Response) (*Res case *tikvpb.BatchCommandsResponse_Response_RawScan: return &Response{Resp: res.RawScan}, nil case *tikvpb.BatchCommandsResponse_Response_Coprocessor: - return &Response{Resp: res.Coprocessor}, nil + return &Response{Resp: res.Coprocessor}, res.Coprocessor.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_PessimisticLock: - return &Response{Resp: res.PessimisticLock}, nil + return &Response{Resp: res.PessimisticLock}, res.PessimisticLock.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_PessimisticRollback: - return &Response{Resp: res.PessimisticRollback}, nil + return &Response{Resp: res.PessimisticRollback}, res.PessimisticRollback.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_Empty: return &Response{Resp: res.Empty}, nil case *tikvpb.BatchCommandsResponse_Response_TxnHeartBeat: - return &Response{Resp: res.TxnHeartBeat}, nil + return &Response{Resp: res.TxnHeartBeat}, res.TxnHeartBeat.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_CheckTxnStatus: - return &Response{Resp: res.CheckTxnStatus}, nil + return &Response{Resp: res.CheckTxnStatus}, res.CheckTxnStatus.GetExecDetailsV2() case *tikvpb.BatchCommandsResponse_Response_CheckSecondaryLocks: - return &Response{Resp: res.CheckSecondaryLocks}, nil + return &Response{Resp: res.CheckSecondaryLocks}, res.CheckSecondaryLocks.GetExecDetailsV2() } panic("unreachable") } diff --git a/tikvrpc/tikvrpc_test.go b/tikvrpc/tikvrpc_test.go index e3d5e25fb3..e9654d575f 100644 --- a/tikvrpc/tikvrpc_test.go +++ b/tikvrpc/tikvrpc_test.go @@ -43,7 +43,7 @@ import ( func TestBatchResponse(t *testing.T) { resp := &tikvpb.BatchCommandsResponse_Response{} - batchResp, err := FromBatchCommandsResponse(resp) + batchResp, details := FromBatchCommandsResponse(resp) assert.Nil(t, batchResp) - assert.NotNil(t, err) + assert.Nil(t, details) }