mirror of https://github.com/tikv/client-go.git
client: support requests with source label (#506)
* support request scope and source. Signed-off-by: you06 <you1474600@gmail.com> * update Signed-off-by: you06 <you1474600@gmail.com> * use counter for requests with too-many source Signed-off-by: you06 <you1474600@gmail.com> * refine resolve lock Signed-off-by: you06 <you1474600@gmail.com> * remove request source from resolve details Signed-off-by: you06 <you1474600@gmail.com> * address comment Signed-off-by: you06 <you1474600@gmail.com>
This commit is contained in:
parent
681fb6e537
commit
bb026bdad8
2
go.mod
2
go.mod
|
|
@ -16,7 +16,7 @@ require (
|
||||||
github.com/opentracing/opentracing-go v1.2.0
|
github.com/opentracing/opentracing-go v1.2.0
|
||||||
github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00
|
github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00
|
||||||
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989
|
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989
|
||||||
github.com/pingcap/kvproto v0.0.0-20220517085838-12e2f5a9d167
|
github.com/pingcap/kvproto v0.0.0-20220525022339-6aaebf466305
|
||||||
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee
|
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/prometheus/client_golang v1.11.0
|
github.com/prometheus/client_golang v1.11.0
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -161,8 +161,8 @@ github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00/go.mod h1:4qGtCB
|
||||||
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
|
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/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
|
||||||
github.com/pingcap/kvproto v0.0.0-20220302110454-c696585a961b/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI=
|
github.com/pingcap/kvproto v0.0.0-20220302110454-c696585a961b/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI=
|
||||||
github.com/pingcap/kvproto v0.0.0-20220517085838-12e2f5a9d167 h1:dsMpneacHyuVslSVndgUfJKrXFNG7VPdXip2ulG6glo=
|
github.com/pingcap/kvproto v0.0.0-20220525022339-6aaebf466305 h1:TZ0teMZoKHnZDlJxNkWrp5Sgv3w+ruNbrqtBYKsfaNw=
|
||||||
github.com/pingcap/kvproto v0.0.0-20220517085838-12e2f5a9d167/go.mod h1:OYtxs0786qojVTmkVeufx93xe+jUgm56GUYRIKnmaGI=
|
github.com/pingcap/kvproto v0.0.0-20220525022339-6aaebf466305/go.mod h1:OYtxs0786qojVTmkVeufx93xe+jUgm56GUYRIKnmaGI=
|
||||||
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
|
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
|
||||||
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee h1:VO2t6IBpfvW34TdtD/G10VvnGqjLic1jzOuHjUb5VqM=
|
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee h1:VO2t6IBpfvW34TdtD/G10VvnGqjLic1jzOuHjUb5VqM=
|
||||||
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,16 @@ require (
|
||||||
github.com/ninedraft/israce v0.0.3
|
github.com/ninedraft/israce v0.0.3
|
||||||
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c
|
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c
|
||||||
github.com/pingcap/failpoint v0.0.0-20220423142525-ae43b7f4e5c3
|
github.com/pingcap/failpoint v0.0.0-20220423142525-ae43b7f4e5c3
|
||||||
github.com/pingcap/kvproto v0.0.0-20220517085838-12e2f5a9d167
|
github.com/pingcap/kvproto v0.0.0-20220525022339-6aaebf466305
|
||||||
github.com/pingcap/tidb v1.1.0-beta.0.20220517125829-586716bff25e
|
github.com/pingcap/tidb v1.1.0-beta.0.20220621061036-5c9ad77ae1f1
|
||||||
github.com/pingcap/tidb/parser v0.0.0-20220517125829-586716bff25e // indirect
|
github.com/pingcap/tidb/parser v0.0.0-20220621061036-5c9ad77ae1f1 // indirect
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/stretchr/testify v1.7.2-0.20220504104629-106ec21d14df
|
github.com/stretchr/testify v1.7.2-0.20220504104629-106ec21d14df
|
||||||
github.com/tikv/client-go/v2 v2.0.1-0.20220516035221-e007187e5101
|
github.com/tikv/client-go/v2 v2.0.1-0.20220613112734-be31f33ba03b
|
||||||
github.com/tikv/pd/client v0.0.0-20220307081149-841fa61e9710
|
github.com/tikv/pd/client v0.0.0-20220307081149-841fa61e9710
|
||||||
go.uber.org/goleak v1.1.12
|
go.uber.org/goleak v1.1.12
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/tikv/client-go/v2 => ../
|
replace github.com/tikv/client-go/v2 => ../
|
||||||
|
|
||||||
|
replace github.com/pingcap/tidb => github.com/you06/tidb v1.1.0-beta.0.20220620132310-ba06be65cc3b
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||||
|
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1581 h1:Q/yk4z/cHUVZfgTqtD09qeYBxHwshQAjVRX73qs8UH0=
|
||||||
|
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1581/go.mod h1:RcDobYh8k5VP6TNybz9m++gL3ijVI5wueVr0EM10VsU=
|
||||||
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
|
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
|
||||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||||
github.com/apache/thrift v0.0.0-20181112125854-24918abba929/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
github.com/apache/thrift v0.0.0-20181112125854-24918abba929/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||||
|
|
@ -175,7 +177,6 @@ github.com/cznic/golex v0.0.0-20181122101858-9c343928389c/go.mod h1:+bmmJDNmKlhW
|
||||||
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 h1:iwZdTE0PVqJCos1vaoKsclOGD3ADKpshg3SRtYBbwso=
|
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 h1:iwZdTE0PVqJCos1vaoKsclOGD3ADKpshg3SRtYBbwso=
|
||||||
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM=
|
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM=
|
||||||
github.com/cznic/parser v0.0.0-20160622100904-31edd927e5b1/go.mod h1:2B43mz36vGZNZEwkWi8ayRSSUXLfjL8OkbzwW4NcPMM=
|
github.com/cznic/parser v0.0.0-20160622100904-31edd927e5b1/go.mod h1:2B43mz36vGZNZEwkWi8ayRSSUXLfjL8OkbzwW4NcPMM=
|
||||||
github.com/cznic/sortutil v0.0.0-20181122101858-f5f958428db8 h1:LpMLYGyy67BoAFGda1NeOBQwqlv7nUXpm+rIVHGxZZ4=
|
|
||||||
github.com/cznic/sortutil v0.0.0-20181122101858-f5f958428db8/go.mod h1:q2w6Bg5jeox1B+QkJ6Wp/+Vn0G/bo3f1uY7Fn3vivIQ=
|
github.com/cznic/sortutil v0.0.0-20181122101858-f5f958428db8/go.mod h1:q2w6Bg5jeox1B+QkJ6Wp/+Vn0G/bo3f1uY7Fn3vivIQ=
|
||||||
github.com/cznic/strutil v0.0.0-20171016134553-529a34b1c186/go.mod h1:AHHPPPXTw0h6pVabbcbyGRK1DckRn7r/STdZEeIDzZc=
|
github.com/cznic/strutil v0.0.0-20171016134553-529a34b1c186/go.mod h1:AHHPPPXTw0h6pVabbcbyGRK1DckRn7r/STdZEeIDzZc=
|
||||||
github.com/cznic/y v0.0.0-20170802143616-045f81c6662a/go.mod h1:1rk5VM7oSnA4vjp+hrLQ3HWHa+Y4yPCa3/CsJrcNnvs=
|
github.com/cznic/y v0.0.0-20170802143616-045f81c6662a/go.mod h1:1rk5VM7oSnA4vjp+hrLQ3HWHa+Y4yPCa3/CsJrcNnvs=
|
||||||
|
|
@ -274,6 +275,7 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP
|
||||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM=
|
github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM=
|
||||||
|
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
|
||||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
|
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
|
||||||
|
|
@ -435,6 +437,7 @@ github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxy
|
||||||
github.com/jcmturner/gokrb5/v8 v8.4.2/go.mod h1:sb+Xq/fTY5yktf/VxLsE3wlfPqQjp0aWNYyvBVK62bc=
|
github.com/jcmturner/gokrb5/v8 v8.4.2/go.mod h1:sb+Xq/fTY5yktf/VxLsE3wlfPqQjp0aWNYyvBVK62bc=
|
||||||
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
|
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
|
||||||
github.com/jedib0t/go-pretty/v6 v6.2.2/go.mod h1:+nE9fyyHGil+PuISTCrp7avEdo6bqoMwqZnuiK2r2a0=
|
github.com/jedib0t/go-pretty/v6 v6.2.2/go.mod h1:+nE9fyyHGil+PuISTCrp7avEdo6bqoMwqZnuiK2r2a0=
|
||||||
|
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||||
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
|
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
|
||||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||||
|
|
@ -444,10 +447,12 @@ github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22
|
||||||
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
|
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
|
||||||
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||||
|
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
|
|
||||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
|
|
@ -530,8 +535,9 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
|
||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
|
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
|
||||||
github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ=
|
github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
|
|
@ -597,8 +603,8 @@ github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN
|
||||||
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
|
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-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w=
|
||||||
github.com/pingcap/kvproto v0.0.0-20220302110454-c696585a961b/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI=
|
github.com/pingcap/kvproto v0.0.0-20220302110454-c696585a961b/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI=
|
||||||
github.com/pingcap/kvproto v0.0.0-20220517085838-12e2f5a9d167 h1:dsMpneacHyuVslSVndgUfJKrXFNG7VPdXip2ulG6glo=
|
github.com/pingcap/kvproto v0.0.0-20220525022339-6aaebf466305 h1:TZ0teMZoKHnZDlJxNkWrp5Sgv3w+ruNbrqtBYKsfaNw=
|
||||||
github.com/pingcap/kvproto v0.0.0-20220517085838-12e2f5a9d167/go.mod h1:OYtxs0786qojVTmkVeufx93xe+jUgm56GUYRIKnmaGI=
|
github.com/pingcap/kvproto v0.0.0-20220525022339-6aaebf466305/go.mod h1:OYtxs0786qojVTmkVeufx93xe+jUgm56GUYRIKnmaGI=
|
||||||
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
|
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
|
||||||
github.com/pingcap/log v0.0.0-20200511115504-543df19646ad/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
|
github.com/pingcap/log v0.0.0-20200511115504-543df19646ad/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
|
||||||
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
|
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
|
||||||
|
|
@ -607,13 +613,11 @@ github.com/pingcap/log v1.1.0 h1:ELiPxACz7vdo1qAvvaWJg1NrYFoY6gqAh/+Uo6aXdD8=
|
||||||
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
||||||
github.com/pingcap/sysutil v0.0.0-20220114020952-ea68d2dbf5b4 h1:HYbcxtnkN3s5tqrZ/z3eJS4j3Db8wMphEm1q10lY/TM=
|
github.com/pingcap/sysutil v0.0.0-20220114020952-ea68d2dbf5b4 h1:HYbcxtnkN3s5tqrZ/z3eJS4j3Db8wMphEm1q10lY/TM=
|
||||||
github.com/pingcap/sysutil v0.0.0-20220114020952-ea68d2dbf5b4/go.mod h1:sDCsM39cGiv2vwunZkaFA917vVkqDTGSPbbV7z4Oops=
|
github.com/pingcap/sysutil v0.0.0-20220114020952-ea68d2dbf5b4/go.mod h1:sDCsM39cGiv2vwunZkaFA917vVkqDTGSPbbV7z4Oops=
|
||||||
github.com/pingcap/tidb v1.1.0-beta.0.20220517125829-586716bff25e h1:EOQMlH0PHWOuG80DDelsL7brkZSvhiewVwKoDiFLZnc=
|
|
||||||
github.com/pingcap/tidb v1.1.0-beta.0.20220517125829-586716bff25e/go.mod h1:LuTxJolM8+ftJgDYrNtps4loodvXN0GBAEHJc3d0tb4=
|
|
||||||
github.com/pingcap/tidb/parser v0.0.0-20211011031125-9b13dc409c5e/go.mod h1:e1MGCA9Sg3T8jid8PKAEq5eYVuMMCq4n8gJ+Kqp4Plg=
|
github.com/pingcap/tidb/parser v0.0.0-20211011031125-9b13dc409c5e/go.mod h1:e1MGCA9Sg3T8jid8PKAEq5eYVuMMCq4n8gJ+Kqp4Plg=
|
||||||
github.com/pingcap/tidb/parser v0.0.0-20220517125829-586716bff25e h1:KPDMn5WiIPGvLBc5iT3icdCP/a0KPofpUQdhLVC/7W8=
|
github.com/pingcap/tidb/parser v0.0.0-20220621061036-5c9ad77ae1f1 h1:IOBUGVF1Neq5BPRKKIxyg/57PYKdCC8QxCUzi/Q2DV4=
|
||||||
github.com/pingcap/tidb/parser v0.0.0-20220517125829-586716bff25e/go.mod h1:ElJiub4lRy6UZDb+0JHDkGEdr6aOli+ykhyej7VCLoI=
|
github.com/pingcap/tidb/parser v0.0.0-20220621061036-5c9ad77ae1f1/go.mod h1:ElJiub4lRy6UZDb+0JHDkGEdr6aOli+ykhyej7VCLoI=
|
||||||
github.com/pingcap/tipb v0.0.0-20220314125451-bfb5c2c55188 h1:+46isFI9fR9R+nJVDMI55tCC/TCwp+bvVA4HLGEv1rY=
|
github.com/pingcap/tipb v0.0.0-20220602075447-4847c5d68e73 h1:L4nZwfYSrIsWPAZR8zMwHaNQJy0Rjy3Od6Smj5mlOms=
|
||||||
github.com/pingcap/tipb v0.0.0-20220314125451-bfb5c2c55188/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
|
github.com/pingcap/tipb v0.0.0-20220602075447-4847c5d68e73/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
|
||||||
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98=
|
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98=
|
||||||
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
|
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
|
@ -631,8 +635,9 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP
|
||||||
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||||
github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ=
|
|
||||||
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||||
|
github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34=
|
||||||
|
github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
||||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
|
@ -650,8 +655,9 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
|
||||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||||
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
|
|
||||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||||
|
github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
|
||||||
|
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
|
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
|
||||||
|
|
@ -754,6 +760,8 @@ github.com/xitongsys/parquet-go-source v0.0.0-20190524061010-2b72cbee77d5/go.mod
|
||||||
github.com/xitongsys/parquet-go-source v0.0.0-20200817004010-026bad9b25d0/go.mod h1:HYhIKsdns7xz80OgkbgJYrtQY7FjHWHKH6cvN7+czGE=
|
github.com/xitongsys/parquet-go-source v0.0.0-20200817004010-026bad9b25d0/go.mod h1:HYhIKsdns7xz80OgkbgJYrtQY7FjHWHKH6cvN7+czGE=
|
||||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
|
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
|
||||||
|
github.com/you06/tidb v1.1.0-beta.0.20220620132310-ba06be65cc3b h1:LctQrf5HpbkRpLOBMzx2vSE05x05A8FBgYMU9DOmhqs=
|
||||||
|
github.com/you06/tidb v1.1.0-beta.0.20220620132310-ba06be65cc3b/go.mod h1:mdUm2FwYwwqDYXtVtASTY3rrtA1ikgSGH5FKdQfKdmI=
|
||||||
github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
|
github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
|
||||||
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
|
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
|
||||||
github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc=
|
github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc=
|
||||||
|
|
@ -990,8 +998,9 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
|
||||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4=
|
||||||
|
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
|
@ -1349,6 +1358,7 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy
|
||||||
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
||||||
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
|
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
|
||||||
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
|
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
gopkg.in/jcmturner/aescts.v1 v1.0.1/go.mod h1:nsR8qBOg+OucoIW+WMhB3GspUQXq9XorLnQb9XtvcOo=
|
gopkg.in/jcmturner/aescts.v1 v1.0.1/go.mod h1:nsR8qBOg+OucoIW+WMhB3GspUQXq9XorLnQb9XtvcOo=
|
||||||
gopkg.in/jcmturner/dnsutils.v1 v1.0.1/go.mod h1:m3v+5svpVOhtFAP/wSz+yzh4Mc0Fg7eRhxkJMWSIz9Q=
|
gopkg.in/jcmturner/dnsutils.v1 v1.0.1/go.mod h1:m3v+5svpVOhtFAP/wSz+yzh4Mc0Fg7eRhxkJMWSIz9Q=
|
||||||
gopkg.in/jcmturner/goidentity.v3 v3.0.0/go.mod h1:oG2kH0IvSYNIu80dVAyu/yoefjq1mNfM5bm88whjWx4=
|
gopkg.in/jcmturner/goidentity.v3 v3.0.0/go.mod h1:oG2kH0IvSYNIu80dVAyu/yoefjq1mNfM5bm88whjWx4=
|
||||||
|
|
|
||||||
|
|
@ -344,7 +344,10 @@ func (c *RPCClient) closeConns() {
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
var sendReqHistCache sync.Map
|
var (
|
||||||
|
sendReqHistCache sync.Map
|
||||||
|
sendReqCounterCache sync.Map
|
||||||
|
)
|
||||||
|
|
||||||
type sendReqHistCacheKey struct {
|
type sendReqHistCacheKey struct {
|
||||||
tp tikvrpc.CmdType
|
tp tikvrpc.CmdType
|
||||||
|
|
@ -352,22 +355,49 @@ type sendReqHistCacheKey struct {
|
||||||
staleRad bool
|
staleRad bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type sendReqCounterCacheKey struct {
|
||||||
|
sendReqHistCacheKey
|
||||||
|
requestSource string
|
||||||
|
}
|
||||||
|
|
||||||
|
type sendReqCounterCacheValue struct {
|
||||||
|
counter prometheus.Counter
|
||||||
|
timeCounter prometheus.Counter
|
||||||
|
}
|
||||||
|
|
||||||
func (c *RPCClient) updateTiKVSendReqHistogram(req *tikvrpc.Request, start time.Time, staleRead bool) {
|
func (c *RPCClient) updateTiKVSendReqHistogram(req *tikvrpc.Request, start time.Time, staleRead bool) {
|
||||||
key := sendReqHistCacheKey{
|
histKey := sendReqHistCacheKey{
|
||||||
req.Type,
|
req.Type,
|
||||||
req.Context.GetPeer().GetStoreId(),
|
req.Context.GetPeer().GetStoreId(),
|
||||||
staleRead,
|
staleRead,
|
||||||
}
|
}
|
||||||
|
counterKey := sendReqCounterCacheKey{
|
||||||
|
histKey,
|
||||||
|
req.GetRequestSource(),
|
||||||
|
}
|
||||||
|
|
||||||
v, ok := sendReqHistCache.Load(key)
|
hist, ok := sendReqHistCache.Load(histKey)
|
||||||
if !ok {
|
if !ok {
|
||||||
reqType := req.Type.String()
|
reqType := req.Type.String()
|
||||||
storeID := strconv.FormatUint(req.Context.GetPeer().GetStoreId(), 10)
|
storeID := strconv.FormatUint(req.Context.GetPeer().GetStoreId(), 10)
|
||||||
v = metrics.TiKVSendReqHistogram.WithLabelValues(reqType, storeID, strconv.FormatBool(staleRead))
|
hist = metrics.TiKVSendReqHistogram.WithLabelValues(reqType, storeID, strconv.FormatBool(staleRead))
|
||||||
sendReqHistCache.Store(key, v)
|
sendReqHistCache.Store(histKey, hist)
|
||||||
|
}
|
||||||
|
counter, ok := sendReqCounterCache.Load(counterKey)
|
||||||
|
if !ok {
|
||||||
|
reqType := req.Type.String()
|
||||||
|
storeID := strconv.FormatUint(req.Context.GetPeer().GetStoreId(), 10)
|
||||||
|
counter = sendReqCounterCacheValue{
|
||||||
|
metrics.TiKVSendReqCounter.WithLabelValues(reqType, storeID, strconv.FormatBool(staleRead), counterKey.requestSource),
|
||||||
|
metrics.TiKVSendReqTimeCounter.WithLabelValues(reqType, storeID, strconv.FormatBool(staleRead), counterKey.requestSource),
|
||||||
|
}
|
||||||
|
sendReqCounterCache.Store(counterKey, counter)
|
||||||
}
|
}
|
||||||
|
|
||||||
v.(prometheus.Observer).Observe(time.Since(start).Seconds())
|
secs := time.Since(start).Seconds()
|
||||||
|
hist.(prometheus.Observer).Observe(secs)
|
||||||
|
counter.(sendReqCounterCacheValue).counter.Inc()
|
||||||
|
counter.(sendReqCounterCacheValue).timeCounter.Add(secs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendRequest sends a Request to server and receives Response.
|
// SendRequest sends a Request to server and receives Response.
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ var (
|
||||||
TiKVTxnCmdHistogram *prometheus.HistogramVec
|
TiKVTxnCmdHistogram *prometheus.HistogramVec
|
||||||
TiKVBackoffHistogram *prometheus.HistogramVec
|
TiKVBackoffHistogram *prometheus.HistogramVec
|
||||||
TiKVSendReqHistogram *prometheus.HistogramVec
|
TiKVSendReqHistogram *prometheus.HistogramVec
|
||||||
|
TiKVSendReqCounter *prometheus.CounterVec
|
||||||
|
TiKVSendReqTimeCounter *prometheus.CounterVec
|
||||||
TiKVCoprocessorHistogram *prometheus.HistogramVec
|
TiKVCoprocessorHistogram *prometheus.HistogramVec
|
||||||
TiKVLockResolverCounter *prometheus.CounterVec
|
TiKVLockResolverCounter *prometheus.CounterVec
|
||||||
TiKVRegionErrorCounter *prometheus.CounterVec
|
TiKVRegionErrorCounter *prometheus.CounterVec
|
||||||
|
|
@ -112,6 +114,7 @@ const (
|
||||||
LblFromStore = "from_store"
|
LblFromStore = "from_store"
|
||||||
LblToStore = "to_store"
|
LblToStore = "to_store"
|
||||||
LblStaleRead = "stale_read"
|
LblStaleRead = "stale_read"
|
||||||
|
LblSource = "source"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initMetrics(namespace, subsystem string) {
|
func initMetrics(namespace, subsystem string) {
|
||||||
|
|
@ -142,6 +145,22 @@ func initMetrics(namespace, subsystem string) {
|
||||||
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 29), // 0.5ms ~ 1.5days
|
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 29), // 0.5ms ~ 1.5days
|
||||||
}, []string{LblType, LblStore, LblStaleRead})
|
}, []string{LblType, LblStore, LblStaleRead})
|
||||||
|
|
||||||
|
TiKVSendReqCounter = prometheus.NewCounterVec(
|
||||||
|
prometheus.CounterOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: subsystem,
|
||||||
|
Name: "request_counter",
|
||||||
|
Help: "Counter of sending request with multi dimensions.",
|
||||||
|
}, []string{LblType, LblStore, LblStaleRead, LblSource})
|
||||||
|
|
||||||
|
TiKVSendReqTimeCounter = prometheus.NewCounterVec(
|
||||||
|
prometheus.CounterOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: subsystem,
|
||||||
|
Name: "request_time_counter",
|
||||||
|
Help: "Counter of request time with multi dimensions.",
|
||||||
|
}, []string{LblType, LblStore, LblStaleRead, LblSource})
|
||||||
|
|
||||||
TiKVCoprocessorHistogram = prometheus.NewHistogramVec(
|
TiKVCoprocessorHistogram = prometheus.NewHistogramVec(
|
||||||
prometheus.HistogramOpts{
|
prometheus.HistogramOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
|
|
@ -578,6 +597,8 @@ func RegisterMetrics() {
|
||||||
prometheus.MustRegister(TiKVTxnCmdHistogram)
|
prometheus.MustRegister(TiKVTxnCmdHistogram)
|
||||||
prometheus.MustRegister(TiKVBackoffHistogram)
|
prometheus.MustRegister(TiKVBackoffHistogram)
|
||||||
prometheus.MustRegister(TiKVSendReqHistogram)
|
prometheus.MustRegister(TiKVSendReqHistogram)
|
||||||
|
prometheus.MustRegister(TiKVSendReqCounter)
|
||||||
|
prometheus.MustRegister(TiKVSendReqTimeCounter)
|
||||||
prometheus.MustRegister(TiKVCoprocessorHistogram)
|
prometheus.MustRegister(TiKVCoprocessorHistogram)
|
||||||
prometheus.MustRegister(TiKVLockResolverCounter)
|
prometheus.MustRegister(TiKVLockResolverCounter)
|
||||||
prometheus.MustRegister(TiKVRegionErrorCounter)
|
prometheus.MustRegister(TiKVRegionErrorCounter)
|
||||||
|
|
|
||||||
36
tikv/kv.go
36
tikv/kv.go
|
|
@ -251,7 +251,7 @@ func (s *KVStore) runSafePointChecker() {
|
||||||
|
|
||||||
// Begin a global transaction.
|
// Begin a global transaction.
|
||||||
func (s *KVStore) Begin(opts ...TxnOption) (*transaction.KVTxn, error) {
|
func (s *KVStore) Begin(opts ...TxnOption) (*transaction.KVTxn, error) {
|
||||||
options := &txnOptions{}
|
options := &transaction.TxnOptions{}
|
||||||
// Inject the options
|
// Inject the options
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(options)
|
opt(options)
|
||||||
|
|
@ -260,18 +260,22 @@ func (s *KVStore) Begin(opts ...TxnOption) (*transaction.KVTxn, error) {
|
||||||
if options.TxnScope == "" {
|
if options.TxnScope == "" {
|
||||||
options.TxnScope = oracle.GlobalTxnScope
|
options.TxnScope = oracle.GlobalTxnScope
|
||||||
}
|
}
|
||||||
|
var (
|
||||||
|
startTS uint64
|
||||||
|
err error
|
||||||
|
)
|
||||||
if options.StartTS != nil {
|
if options.StartTS != nil {
|
||||||
snapshot := txnsnapshot.NewTiKVSnapshot(s, *options.StartTS, s.nextReplicaReadSeed())
|
startTS = *options.StartTS
|
||||||
return transaction.NewTiKVTxn(s, snapshot, *options.StartTS, options.TxnScope)
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
bo := retry.NewBackofferWithVars(context.Background(), transaction.TsoMaxBackoff, nil)
|
bo := retry.NewBackofferWithVars(context.Background(), transaction.TsoMaxBackoff, nil)
|
||||||
startTS, err := s.getTimestampWithRetry(bo, options.TxnScope)
|
startTS, err = s.getTimestampWithRetry(bo, options.TxnScope)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
snapshot := txnsnapshot.NewTiKVSnapshot(s, startTS, s.nextReplicaReadSeed())
|
snapshot := txnsnapshot.NewTiKVSnapshot(s, startTS, s.nextReplicaReadSeed())
|
||||||
return transaction.NewTiKVTxn(s, snapshot, startTS, options.TxnScope)
|
return transaction.NewTiKVTxn(s, snapshot, startTS, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteRange delete all versions of all keys in the range[startKey,endKey) immediately.
|
// DeleteRange delete all versions of all keys in the range[startKey,endKey) immediately.
|
||||||
|
|
@ -516,6 +520,7 @@ func (s *KVStore) safeTSUpdater() {
|
||||||
t := time.NewTicker(time.Second * 2)
|
t := time.NewTicker(time.Second * 2)
|
||||||
defer t.Stop()
|
defer t.Stop()
|
||||||
ctx, cancel := context.WithCancel(s.ctx)
|
ctx, cancel := context.WithCancel(s.ctx)
|
||||||
|
ctx = util.WithInternalSourceType(ctx, util.InternalTxnGC)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|
@ -540,7 +545,9 @@ func (s *KVStore) updateSafeTS(ctx context.Context) {
|
||||||
resp, err := tikvClient.SendRequest(ctx, storeAddr, tikvrpc.NewRequest(tikvrpc.CmdStoreSafeTS, &kvrpcpb.StoreSafeTSRequest{KeyRange: &kvrpcpb.KeyRange{
|
resp, err := tikvClient.SendRequest(ctx, storeAddr, tikvrpc.NewRequest(tikvrpc.CmdStoreSafeTS, &kvrpcpb.StoreSafeTSRequest{KeyRange: &kvrpcpb.KeyRange{
|
||||||
StartKey: []byte(""),
|
StartKey: []byte(""),
|
||||||
EndKey: []byte(""),
|
EndKey: []byte(""),
|
||||||
}}), client.ReadTimeoutShort)
|
}}, kvrpcpb.Context{
|
||||||
|
RequestSource: util.RequestSourceFromCtx(ctx),
|
||||||
|
}), client.ReadTimeoutShort)
|
||||||
storeIDStr := strconv.Itoa(int(storeID))
|
storeIDStr := strconv.Itoa(int(storeID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
metrics.TiKVSafeTSUpdateCounter.WithLabelValues("fail", storeIDStr).Inc()
|
metrics.TiKVSafeTSUpdateCounter.WithLabelValues("fail", storeIDStr).Inc()
|
||||||
|
|
@ -602,26 +609,19 @@ func NewLockResolver(etcdAddrs []string, security config.Security, opts ...pd.Cl
|
||||||
return s.lockResolver, nil
|
return s.lockResolver, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// txnOptions indicates the option when beginning a transaction.
|
|
||||||
// txnOptions are set by the TxnOption values passed to Begin
|
|
||||||
type txnOptions struct {
|
|
||||||
TxnScope string
|
|
||||||
StartTS *uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
// TxnOption configures Transaction
|
// TxnOption configures Transaction
|
||||||
type TxnOption func(*txnOptions)
|
type TxnOption func(*transaction.TxnOptions)
|
||||||
|
|
||||||
// WithTxnScope sets the TxnScope to txnScope
|
// WithTxnScope sets the TxnScope to txnScope
|
||||||
func WithTxnScope(txnScope string) TxnOption {
|
func WithTxnScope(txnScope string) TxnOption {
|
||||||
return func(st *txnOptions) {
|
return func(st *transaction.TxnOptions) {
|
||||||
st.TxnScope = txnScope
|
st.TxnScope = txnScope
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithStartTS sets the StartTS to startTS
|
// WithStartTS sets the StartTS to startTS
|
||||||
func WithStartTS(startTS uint64) TxnOption {
|
func WithStartTS(startTS uint64) TxnOption {
|
||||||
return func(st *txnOptions) {
|
return func(st *transaction.TxnOptions) {
|
||||||
st.StartTS = &startTS
|
st.StartTS = &startTS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,7 @@ func (s *KVStore) batchSendSingleRegion(bo *Backoffer, batch kvrpc.Batch, scatte
|
||||||
SplitKeys: batch.Keys,
|
SplitKeys: batch.Keys,
|
||||||
}, kvrpcpb.Context{
|
}, kvrpcpb.Context{
|
||||||
Priority: kvrpcpb.CommandPri_Normal,
|
Priority: kvrpcpb.CommandPri_Normal,
|
||||||
|
RequestSource: util.RequestSourceFromCtx(bo.GetCtx()),
|
||||||
})
|
})
|
||||||
|
|
||||||
sender := locate.NewRegionRequestSender(s.regionCache, s.GetTiKVClient())
|
sender := locate.NewRegionRequestSender(s.regionCache, s.GetTiKVClient())
|
||||||
|
|
|
||||||
|
|
@ -647,7 +647,11 @@ func (c *twoPhaseCommitter) initKeysAndMutations(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
commitDetail := &util.CommitDetails{WriteSize: size, WriteKeys: c.mutations.Len()}
|
commitDetail := &util.CommitDetails{
|
||||||
|
WriteSize: size,
|
||||||
|
WriteKeys: c.mutations.Len(),
|
||||||
|
ResolveLock: util.ResolveLockDetail{},
|
||||||
|
}
|
||||||
metrics.TiKVTxnWriteKVCountHistogram.Observe(float64(commitDetail.WriteKeys))
|
metrics.TiKVTxnWriteKVCountHistogram.Observe(float64(commitDetail.WriteKeys))
|
||||||
metrics.TiKVTxnWriteSizeHistogram.Observe(float64(commitDetail.WriteSize))
|
metrics.TiKVTxnWriteSizeHistogram.Observe(float64(commitDetail.WriteSize))
|
||||||
c.hasNoNeedCommitKeys = checkCnt > 0
|
c.hasNoNeedCommitKeys = checkCnt > 0
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,13 @@ func (actionCleanup) handleSingleBatch(c *twoPhaseCommitter, bo *retry.Backoffer
|
||||||
req := tikvrpc.NewRequest(tikvrpc.CmdBatchRollback, &kvrpcpb.BatchRollbackRequest{
|
req := tikvrpc.NewRequest(tikvrpc.CmdBatchRollback, &kvrpcpb.BatchRollbackRequest{
|
||||||
Keys: batch.mutations.GetKeys(),
|
Keys: batch.mutations.GetKeys(),
|
||||||
StartVersion: c.startTS,
|
StartVersion: c.startTS,
|
||||||
}, kvrpcpb.Context{Priority: c.priority, SyncLog: c.syncLog, ResourceGroupTag: c.resourceGroupTag,
|
}, kvrpcpb.Context{
|
||||||
MaxExecutionDurationMs: uint64(client.MaxWriteExecutionTime.Milliseconds())})
|
Priority: c.priority,
|
||||||
|
SyncLog: c.syncLog,
|
||||||
|
ResourceGroupTag: c.resourceGroupTag,
|
||||||
|
MaxExecutionDurationMs: uint64(client.MaxWriteExecutionTime.Milliseconds()),
|
||||||
|
RequestSource: c.txn.GetRequestSource(),
|
||||||
|
})
|
||||||
if c.resourceGroupTag == nil && c.resourceGroupTagger != nil {
|
if c.resourceGroupTag == nil && c.resourceGroupTagger != nil {
|
||||||
c.resourceGroupTagger(req)
|
c.resourceGroupTagger(req)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,14 @@ func (actionCommit) handleSingleBatch(c *twoPhaseCommitter, bo *retry.Backoffer,
|
||||||
StartVersion: c.startTS,
|
StartVersion: c.startTS,
|
||||||
Keys: keys,
|
Keys: keys,
|
||||||
CommitVersion: c.commitTS,
|
CommitVersion: c.commitTS,
|
||||||
}, kvrpcpb.Context{Priority: c.priority, SyncLog: c.syncLog,
|
}, kvrpcpb.Context{
|
||||||
ResourceGroupTag: c.resourceGroupTag, DiskFullOpt: c.diskFullOpt,
|
Priority: c.priority,
|
||||||
MaxExecutionDurationMs: uint64(client.MaxWriteExecutionTime.Milliseconds())})
|
SyncLog: c.syncLog,
|
||||||
|
ResourceGroupTag: c.resourceGroupTag,
|
||||||
|
DiskFullOpt: c.diskFullOpt,
|
||||||
|
MaxExecutionDurationMs: uint64(client.MaxWriteExecutionTime.Milliseconds()),
|
||||||
|
RequestSource: c.txn.GetRequestSource(),
|
||||||
|
})
|
||||||
if c.resourceGroupTag == nil && c.resourceGroupTagger != nil {
|
if c.resourceGroupTag == nil && c.resourceGroupTagger != nil {
|
||||||
c.resourceGroupTagger(req)
|
c.resourceGroupTagger(req)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,13 @@ func (action actionPessimisticLock) handleSingleBatch(c *twoPhaseCommitter, bo *
|
||||||
ReturnValues: action.ReturnValues,
|
ReturnValues: action.ReturnValues,
|
||||||
CheckExistence: action.CheckExistence,
|
CheckExistence: action.CheckExistence,
|
||||||
MinCommitTs: c.forUpdateTS + 1,
|
MinCommitTs: c.forUpdateTS + 1,
|
||||||
}, kvrpcpb.Context{Priority: c.priority, SyncLog: c.syncLog, ResourceGroupTag: action.LockCtx.ResourceGroupTag,
|
}, kvrpcpb.Context{
|
||||||
MaxExecutionDurationMs: uint64(client.MaxWriteExecutionTime.Milliseconds())})
|
Priority: c.priority,
|
||||||
|
SyncLog: c.syncLog,
|
||||||
|
ResourceGroupTag: action.LockCtx.ResourceGroupTag,
|
||||||
|
MaxExecutionDurationMs: uint64(client.MaxWriteExecutionTime.Milliseconds()),
|
||||||
|
RequestSource: c.txn.GetRequestSource(),
|
||||||
|
})
|
||||||
if action.LockCtx.ResourceGroupTag == nil && action.LockCtx.ResourceGroupTagger != nil {
|
if action.LockCtx.ResourceGroupTag == nil && action.LockCtx.ResourceGroupTagger != nil {
|
||||||
req.ResourceGroupTag = action.LockCtx.ResourceGroupTagger(req.Req.(*kvrpcpb.PessimisticLockRequest))
|
req.ResourceGroupTag = action.LockCtx.ResourceGroupTagger(req.Req.(*kvrpcpb.PessimisticLockRequest))
|
||||||
}
|
}
|
||||||
|
|
@ -226,7 +231,6 @@ func (action actionPessimisticLock) handleSingleBatch(c *twoPhaseCommitter, bo *
|
||||||
}
|
}
|
||||||
// Because we already waited on tikv, no need to Backoff here.
|
// Because we already waited on tikv, no need to Backoff here.
|
||||||
// tikv default will wait 3s(also the maximum wait value) when lock error occurs
|
// tikv default will wait 3s(also the maximum wait value) when lock error occurs
|
||||||
startTime = time.Now()
|
|
||||||
if resolvingRecordToken == nil {
|
if resolvingRecordToken == nil {
|
||||||
token := c.store.GetLockResolver().RecordResolvingLocks(locks, c.startTS)
|
token := c.store.GetLockResolver().RecordResolvingLocks(locks, c.startTS)
|
||||||
resolvingRecordToken = &token
|
resolvingRecordToken = &token
|
||||||
|
|
@ -234,17 +238,19 @@ func (action actionPessimisticLock) handleSingleBatch(c *twoPhaseCommitter, bo *
|
||||||
} else {
|
} else {
|
||||||
c.store.GetLockResolver().UpdateResolvingLocks(locks, c.startTS, *resolvingRecordToken)
|
c.store.GetLockResolver().UpdateResolvingLocks(locks, c.startTS, *resolvingRecordToken)
|
||||||
}
|
}
|
||||||
msBeforeTxnExpired, err := c.store.GetLockResolver().ResolveLocks(bo, 0, locks)
|
resolveLockOpts := txnlock.ResolveLocksOptions{
|
||||||
|
CallerStartTS: 0,
|
||||||
|
Locks: locks,
|
||||||
|
Detail: &action.LockCtx.Stats.ResolveLock,
|
||||||
|
}
|
||||||
|
resolveLockRes, err := c.store.GetLockResolver().ResolveLocksWithOpts(bo, resolveLockOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if action.LockCtx.Stats != nil {
|
|
||||||
atomic.AddInt64(&action.LockCtx.Stats.ResolveLockTime, int64(time.Since(startTime)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// If msBeforeTxnExpired is not zero, it means there are still locks blocking us acquiring
|
// If msBeforeTxnExpired is not zero, it means there are still locks blocking us acquiring
|
||||||
// the pessimistic lock. We should return acquire fail with nowait set or timeout error if necessary.
|
// the pessimistic lock. We should return acquire fail with nowait set or timeout error if necessary.
|
||||||
if msBeforeTxnExpired > 0 {
|
if resolveLockRes.TTL > 0 {
|
||||||
if action.LockWaitTime() == kv.LockNoWait {
|
if action.LockWaitTime() == kv.LockNoWait {
|
||||||
return errors.WithStack(tikverr.ErrLockAcquireFailAndNoWaitSet)
|
return errors.WithStack(tikverr.ErrLockAcquireFailAndNoWaitSet)
|
||||||
} else if action.LockWaitTime() == kv.LockAlwaysWait {
|
} else if action.LockWaitTime() == kv.LockAlwaysWait {
|
||||||
|
|
@ -280,6 +286,7 @@ func (actionPessimisticRollback) handleSingleBatch(c *twoPhaseCommitter, bo *ret
|
||||||
ForUpdateTs: c.forUpdateTS,
|
ForUpdateTs: c.forUpdateTS,
|
||||||
Keys: batch.mutations.GetKeys(),
|
Keys: batch.mutations.GetKeys(),
|
||||||
})
|
})
|
||||||
|
req.RequestSource = util.RequestSourceFromCtx(bo.GetCtx())
|
||||||
req.MaxExecutionDurationMs = uint64(client.MaxWriteExecutionTime.Milliseconds())
|
req.MaxExecutionDurationMs = uint64(client.MaxWriteExecutionTime.Milliseconds())
|
||||||
resp, err := c.store.SendReq(bo, req, batch.region, client.ReadTimeoutShort)
|
resp, err := c.store.SendReq(bo, req, batch.region, client.ReadTimeoutShort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -170,9 +170,14 @@ func (c *twoPhaseCommitter) buildPrewriteRequest(batch batchMutations, txnSize u
|
||||||
req.TryOnePc = true
|
req.TryOnePc = true
|
||||||
}
|
}
|
||||||
|
|
||||||
r := tikvrpc.NewRequest(tikvrpc.CmdPrewrite, req,
|
r := tikvrpc.NewRequest(tikvrpc.CmdPrewrite, req, kvrpcpb.Context{
|
||||||
kvrpcpb.Context{Priority: c.priority, SyncLog: c.syncLog, ResourceGroupTag: c.resourceGroupTag,
|
Priority: c.priority,
|
||||||
DiskFullOpt: c.diskFullOpt, MaxExecutionDurationMs: uint64(client.MaxWriteExecutionTime.Milliseconds())})
|
SyncLog: c.syncLog,
|
||||||
|
ResourceGroupTag: c.resourceGroupTag,
|
||||||
|
DiskFullOpt: c.diskFullOpt,
|
||||||
|
MaxExecutionDurationMs: uint64(client.MaxWriteExecutionTime.Milliseconds()),
|
||||||
|
RequestSource: c.txn.GetRequestSource(),
|
||||||
|
})
|
||||||
if c.resourceGroupTag == nil && c.resourceGroupTagger != nil {
|
if c.resourceGroupTag == nil && c.resourceGroupTagger != nil {
|
||||||
c.resourceGroupTagger(r)
|
c.resourceGroupTagger(r)
|
||||||
}
|
}
|
||||||
|
|
@ -382,7 +387,6 @@ func (action actionPrewrite) handleSingleBatch(c *twoPhaseCommitter, bo *retry.B
|
||||||
}
|
}
|
||||||
locks = append(locks, lock)
|
locks = append(locks, lock)
|
||||||
}
|
}
|
||||||
start := time.Now()
|
|
||||||
if resolvingRecordToken == nil {
|
if resolvingRecordToken == nil {
|
||||||
token := c.store.GetLockResolver().RecordResolvingLocks(locks, c.startTS)
|
token := c.store.GetLockResolver().RecordResolvingLocks(locks, c.startTS)
|
||||||
resolvingRecordToken = &token
|
resolvingRecordToken = &token
|
||||||
|
|
@ -390,11 +394,16 @@ func (action actionPrewrite) handleSingleBatch(c *twoPhaseCommitter, bo *retry.B
|
||||||
} else {
|
} else {
|
||||||
c.store.GetLockResolver().UpdateResolvingLocks(locks, c.startTS, *resolvingRecordToken)
|
c.store.GetLockResolver().UpdateResolvingLocks(locks, c.startTS, *resolvingRecordToken)
|
||||||
}
|
}
|
||||||
msBeforeExpired, err := c.store.GetLockResolver().ResolveLocks(bo, c.startTS, locks)
|
resolveLockOpts := txnlock.ResolveLocksOptions{
|
||||||
|
CallerStartTS: c.startTS,
|
||||||
|
Locks: locks,
|
||||||
|
Detail: &c.getDetail().ResolveLock,
|
||||||
|
}
|
||||||
|
resolveLockRes, err := c.store.GetLockResolver().ResolveLocksWithOpts(bo, resolveLockOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
atomic.AddInt64(&c.getDetail().ResolveLockTime, int64(time.Since(start)))
|
msBeforeExpired := resolveLockRes.TTL
|
||||||
if msBeforeExpired > 0 {
|
if msBeforeExpired > 0 {
|
||||||
err = bo.BackoffWithCfgAndMaxSleep(retry.BoTxnLock, int(msBeforeExpired), errors.Errorf("2PC prewrite lockedKeys: %d", len(locks)))
|
err = bo.BackoffWithCfgAndMaxSleep(retry.BoTxnLock, int(msBeforeExpired), errors.Errorf("2PC prewrite lockedKeys: %d", len(locks)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,13 @@ type SchemaAmender interface {
|
||||||
AmendTxn(ctx context.Context, startInfoSchema SchemaVer, change *RelatedSchemaChange, mutations CommitterMutations) (CommitterMutations, error)
|
AmendTxn(ctx context.Context, startInfoSchema SchemaVer, change *RelatedSchemaChange, mutations CommitterMutations) (CommitterMutations, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TxnOptions indicates the option when beginning a transaction.
|
||||||
|
// TxnOptions are set by the TxnOption values passed to Begin
|
||||||
|
type TxnOptions struct {
|
||||||
|
TxnScope string
|
||||||
|
StartTS *uint64
|
||||||
|
}
|
||||||
|
|
||||||
// KVTxn contains methods to interact with a TiKV transaction.
|
// KVTxn contains methods to interact with a TiKV transaction.
|
||||||
type KVTxn struct {
|
type KVTxn struct {
|
||||||
snapshot *txnsnapshot.KVSnapshot
|
snapshot *txnsnapshot.KVSnapshot
|
||||||
|
|
@ -117,10 +124,11 @@ type KVTxn struct {
|
||||||
// interceptor is used to decorate the RPC request logic related to the txn.
|
// interceptor is used to decorate the RPC request logic related to the txn.
|
||||||
interceptor interceptor.RPCInterceptor
|
interceptor interceptor.RPCInterceptor
|
||||||
assertionLevel kvrpcpb.AssertionLevel
|
assertionLevel kvrpcpb.AssertionLevel
|
||||||
|
*util.RequestSource
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTiKVTxn creates a new KVTxn.
|
// NewTiKVTxn creates a new KVTxn.
|
||||||
func NewTiKVTxn(store kvstore, snapshot *txnsnapshot.KVSnapshot, startTS uint64, scope string) (*KVTxn, error) {
|
func NewTiKVTxn(store kvstore, snapshot *txnsnapshot.KVSnapshot, startTS uint64, options *TxnOptions) (*KVTxn, error) {
|
||||||
cfg := config.GetGlobalConfig()
|
cfg := config.GetGlobalConfig()
|
||||||
newTiKVTxn := &KVTxn{
|
newTiKVTxn := &KVTxn{
|
||||||
snapshot: snapshot,
|
snapshot: snapshot,
|
||||||
|
|
@ -130,10 +138,11 @@ func NewTiKVTxn(store kvstore, snapshot *txnsnapshot.KVSnapshot, startTS uint64,
|
||||||
startTime: time.Now(),
|
startTime: time.Now(),
|
||||||
valid: true,
|
valid: true,
|
||||||
vars: tikv.DefaultVars,
|
vars: tikv.DefaultVars,
|
||||||
scope: scope,
|
scope: options.TxnScope,
|
||||||
enableAsyncCommit: cfg.EnableAsyncCommit,
|
enableAsyncCommit: cfg.EnableAsyncCommit,
|
||||||
enable1PC: cfg.Enable1PC,
|
enable1PC: cfg.Enable1PC,
|
||||||
diskFullOpt: kvrpcpb.DiskFullOpt_NotAllowedOnFull,
|
diskFullOpt: kvrpcpb.DiskFullOpt_NotAllowedOnFull,
|
||||||
|
RequestSource: snapshot.RequestSource,
|
||||||
}
|
}
|
||||||
return newTiKVTxn, nil
|
return newTiKVTxn, nil
|
||||||
}
|
}
|
||||||
|
|
@ -361,6 +370,8 @@ func (txn *KVTxn) Commit(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
defer txn.close()
|
defer txn.close()
|
||||||
|
|
||||||
|
ctx = context.WithValue(ctx, util.RequestSourceKey, *txn.RequestSource)
|
||||||
|
|
||||||
if val, err := util.EvalFailpoint("mockCommitError"); err == nil && val.(bool) {
|
if val, err := util.EvalFailpoint("mockCommitError"); err == nil && val.(bool) {
|
||||||
if _, err := util.EvalFailpoint("mockCommitErrorOpt"); err == nil {
|
if _, err := util.EvalFailpoint("mockCommitErrorOpt"); err == nil {
|
||||||
failpoint.Disable("tikvclient/mockCommitErrorOpt")
|
failpoint.Disable("tikvclient/mockCommitErrorOpt")
|
||||||
|
|
@ -494,7 +505,8 @@ func (txn *KVTxn) rollbackPessimisticLocks() error {
|
||||||
if txn.lockedCnt == 0 {
|
if txn.lockedCnt == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
bo := retry.NewBackofferWithVars(context.Background(), cleanupMaxBackoff, txn.vars)
|
ctx := context.WithValue(context.Background(), util.RequestSourceKey, *txn.RequestSource)
|
||||||
|
bo := retry.NewBackofferWithVars(ctx, cleanupMaxBackoff, txn.vars)
|
||||||
if txn.interceptor != nil {
|
if txn.interceptor != nil {
|
||||||
// User has called txn.SetRPCInterceptor() to explicitly set an interceptor, we
|
// User has called txn.SetRPCInterceptor() to explicitly set an interceptor, we
|
||||||
// need to bind it to ctx so that the internal client can perceive and execute
|
// need to bind it to ctx so that the internal client can perceive and execute
|
||||||
|
|
@ -583,6 +595,7 @@ func (txn *KVTxn) LockKeys(ctx context.Context, lockCtx *tikv.LockCtx, keysInput
|
||||||
// it before initiating an RPC request.
|
// it before initiating an RPC request.
|
||||||
ctx = interceptor.WithRPCInterceptor(ctx, txn.interceptor)
|
ctx = interceptor.WithRPCInterceptor(ctx, txn.interceptor)
|
||||||
}
|
}
|
||||||
|
ctx = context.WithValue(ctx, util.RequestSourceKey, *txn.RequestSource)
|
||||||
// Exclude keys that are already locked.
|
// Exclude keys that are already locked.
|
||||||
var err error
|
var err error
|
||||||
keys := make([][]byte, 0, len(keysInput))
|
keys := make([][]byte, 0, len(keysInput))
|
||||||
|
|
@ -663,6 +676,7 @@ func (txn *KVTxn) LockKeys(ctx context.Context, lockCtx *tikv.LockCtx, keysInput
|
||||||
|
|
||||||
lockCtx.Stats = &util.LockKeysDetails{
|
lockCtx.Stats = &util.LockKeysDetails{
|
||||||
LockKeys: int32(len(keys)),
|
LockKeys: int32(len(keys)),
|
||||||
|
ResolveLock: util.ResolveLockDetail{},
|
||||||
}
|
}
|
||||||
bo := retry.NewBackofferWithVars(ctx, pessimisticLockMaxBackoff, txn.vars)
|
bo := retry.NewBackofferWithVars(ctx, pessimisticLockMaxBackoff, txn.vars)
|
||||||
txn.committer.forUpdateTS = lockCtx.ForUpdateTS
|
txn.committer.forUpdateTS = lockCtx.ForUpdateTS
|
||||||
|
|
@ -869,3 +883,13 @@ func (txn *KVTxn) SetBinlogExecutor(binlog BinlogExecutor) {
|
||||||
func (txn *KVTxn) GetClusterID() uint64 {
|
func (txn *KVTxn) GetClusterID() uint64 {
|
||||||
return txn.store.GetClusterID()
|
return txn.store.GetClusterID()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetRequestSourceInternal sets the scope of the request source.
|
||||||
|
func (txn *KVTxn) SetRequestSourceInternal(internal bool) {
|
||||||
|
txn.RequestSource.SetRequestSourceInternal(internal)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRequestSourceType sets the type of the request source.
|
||||||
|
func (txn *KVTxn) SetRequestSourceType(tp string) {
|
||||||
|
txn.RequestSource.SetRequestSourceType(tp)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pingcap/kvproto/pkg/kvrpcpb"
|
"github.com/pingcap/kvproto/pkg/kvrpcpb"
|
||||||
|
|
@ -283,7 +284,8 @@ func (lr *LockResolver) BatchResolveLocks(bo *retry.Backoffer, locks []*Lock, lo
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
req := tikvrpc.NewRequest(tikvrpc.CmdResolveLock, &kvrpcpb.ResolveLockRequest{TxnInfos: listTxnInfos})
|
req := tikvrpc.NewRequest(tikvrpc.CmdResolveLock, &kvrpcpb.ResolveLockRequest{TxnInfos: listTxnInfos},
|
||||||
|
kvrpcpb.Context{RequestSource: util.RequestSourceFromCtx(bo.GetCtx())})
|
||||||
req.MaxExecutionDurationMs = uint64(client.MaxWriteExecutionTime.Milliseconds())
|
req.MaxExecutionDurationMs = uint64(client.MaxWriteExecutionTime.Milliseconds())
|
||||||
startTime = time.Now()
|
startTime = time.Now()
|
||||||
resp, err := lr.store.SendReq(bo, req, loc, client.ReadTimeoutShort)
|
resp, err := lr.store.SendReq(bo, req, loc, client.ReadTimeoutShort)
|
||||||
|
|
@ -318,6 +320,27 @@ func (lr *LockResolver) BatchResolveLocks(bo *retry.Backoffer, locks []*Lock, lo
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResolveLocksOptions is the options struct for calling resolving lock.
|
||||||
|
type ResolveLocksOptions struct {
|
||||||
|
CallerStartTS uint64
|
||||||
|
Locks []*Lock
|
||||||
|
Lite bool
|
||||||
|
ForRead bool
|
||||||
|
Detail *util.ResolveLockDetail
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolveLockResult is the result struct for resolving lock.
|
||||||
|
type ResolveLockResult struct {
|
||||||
|
TTL int64
|
||||||
|
IgnoreLocks []uint64
|
||||||
|
AccessLocks []uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolveLocksWithOpts wraps ResolveLocks and ResolveLocksForRead, which extract the parameters into structs for better extension.
|
||||||
|
func (lr *LockResolver) ResolveLocksWithOpts(bo *retry.Backoffer, opts ResolveLocksOptions) (ResolveLockResult, error) {
|
||||||
|
return lr.resolveLocks(bo, opts)
|
||||||
|
}
|
||||||
|
|
||||||
// ResolveLocks tries to resolve Locks. The resolving process is in 3 steps:
|
// ResolveLocks tries to resolve Locks. The resolving process is in 3 steps:
|
||||||
// 1) Use the `lockTTL` to pick up all expired locks. Only locks that are too
|
// 1) Use the `lockTTL` to pick up all expired locks. Only locks that are too
|
||||||
// old are considered orphan locks and will be handled later. If all locks
|
// old are considered orphan locks and will be handled later. If all locks
|
||||||
|
|
@ -328,15 +351,26 @@ func (lr *LockResolver) BatchResolveLocks(bo *retry.Backoffer, locks []*Lock, lo
|
||||||
// 3) Send `ResolveLock` cmd to the lock's region to resolve all locks belong to
|
// 3) Send `ResolveLock` cmd to the lock's region to resolve all locks belong to
|
||||||
// the same transaction.
|
// the same transaction.
|
||||||
func (lr *LockResolver) ResolveLocks(bo *retry.Backoffer, callerStartTS uint64, locks []*Lock) (int64, error) {
|
func (lr *LockResolver) ResolveLocks(bo *retry.Backoffer, callerStartTS uint64, locks []*Lock) (int64, error) {
|
||||||
ttl, _, _, err := lr.resolveLocks(bo, callerStartTS, locks, false, false)
|
opts := ResolveLocksOptions{
|
||||||
return ttl, err
|
CallerStartTS: callerStartTS,
|
||||||
|
Locks: locks,
|
||||||
|
}
|
||||||
|
res, err := lr.resolveLocks(bo, opts)
|
||||||
|
return res.TTL, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResolveLocksForRead is essentially the same as ResolveLocks, except with some optimizations for read.
|
// ResolveLocksForRead is essentially the same as ResolveLocks, except with some optimizations for read.
|
||||||
// Read operations needn't wait for resolve secondary locks and can read through(the lock's transaction is committed
|
// Read operations needn't wait for resolve secondary locks and can read through(the lock's transaction is committed
|
||||||
// and its commitTS is less than or equal to callerStartTS) or ignore(the lock's transaction is rolled back or its minCommitTS is pushed) the lock .
|
// and its commitTS is less than or equal to callerStartTS) or ignore(the lock's transaction is rolled back or its minCommitTS is pushed) the lock .
|
||||||
func (lr *LockResolver) ResolveLocksForRead(bo *retry.Backoffer, callerStartTS uint64, locks []*Lock, lite bool) (int64, []uint64 /* canIgnore */, []uint64 /* canAccess */, error) {
|
func (lr *LockResolver) ResolveLocksForRead(bo *retry.Backoffer, callerStartTS uint64, locks []*Lock, lite bool) (int64, []uint64 /* canIgnore */, []uint64 /* canAccess */, error) {
|
||||||
return lr.resolveLocks(bo, callerStartTS, locks, true, lite)
|
opts := ResolveLocksOptions{
|
||||||
|
CallerStartTS: callerStartTS,
|
||||||
|
Locks: locks,
|
||||||
|
Lite: lite,
|
||||||
|
ForRead: true,
|
||||||
|
}
|
||||||
|
res, err := lr.resolveLocks(bo, opts)
|
||||||
|
return res.TTL, res.IgnoreLocks, res.AccessLocks, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// RecordResolvingLocks records a txn which startTS is callerStartTS tries to resolve locks
|
// RecordResolvingLocks records a txn which startTS is callerStartTS tries to resolve locks
|
||||||
|
|
@ -378,22 +412,33 @@ func (lr *LockResolver) ResolveLocksDone(callerStartTS uint64, token int) {
|
||||||
lr.mu.Unlock()
|
lr.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lr *LockResolver) resolveLocks(bo *retry.Backoffer, callerStartTS uint64, locks []*Lock, forRead bool, lite bool) (int64, []uint64 /* canIgnore */, []uint64 /* canAccess */, error) {
|
func (lr *LockResolver) resolveLocks(bo *retry.Backoffer, opts ResolveLocksOptions) (ResolveLockResult, error) {
|
||||||
|
callerStartTS, locks, forRead, lite, detail := opts.CallerStartTS, opts.Locks, opts.ForRead, opts.Lite, opts.Detail
|
||||||
if lr.testingKnobs.meetLock != nil {
|
if lr.testingKnobs.meetLock != nil {
|
||||||
lr.testingKnobs.meetLock(locks)
|
lr.testingKnobs.meetLock(locks)
|
||||||
}
|
}
|
||||||
var msBeforeTxnExpired txnExpireTime
|
var msBeforeTxnExpired txnExpireTime
|
||||||
if len(locks) == 0 {
|
if len(locks) == 0 {
|
||||||
return msBeforeTxnExpired.value(), nil, nil, nil
|
return ResolveLockResult{
|
||||||
|
TTL: msBeforeTxnExpired.value(),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
metrics.LockResolverCountWithResolve.Inc()
|
metrics.LockResolverCountWithResolve.Inc()
|
||||||
|
// This is the origin resolve lock time.
|
||||||
|
// TODO(you06): record the more details and calculate the total time by calculating the sum of details.
|
||||||
|
if detail != nil {
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
atomic.AddInt64(&detail.ResolveLockTime, int64(time.Since(startTime)))
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// TxnID -> []Region, record resolved Regions.
|
// TxnID -> []Region, record resolved Regions.
|
||||||
// TODO: Maybe put it in LockResolver and share by all txns.
|
// TODO: Maybe put it in LockResolver and share by all txns.
|
||||||
cleanTxns := make(map[uint64]map[locate.RegionVerID]struct{})
|
cleanTxns := make(map[uint64]map[locate.RegionVerID]struct{})
|
||||||
var resolve func(*Lock, bool) (TxnStatus, error)
|
var resolve func(*Lock, bool) (TxnStatus, error)
|
||||||
resolve = func(l *Lock, forceSyncCommit bool) (TxnStatus, error) {
|
resolve = func(l *Lock, forceSyncCommit bool) (TxnStatus, error) {
|
||||||
status, err := lr.getTxnStatusFromLock(bo, l, callerStartTS, forceSyncCommit)
|
status, err := lr.getTxnStatusFromLock(bo, l, callerStartTS, forceSyncCommit, detail)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return TxnStatus{}, err
|
return TxnStatus{}, err
|
||||||
}
|
}
|
||||||
|
|
@ -426,7 +471,8 @@ func (lr *LockResolver) resolveLocks(bo *retry.Backoffer, callerStartTS uint64,
|
||||||
err = lr.resolvePessimisticLock(bo, l)
|
err = lr.resolvePessimisticLock(bo, l)
|
||||||
} else {
|
} else {
|
||||||
if forRead {
|
if forRead {
|
||||||
asyncBo := retry.NewBackoffer(lr.asyncResolveCtx, asyncResolveLockMaxBackoff)
|
asyncCtx := context.WithValue(lr.asyncResolveCtx, util.RequestSourceKey, bo.GetCtx().Value(util.RequestSourceKey))
|
||||||
|
asyncBo := retry.NewBackoffer(asyncCtx, asyncResolveLockMaxBackoff)
|
||||||
go func() {
|
go func() {
|
||||||
// Pass an empty cleanRegions here to avoid data race and
|
// Pass an empty cleanRegions here to avoid data race and
|
||||||
// let `reqCollapse` deduplicate identical resolve requests.
|
// let `reqCollapse` deduplicate identical resolve requests.
|
||||||
|
|
@ -448,7 +494,9 @@ func (lr *LockResolver) resolveLocks(bo *retry.Backoffer, callerStartTS uint64,
|
||||||
status, err := resolve(l, false)
|
status, err := resolve(l, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msBeforeTxnExpired.update(0)
|
msBeforeTxnExpired.update(0)
|
||||||
return msBeforeTxnExpired.value(), nil, nil, err
|
return ResolveLockResult{
|
||||||
|
TTL: msBeforeTxnExpired.value(),
|
||||||
|
}, err
|
||||||
}
|
}
|
||||||
if !forRead {
|
if !forRead {
|
||||||
if status.ttl != 0 {
|
if status.ttl != 0 {
|
||||||
|
|
@ -478,7 +526,11 @@ func (lr *LockResolver) resolveLocks(bo *retry.Backoffer, callerStartTS uint64,
|
||||||
if msBeforeTxnExpired.value() > 0 {
|
if msBeforeTxnExpired.value() > 0 {
|
||||||
metrics.LockResolverCountWithWaitExpired.Inc()
|
metrics.LockResolverCountWithWaitExpired.Inc()
|
||||||
}
|
}
|
||||||
return msBeforeTxnExpired.value(), canIgnore, canAccess, nil
|
return ResolveLockResult{
|
||||||
|
TTL: msBeforeTxnExpired.value(),
|
||||||
|
IgnoreLocks: canIgnore,
|
||||||
|
AccessLocks: canAccess,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolving returns the locks' information we are resolving currently.
|
// Resolving returns the locks' information we are resolving currently.
|
||||||
|
|
@ -541,7 +593,7 @@ func (lr *LockResolver) GetTxnStatus(txnID uint64, callerStartTS uint64, primary
|
||||||
return lr.getTxnStatus(bo, txnID, primary, callerStartTS, currentTS, true, false, nil)
|
return lr.getTxnStatus(bo, txnID, primary, callerStartTS, currentTS, true, false, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lr *LockResolver) getTxnStatusFromLock(bo *retry.Backoffer, l *Lock, callerStartTS uint64, forceSyncCommit bool) (TxnStatus, error) {
|
func (lr *LockResolver) getTxnStatusFromLock(bo *retry.Backoffer, l *Lock, callerStartTS uint64, forceSyncCommit bool, detail *util.ResolveLockDetail) (TxnStatus, error) {
|
||||||
var currentTS uint64
|
var currentTS uint64
|
||||||
var err error
|
var err error
|
||||||
var status TxnStatus
|
var status TxnStatus
|
||||||
|
|
@ -649,6 +701,8 @@ func (lr *LockResolver) getTxnStatus(bo *retry.Backoffer, txnID uint64, primary
|
||||||
RollbackIfNotExist: rollbackIfNotExist,
|
RollbackIfNotExist: rollbackIfNotExist,
|
||||||
ForceSyncCommit: forceSyncCommit,
|
ForceSyncCommit: forceSyncCommit,
|
||||||
ResolvingPessimisticLock: resolvingPessimisticLock,
|
ResolvingPessimisticLock: resolvingPessimisticLock,
|
||||||
|
}, kvrpcpb.Context{
|
||||||
|
RequestSource: util.RequestSourceFromCtx(bo.GetCtx()),
|
||||||
})
|
})
|
||||||
for {
|
for {
|
||||||
loc, err := lr.store.GetRegionCache().LocateKey(bo, primary)
|
loc, err := lr.store.GetRegionCache().LocateKey(bo, primary)
|
||||||
|
|
@ -790,7 +844,9 @@ func (lr *LockResolver) checkSecondaries(bo *retry.Backoffer, txnID uint64, curK
|
||||||
Keys: curKeys,
|
Keys: curKeys,
|
||||||
StartVersion: txnID,
|
StartVersion: txnID,
|
||||||
}
|
}
|
||||||
req := tikvrpc.NewRequest(tikvrpc.CmdCheckSecondaryLocks, checkReq)
|
req := tikvrpc.NewRequest(tikvrpc.CmdCheckSecondaryLocks, checkReq, kvrpcpb.Context{
|
||||||
|
RequestSource: util.RequestSourceFromCtx(bo.GetCtx()),
|
||||||
|
})
|
||||||
metrics.LockResolverCountWithQueryCheckSecondaryLocks.Inc()
|
metrics.LockResolverCountWithQueryCheckSecondaryLocks.Inc()
|
||||||
req.MaxExecutionDurationMs = uint64(client.MaxWriteExecutionTime.Milliseconds())
|
req.MaxExecutionDurationMs = uint64(client.MaxWriteExecutionTime.Milliseconds())
|
||||||
resp, err := lr.store.SendReq(bo, req, curRegionID, client.ReadTimeoutShort)
|
resp, err := lr.store.SendReq(bo, req, curRegionID, client.ReadTimeoutShort)
|
||||||
|
|
@ -1022,6 +1078,7 @@ func (lr *LockResolver) resolveLock(bo *retry.Backoffer, l *Lock, status TxnStat
|
||||||
}
|
}
|
||||||
req := tikvrpc.NewRequest(tikvrpc.CmdResolveLock, lreq)
|
req := tikvrpc.NewRequest(tikvrpc.CmdResolveLock, lreq)
|
||||||
req.MaxExecutionDurationMs = uint64(client.MaxWriteExecutionTime.Milliseconds())
|
req.MaxExecutionDurationMs = uint64(client.MaxWriteExecutionTime.Milliseconds())
|
||||||
|
req.RequestSource = util.RequestSourceFromCtx(bo.GetCtx())
|
||||||
resp, err := lr.store.SendReq(bo, req, loc.Region, client.ReadTimeoutShort)
|
resp, err := lr.store.SendReq(bo, req, loc.Region, client.ReadTimeoutShort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ func (l LockResolverProbe) GetTxnStatus(bo *retry.Backoffer, txnID uint64, prima
|
||||||
|
|
||||||
// GetTxnStatusFromLock queries tikv for a txn's status.
|
// GetTxnStatusFromLock queries tikv for a txn's status.
|
||||||
func (l LockResolverProbe) GetTxnStatusFromLock(bo *retry.Backoffer, lock *Lock, callerStartTS uint64, forceSyncCommit bool) (TxnStatus, error) {
|
func (l LockResolverProbe) GetTxnStatusFromLock(bo *retry.Backoffer, lock *Lock, callerStartTS uint64, forceSyncCommit bool) (TxnStatus, error) {
|
||||||
return l.getTxnStatusFromLock(bo, lock, callerStartTS, forceSyncCommit)
|
return l.getTxnStatusFromLock(bo, lock, callerStartTS, forceSyncCommit, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSecondariesFromTxnStatus returns the secondary locks from txn status.
|
// GetSecondariesFromTxnStatus returns the secondary locks from txn status.
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,28 @@ func NewClientHelper(store kvstore, resolvedLocks *util.TSSet, committedLocks *u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResolveLocksWithOpts wraps the ResolveLocksWithOpts function and store the resolved result.
|
||||||
|
func (ch *ClientHelper) ResolveLocksWithOpts(bo *retry.Backoffer, opts txnlock.ResolveLocksOptions) (txnlock.ResolveLockResult, error) {
|
||||||
|
if ch.Stats != nil {
|
||||||
|
defer func(start time.Time) {
|
||||||
|
locate.RecordRegionRequestRuntimeStats(ch.Stats, tikvrpc.CmdResolveLock, time.Since(start))
|
||||||
|
}(time.Now())
|
||||||
|
}
|
||||||
|
opts.ForRead = true
|
||||||
|
opts.Lite = ch.resolveLite
|
||||||
|
res, err := ch.lockResolver.ResolveLocksWithOpts(bo, opts)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
if len(res.IgnoreLocks) > 0 {
|
||||||
|
ch.resolvedLocks.Put(res.IgnoreLocks...)
|
||||||
|
}
|
||||||
|
if len(res.AccessLocks) > 0 {
|
||||||
|
ch.committedLocks.Put(res.AccessLocks...)
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ResolveLocks wraps the ResolveLocks function and store the resolved result.
|
// ResolveLocks wraps the ResolveLocks function and store the resolved result.
|
||||||
func (ch *ClientHelper) ResolveLocks(bo *retry.Backoffer, callerStartTS uint64, locks []*txnlock.Lock) (int64, error) {
|
func (ch *ClientHelper) ResolveLocks(bo *retry.Backoffer, callerStartTS uint64, locks []*txnlock.Lock) (int64, error) {
|
||||||
if ch.Stats != nil {
|
if ch.Stats != nil {
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,7 @@ func (s *Scanner) getData(bo *retry.Backoffer) error {
|
||||||
NotFillCache: s.snapshot.notFillCache,
|
NotFillCache: s.snapshot.notFillCache,
|
||||||
IsolationLevel: s.snapshot.isolationLevel.ToPB(),
|
IsolationLevel: s.snapshot.isolationLevel.ToPB(),
|
||||||
ResourceGroupTag: s.snapshot.mu.resourceGroupTag,
|
ResourceGroupTag: s.snapshot.mu.resourceGroupTag,
|
||||||
|
RequestSource: s.snapshot.GetRequestSource(),
|
||||||
},
|
},
|
||||||
StartKey: s.nextStartKey,
|
StartKey: s.nextStartKey,
|
||||||
EndKey: reqEndKey,
|
EndKey: reqEndKey,
|
||||||
|
|
@ -250,6 +251,7 @@ func (s *Scanner) getData(bo *retry.Backoffer) error {
|
||||||
TaskId: s.snapshot.mu.taskID,
|
TaskId: s.snapshot.mu.taskID,
|
||||||
ResourceGroupTag: s.snapshot.mu.resourceGroupTag,
|
ResourceGroupTag: s.snapshot.mu.resourceGroupTag,
|
||||||
IsolationLevel: s.snapshot.isolationLevel.ToPB(),
|
IsolationLevel: s.snapshot.isolationLevel.ToPB(),
|
||||||
|
RequestSource: s.snapshot.GetRequestSource(),
|
||||||
})
|
})
|
||||||
if s.snapshot.mu.resourceGroupTag == nil && s.snapshot.mu.resourceGroupTagger != nil {
|
if s.snapshot.mu.resourceGroupTag == nil && s.snapshot.mu.resourceGroupTagger != nil {
|
||||||
s.snapshot.mu.resourceGroupTagger(req)
|
s.snapshot.mu.resourceGroupTagger(req)
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@ type KVSnapshot struct {
|
||||||
interceptor interceptor.RPCInterceptor
|
interceptor interceptor.RPCInterceptor
|
||||||
}
|
}
|
||||||
sampleStep uint32
|
sampleStep uint32
|
||||||
|
*util.RequestSource
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTiKVSnapshot creates a snapshot of an TiKV store.
|
// NewTiKVSnapshot creates a snapshot of an TiKV store.
|
||||||
|
|
@ -157,6 +158,7 @@ func NewTiKVSnapshot(store kvstore, ts uint64, replicaReadSeed uint32) *KVSnapsh
|
||||||
priority: txnutil.PriorityNormal,
|
priority: txnutil.PriorityNormal,
|
||||||
vars: kv.DefaultVars,
|
vars: kv.DefaultVars,
|
||||||
replicaReadSeed: replicaReadSeed,
|
replicaReadSeed: replicaReadSeed,
|
||||||
|
RequestSource: &util.RequestSource{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,6 +208,9 @@ func (s *KVSnapshot) BatchGet(ctx context.Context, keys [][]byte) (map[string][]
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = context.WithValue(ctx, retry.TxnStartKey, s.version)
|
ctx = context.WithValue(ctx, retry.TxnStartKey, s.version)
|
||||||
|
if ctx.Value(util.RequestSourceKey) == nil {
|
||||||
|
ctx = context.WithValue(ctx, util.RequestSourceKey, *s.RequestSource)
|
||||||
|
}
|
||||||
bo := retry.NewBackofferWithVars(ctx, batchGetMaxBackoff, s.vars)
|
bo := retry.NewBackofferWithVars(ctx, batchGetMaxBackoff, s.vars)
|
||||||
s.mu.RLock()
|
s.mu.RLock()
|
||||||
if s.mu.interceptor != nil {
|
if s.mu.interceptor != nil {
|
||||||
|
|
@ -368,6 +373,7 @@ func (s *KVSnapshot) batchGetSingleRegion(bo *retry.Backoffer, batch batchKeys,
|
||||||
TaskId: s.mu.taskID,
|
TaskId: s.mu.taskID,
|
||||||
ResourceGroupTag: s.mu.resourceGroupTag,
|
ResourceGroupTag: s.mu.resourceGroupTag,
|
||||||
IsolationLevel: s.isolationLevel.ToPB(),
|
IsolationLevel: s.isolationLevel.ToPB(),
|
||||||
|
RequestSource: s.GetRequestSource(),
|
||||||
})
|
})
|
||||||
if s.mu.resourceGroupTag == nil && s.mu.resourceGroupTagger != nil {
|
if s.mu.resourceGroupTag == nil && s.mu.resourceGroupTagger != nil {
|
||||||
s.mu.resourceGroupTagger(req)
|
s.mu.resourceGroupTagger(req)
|
||||||
|
|
@ -458,7 +464,13 @@ func (s *KVSnapshot) batchGetSingleRegion(bo *retry.Backoffer, batch batchKeys,
|
||||||
} else {
|
} else {
|
||||||
cli.UpdateResolvingLocks(locks, s.version, *resolvingRecordToken)
|
cli.UpdateResolvingLocks(locks, s.version, *resolvingRecordToken)
|
||||||
}
|
}
|
||||||
msBeforeExpired, err := cli.ResolveLocks(bo, s.version, locks)
|
resolveLocksOpts := txnlock.ResolveLocksOptions{
|
||||||
|
CallerStartTS: s.version,
|
||||||
|
Locks: locks,
|
||||||
|
Detail: s.getResolveLockDetail(),
|
||||||
|
}
|
||||||
|
resolveLocksRes, err := cli.ResolveLocksWithOpts(bo, resolveLocksOpts)
|
||||||
|
msBeforeExpired := resolveLocksRes.TTL
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -488,6 +500,9 @@ func (s *KVSnapshot) Get(ctx context.Context, k []byte) ([]byte, error) {
|
||||||
}(time.Now())
|
}(time.Now())
|
||||||
|
|
||||||
ctx = context.WithValue(ctx, retry.TxnStartKey, s.version)
|
ctx = context.WithValue(ctx, retry.TxnStartKey, s.version)
|
||||||
|
if ctx.Value(util.RequestSourceKey) == nil {
|
||||||
|
ctx = context.WithValue(ctx, util.RequestSourceKey, *s.RequestSource)
|
||||||
|
}
|
||||||
bo := retry.NewBackofferWithVars(ctx, getMaxBackoff, s.vars)
|
bo := retry.NewBackofferWithVars(ctx, getMaxBackoff, s.vars)
|
||||||
s.mu.RLock()
|
s.mu.RLock()
|
||||||
if s.mu.interceptor != nil {
|
if s.mu.interceptor != nil {
|
||||||
|
|
@ -523,7 +538,6 @@ func (s *KVSnapshot) get(ctx context.Context, bo *retry.Backoffer, k []byte) ([]
|
||||||
return value, nil
|
return value, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.mu.RUnlock()
|
|
||||||
if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil {
|
if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil {
|
||||||
span1 := span.Tracer().StartSpan("tikvSnapshot.get", opentracing.ChildOf(span.Context()))
|
span1 := span.Tracer().StartSpan("tikvSnapshot.get", opentracing.ChildOf(span.Context()))
|
||||||
defer span1.Finish()
|
defer span1.Finish()
|
||||||
|
|
@ -531,13 +545,13 @@ func (s *KVSnapshot) get(ctx context.Context, bo *retry.Backoffer, k []byte) ([]
|
||||||
}
|
}
|
||||||
if _, err := util.EvalFailpoint("snapshot-get-cache-fail"); err == nil {
|
if _, err := util.EvalFailpoint("snapshot-get-cache-fail"); err == nil {
|
||||||
if bo.GetCtx().Value("TestSnapshotCache") != nil {
|
if bo.GetCtx().Value("TestSnapshotCache") != nil {
|
||||||
|
s.mu.RUnlock()
|
||||||
panic("cache miss")
|
panic("cache miss")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cli := NewClientHelper(s.store, &s.resolvedLocks, &s.committedLocks, true)
|
cli := NewClientHelper(s.store, &s.resolvedLocks, &s.committedLocks, true)
|
||||||
|
|
||||||
s.mu.RLock()
|
|
||||||
if s.mu.stats != nil {
|
if s.mu.stats != nil {
|
||||||
cli.Stats = make(map[tikvrpc.CmdType]*locate.RPCRuntimeStats)
|
cli.Stats = make(map[tikvrpc.CmdType]*locate.RPCRuntimeStats)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
@ -554,6 +568,7 @@ func (s *KVSnapshot) get(ctx context.Context, bo *retry.Backoffer, k []byte) ([]
|
||||||
TaskId: s.mu.taskID,
|
TaskId: s.mu.taskID,
|
||||||
ResourceGroupTag: s.mu.resourceGroupTag,
|
ResourceGroupTag: s.mu.resourceGroupTag,
|
||||||
IsolationLevel: s.isolationLevel.ToPB(),
|
IsolationLevel: s.isolationLevel.ToPB(),
|
||||||
|
RequestSource: s.GetRequestSource(),
|
||||||
})
|
})
|
||||||
if s.mu.resourceGroupTag == nil && s.mu.resourceGroupTagger != nil {
|
if s.mu.resourceGroupTag == nil && s.mu.resourceGroupTagger != nil {
|
||||||
s.mu.resourceGroupTagger(req)
|
s.mu.resourceGroupTagger(req)
|
||||||
|
|
@ -634,10 +649,16 @@ func (s *KVSnapshot) get(ctx context.Context, bo *retry.Backoffer, k []byte) ([]
|
||||||
} else {
|
} else {
|
||||||
cli.UpdateResolvingLocks(locks, s.version, *resolvingRecordToken)
|
cli.UpdateResolvingLocks(locks, s.version, *resolvingRecordToken)
|
||||||
}
|
}
|
||||||
msBeforeExpired, err := cli.ResolveLocks(bo, s.version, locks)
|
resolveLocksOpts := txnlock.ResolveLocksOptions{
|
||||||
|
CallerStartTS: s.version,
|
||||||
|
Locks: locks,
|
||||||
|
Detail: s.getResolveLockDetail(),
|
||||||
|
}
|
||||||
|
resolveLocksRes, err := cli.ResolveLocksWithOpts(bo, resolveLocksOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
msBeforeExpired := resolveLocksRes.TTL
|
||||||
if msBeforeExpired > 0 {
|
if msBeforeExpired > 0 {
|
||||||
err = bo.BackoffWithMaxSleepTxnLockFast(int(msBeforeExpired), errors.New(keyErr.String()))
|
err = bo.BackoffWithMaxSleepTxnLockFast(int(msBeforeExpired), errors.New(keyErr.String()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -656,8 +677,13 @@ func (s *KVSnapshot) mergeExecDetail(detail *kvrpcpb.ExecDetailsV2) {
|
||||||
if detail == nil || s.mu.stats == nil {
|
if detail == nil || s.mu.stats == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if s.mu.stats.resolveLockDetail == nil {
|
||||||
|
s.mu.stats.resolveLockDetail = &util.ResolveLockDetail{}
|
||||||
|
}
|
||||||
if s.mu.stats.scanDetail == nil {
|
if s.mu.stats.scanDetail == nil {
|
||||||
s.mu.stats.scanDetail = &util.ScanDetail{}
|
s.mu.stats.scanDetail = &util.ScanDetail{
|
||||||
|
ResolveLock: s.mu.stats.resolveLockDetail,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if s.mu.stats.timeDetail == nil {
|
if s.mu.stats.timeDetail == nil {
|
||||||
s.mu.stats.timeDetail = &util.TimeDetail{}
|
s.mu.stats.timeDetail = &util.TimeDetail{}
|
||||||
|
|
@ -859,6 +885,15 @@ func (s *KVSnapshot) mergeRegionRequestStats(stats map[tikvrpc.CmdType]*locate.R
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *KVSnapshot) getResolveLockDetail() *util.ResolveLockDetail {
|
||||||
|
s.mu.RLock()
|
||||||
|
defer s.mu.RUnlock()
|
||||||
|
if s.mu.stats == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return s.mu.stats.resolveLockDetail
|
||||||
|
}
|
||||||
|
|
||||||
// SnapshotRuntimeStats records the runtime stats of snapshot.
|
// SnapshotRuntimeStats records the runtime stats of snapshot.
|
||||||
type SnapshotRuntimeStats struct {
|
type SnapshotRuntimeStats struct {
|
||||||
rpcStats locate.RegionRequestRuntimeStats
|
rpcStats locate.RegionRequestRuntimeStats
|
||||||
|
|
@ -866,6 +901,7 @@ type SnapshotRuntimeStats struct {
|
||||||
backoffTimes map[string]int
|
backoffTimes map[string]int
|
||||||
scanDetail *util.ScanDetail
|
scanDetail *util.ScanDetail
|
||||||
timeDetail *util.TimeDetail
|
timeDetail *util.TimeDetail
|
||||||
|
resolveLockDetail *util.ResolveLockDetail
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone implements the RuntimeStats interface.
|
// Clone implements the RuntimeStats interface.
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,11 @@ type CommitDetails struct {
|
||||||
CommitBackoffTime int64
|
CommitBackoffTime int64
|
||||||
BackoffTypes []string
|
BackoffTypes []string
|
||||||
}
|
}
|
||||||
ResolveLockTime int64
|
|
||||||
WriteKeys int
|
WriteKeys int
|
||||||
WriteSize int
|
WriteSize int
|
||||||
PrewriteRegionNum int32
|
PrewriteRegionNum int32
|
||||||
TxnRetry int
|
TxnRetry int
|
||||||
|
ResolveLock ResolveLockDetail
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge merges commit details into itself.
|
// Merge merges commit details into itself.
|
||||||
|
|
@ -86,7 +86,7 @@ func (cd *CommitDetails) Merge(other *CommitDetails) {
|
||||||
cd.WaitPrewriteBinlogTime += other.WaitPrewriteBinlogTime
|
cd.WaitPrewriteBinlogTime += other.WaitPrewriteBinlogTime
|
||||||
cd.CommitTime += other.CommitTime
|
cd.CommitTime += other.CommitTime
|
||||||
cd.LocalLatchTime += other.LocalLatchTime
|
cd.LocalLatchTime += other.LocalLatchTime
|
||||||
cd.ResolveLockTime += other.ResolveLockTime
|
cd.ResolveLock.ResolveLockTime += other.ResolveLock.ResolveLockTime
|
||||||
cd.WriteKeys += other.WriteKeys
|
cd.WriteKeys += other.WriteKeys
|
||||||
cd.WriteSize += other.WriteSize
|
cd.WriteSize += other.WriteSize
|
||||||
cd.PrewriteRegionNum += other.PrewriteRegionNum
|
cd.PrewriteRegionNum += other.PrewriteRegionNum
|
||||||
|
|
@ -103,11 +103,11 @@ func (cd *CommitDetails) Clone() *CommitDetails {
|
||||||
WaitPrewriteBinlogTime: cd.WaitPrewriteBinlogTime,
|
WaitPrewriteBinlogTime: cd.WaitPrewriteBinlogTime,
|
||||||
CommitTime: cd.CommitTime,
|
CommitTime: cd.CommitTime,
|
||||||
LocalLatchTime: cd.LocalLatchTime,
|
LocalLatchTime: cd.LocalLatchTime,
|
||||||
ResolveLockTime: cd.ResolveLockTime,
|
|
||||||
WriteKeys: cd.WriteKeys,
|
WriteKeys: cd.WriteKeys,
|
||||||
WriteSize: cd.WriteSize,
|
WriteSize: cd.WriteSize,
|
||||||
PrewriteRegionNum: cd.PrewriteRegionNum,
|
PrewriteRegionNum: cd.PrewriteRegionNum,
|
||||||
TxnRetry: cd.TxnRetry,
|
TxnRetry: cd.TxnRetry,
|
||||||
|
ResolveLock: cd.ResolveLock,
|
||||||
}
|
}
|
||||||
commit.Mu.BackoffTypes = append([]string{}, cd.Mu.BackoffTypes...)
|
commit.Mu.BackoffTypes = append([]string{}, cd.Mu.BackoffTypes...)
|
||||||
commit.Mu.CommitBackoffTime = cd.Mu.CommitBackoffTime
|
commit.Mu.CommitBackoffTime = cd.Mu.CommitBackoffTime
|
||||||
|
|
@ -119,7 +119,7 @@ type LockKeysDetails struct {
|
||||||
TotalTime time.Duration
|
TotalTime time.Duration
|
||||||
RegionNum int32
|
RegionNum int32
|
||||||
LockKeys int32
|
LockKeys int32
|
||||||
ResolveLockTime int64
|
ResolveLock ResolveLockDetail
|
||||||
BackoffTime int64
|
BackoffTime int64
|
||||||
Mu struct {
|
Mu struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
|
@ -135,7 +135,7 @@ func (ld *LockKeysDetails) Merge(lockKey *LockKeysDetails) {
|
||||||
ld.TotalTime += lockKey.TotalTime
|
ld.TotalTime += lockKey.TotalTime
|
||||||
ld.RegionNum += lockKey.RegionNum
|
ld.RegionNum += lockKey.RegionNum
|
||||||
ld.LockKeys += lockKey.LockKeys
|
ld.LockKeys += lockKey.LockKeys
|
||||||
ld.ResolveLockTime += lockKey.ResolveLockTime
|
ld.ResolveLock.ResolveLockTime += lockKey.ResolveLock.ResolveLockTime
|
||||||
ld.BackoffTime += lockKey.BackoffTime
|
ld.BackoffTime += lockKey.BackoffTime
|
||||||
ld.LockRPCTime += lockKey.LockRPCTime
|
ld.LockRPCTime += lockKey.LockRPCTime
|
||||||
ld.LockRPCCount += ld.LockRPCCount
|
ld.LockRPCCount += ld.LockRPCCount
|
||||||
|
|
@ -149,11 +149,11 @@ func (ld *LockKeysDetails) Clone() *LockKeysDetails {
|
||||||
TotalTime: ld.TotalTime,
|
TotalTime: ld.TotalTime,
|
||||||
RegionNum: ld.RegionNum,
|
RegionNum: ld.RegionNum,
|
||||||
LockKeys: ld.LockKeys,
|
LockKeys: ld.LockKeys,
|
||||||
ResolveLockTime: ld.ResolveLockTime,
|
|
||||||
BackoffTime: ld.BackoffTime,
|
BackoffTime: ld.BackoffTime,
|
||||||
LockRPCTime: ld.LockRPCTime,
|
LockRPCTime: ld.LockRPCTime,
|
||||||
LockRPCCount: ld.LockRPCCount,
|
LockRPCCount: ld.LockRPCCount,
|
||||||
RetryCount: ld.RetryCount,
|
RetryCount: ld.RetryCount,
|
||||||
|
ResolveLock: ld.ResolveLock,
|
||||||
}
|
}
|
||||||
lock.Mu.BackoffTypes = append([]string{}, ld.Mu.BackoffTypes...)
|
lock.Mu.BackoffTypes = append([]string{}, ld.Mu.BackoffTypes...)
|
||||||
return lock
|
return lock
|
||||||
|
|
@ -228,6 +228,7 @@ type ScanDetail struct {
|
||||||
RocksdbBlockReadCount uint64
|
RocksdbBlockReadCount uint64
|
||||||
// RocksdbBlockReadByte is the total number of bytes from block reads.
|
// RocksdbBlockReadByte is the total number of bytes from block reads.
|
||||||
RocksdbBlockReadByte uint64
|
RocksdbBlockReadByte uint64
|
||||||
|
ResolveLock *ResolveLockDetail
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge merges scan detail execution details into self.
|
// Merge merges scan detail execution details into self.
|
||||||
|
|
@ -330,3 +331,15 @@ func (td *TimeDetail) MergeFromTimeDetail(timeDetail *kvrpcpb.TimeDetail) {
|
||||||
td.KvReadWallTimeMs += time.Duration(timeDetail.KvReadWallTimeMs) * time.Millisecond
|
td.KvReadWallTimeMs += time.Duration(timeDetail.KvReadWallTimeMs) * time.Millisecond
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResolveLockDetail contains the resolve lock detail information.
|
||||||
|
type ResolveLockDetail struct {
|
||||||
|
// ResolveLockTime is the total duration of resolving lock.
|
||||||
|
ResolveLockTime int64
|
||||||
|
// TODO(you06): add more details of resolving locks.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge merges resolve lock detail details into self.
|
||||||
|
func (rd *ResolveLockDetail) Merge(resolveLock *ResolveLockDetail) {
|
||||||
|
rd.ResolveLockTime += resolveLock.ResolveLockTime
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RequestSourceTypeKeyType is a dummy type to avoid naming collision in context.
|
||||||
|
type RequestSourceTypeKeyType struct{}
|
||||||
|
|
||||||
|
// RequestSourceTypeKey is used as the key of request source type in context.
|
||||||
|
var RequestSourceTypeKey = RequestSourceTypeKeyType{}
|
||||||
|
|
||||||
|
// RequestSourceKeyType is a dummy type to avoid naming collision in context.
|
||||||
|
type RequestSourceKeyType struct{}
|
||||||
|
|
||||||
|
// RequestSourceKey is used as the key of request source type in context.
|
||||||
|
var RequestSourceKey = RequestSourceKeyType{}
|
||||||
|
|
||||||
|
const (
|
||||||
|
// InternalTxnOthers is the type of requests that consume low resources.
|
||||||
|
// This reduces the size of metrics.
|
||||||
|
InternalTxnOthers = "others"
|
||||||
|
// InternalTxnGC is the type of GC txn.
|
||||||
|
InternalTxnGC = "gc"
|
||||||
|
// InternalTxnMeta is the type of the miscellaneous meta usage.
|
||||||
|
InternalTxnMeta = InternalTxnOthers
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// InternalRequest is the scope of internal queries
|
||||||
|
InternalRequest = "internal_"
|
||||||
|
// ExternalRequest is the scope of external queries
|
||||||
|
ExternalRequest = "external_"
|
||||||
|
// SourceUnknown keeps same with the default value(empty string)
|
||||||
|
SourceUnknown = "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RequestSource contains the source label of the request, used for tracking resource consuming.
|
||||||
|
type RequestSource struct {
|
||||||
|
RequestSourceInternal bool
|
||||||
|
RequestSourceType string
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRequestSourceInternal sets the scope of the request source.
|
||||||
|
func (r *RequestSource) SetRequestSourceInternal(internal bool) {
|
||||||
|
r.RequestSourceInternal = internal
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRequestSourceType sets the type of the request source.
|
||||||
|
func (r *RequestSource) SetRequestSourceType(tp string) {
|
||||||
|
r.RequestSourceType = tp
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithInternalSourceType create context with internal source.
|
||||||
|
func WithInternalSourceType(ctx context.Context, source string) context.Context {
|
||||||
|
return context.WithValue(ctx, RequestSourceKey, RequestSource{
|
||||||
|
RequestSourceInternal: true,
|
||||||
|
RequestSourceType: source,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRequestSource gets the request_source field of the request.
|
||||||
|
func (r *RequestSource) GetRequestSource() string {
|
||||||
|
// if r.RequestSourceType is not set, it's mostly possible that r.RequestSourceInternal is not set
|
||||||
|
// to avoid internal requests be marked as external(default value), return unknown source here.
|
||||||
|
if r == nil || r.RequestSourceType == "" {
|
||||||
|
return SourceUnknown
|
||||||
|
}
|
||||||
|
if r.RequestSourceInternal {
|
||||||
|
return InternalRequest + r.RequestSourceType
|
||||||
|
}
|
||||||
|
return ExternalRequest + r.RequestSourceType
|
||||||
|
}
|
||||||
|
|
||||||
|
// RequestSourceFromCtx extract source from passed context.
|
||||||
|
func RequestSourceFromCtx(ctx context.Context) string {
|
||||||
|
if source := ctx.Value(RequestSourceKey); source != nil {
|
||||||
|
rs := source.(RequestSource)
|
||||||
|
return rs.GetRequestSource()
|
||||||
|
}
|
||||||
|
return SourceUnknown
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue