Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e4503f1
Add API V3 keyspace identity support
disksing Jun 18, 2026
2645eb0
Wire API V3 identity into PD client
disksing Jun 18, 2026
a6ab003
Update PD client API V3 dependency
disksing Jun 18, 2026
b0bcaa7
Support API V3 keyspace oneof context
disksing Jun 18, 2026
b2a2d30
Disable router lookup for API V3 region cache
disksing Jun 18, 2026
519ae61
Disable PD router client for API V3 keyspace
disksing Jun 18, 2026
0137975
Merge remote-tracking branch 'origin/master' into task22.3/client-go-…
disksing Jun 30, 2026
64b22d9
Update APIV3 pd and kvproto dependencies
disksing Jun 30, 2026
3e25ac7
Encode API V3 RPC keys with physical prefix
disksing Jun 30, 2026
d7c5390
Revert "Encode API V3 RPC keys with physical prefix"
disksing Jun 30, 2026
9b0c9a7
Merge remote-tracking branch 'origin/master' into task22.3/client-go-…
Jul 8, 2026
8a3e407
Update APIV3 PD and kvproto dependencies
Jul 8, 2026
c99d77c
Encode API V3 RPC keys with physical prefix
Jul 8, 2026
08e7e80
apicodec: avoid double encoding API V3 physical keys
Jul 8, 2026
f310eb8
apicodec: keep API V3 RPC keys logical
Jul 8, 2026
4a85e90
apicodec: keep API V3 region keys logical
Jul 8, 2026
00b316e
apicodec: bound API V3 region scans to keyspace
Jul 8, 2026
875a685
apicodec: fix API V3 physical keyspace prefix
Jul 8, 2026
73ea742
apicodec: clamp API V3 bucket keys to keyspace
Jul 8, 2026
b953d6b
Merge remote-tracking branch 'origin/master' into apiv3
disksing Jul 15, 2026
f9223b8
Update APIV3 PD client dependency
disksing Jul 15, 2026
0bce5be
*: update kvproto oneof dependencies
disksing Jul 20, 2026
21361f2
*: update kvproto to latest apiv3
disksing Jul 22, 2026
fa37e52
*: use kvproto master baseline
disksing Jul 29, 2026
44993e3
Merge master into apiv3
disksing Jul 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/gcworker/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pingcap/errors v0.11.5-0.20241219054535-6b8c588c3122 // indirect
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368 // indirect
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472 // indirect
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
Expand All @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3 // indirect
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
4 changes: 2 additions & 2 deletions examples/rawkv/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pingcap/errors v0.11.5-0.20241219054535-6b8c588c3122 // indirect
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368 // indirect
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472 // indirect
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
Expand All @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3 // indirect
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
4 changes: 2 additions & 2 deletions examples/txnkv/1pc_txn/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pingcap/errors v0.11.5-0.20241219054535-6b8c588c3122 // indirect
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368 // indirect
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472 // indirect
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
Expand All @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3 // indirect
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
4 changes: 2 additions & 2 deletions examples/txnkv/async_commit/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pingcap/errors v0.11.5-0.20241219054535-6b8c588c3122 // indirect
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368 // indirect
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472 // indirect
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
Expand All @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3 // indirect
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
4 changes: 2 additions & 2 deletions examples/txnkv/delete_range/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pingcap/errors v0.11.5-0.20241219054535-6b8c588c3122 // indirect
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368 // indirect
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472 // indirect
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
Expand All @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3 // indirect
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
4 changes: 2 additions & 2 deletions examples/txnkv/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module txnkv
go 1.25.10

require (
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472
github.com/tikv/client-go/v2 v2.0.0
)

Expand Down Expand Up @@ -33,7 +33,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3 // indirect
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
4 changes: 2 additions & 2 deletions examples/txnkv/pessimistic_txn/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pingcap/errors v0.11.5-0.20241219054535-6b8c588c3122 // indirect
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368 // indirect
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472 // indirect
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
Expand All @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3 // indirect
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
4 changes: 2 additions & 2 deletions examples/txnkv/unsafedestoryrange/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pingcap/errors v0.11.5-0.20241219054535-6b8c588c3122 // indirect
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368 // indirect
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472 // indirect
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
Expand All @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3 // indirect
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ require (
github.com/pingcap/errors v0.11.5-0.20241219054535-6b8c588c3122
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/client_model v0.6.1
github.com/stretchr/testify v1.9.0
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f
github.com/twmb/murmur3 v1.1.3
go.etcd.io/etcd/api/v3 v3.5.10
go.etcd.io/etcd/client/v3 v3.5.10
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 h1:tdMsjOqUR7YXH
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86/go.mod h1:exzhVYca3WRtd6gclGNErRWb1qEgff3LYta0LvRmON4=
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368 h1:qW0gHsqY3X3qmyiEfESqpYSF3Vu7agUiAyBnPWQXtm8=
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472 h1:JBrbgynAz4RkeXUvqXAOhySZK5FYFCeHdKWUrj+Z2Vw=
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8IDP+SZrdhV1Kibl9KrHxJ9eciw=
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -115,8 +115,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a h1:J/YdBZ46WKpXsxsW93SG+q0F8KI+yFrcIDT4c/RNoc4=
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a/go.mod h1:h4xBhSNtOeEosLJ4P7JyKXX7Cabg7AVkWCK5gV2vOrM=
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3 h1:OoBvgoeWmdNEXtS+eOlhysz/OvhA4GS0OdPVhTXteGA=
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3/go.mod h1:3/Bu91CJONgkDA+Y0v/cnbROSJnu5tQ09vv7JGybUBA=
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f h1:IYHVxTMV8oXlL4ZaoGDvREUZlszfyA0w3fUK9g2wSlM=
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f/go.mod h1:Xhd/CPuOv+tgP+5LKhWS23tklCXszF0EgKo4R6OZGj0=
github.com/twmb/murmur3 v1.1.3 h1:D83U0XYKcHRYwYIpBKf3Pks91Z0Byda/9SJ8B6EMRcA=
github.com/twmb/murmur3 v1.1.3/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (s *testGCWithTiKVSuite) dropKeyspace(keyspaceMeta *keyspacepb.KeyspaceMeta
re := s.Require()
// Nil might be used to represent the null keyspace.
if keyspaceMeta != nil {
_, err := s.globalPDCli.UpdateKeyspaceState(context.Background(), keyspaceMeta.Id, keyspacepb.KeyspaceState_ARCHIVED)
_, err := s.globalPDCli.UpdateKeyspaceState(context.Background(), keyspaceMeta.GetId(), keyspacepb.KeyspaceState_ARCHIVED)
re.NoError(err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ require (
github.com/ninedraft/israce v0.0.3
github.com/pingcap/errors v0.11.5-0.20260508054701-306e305bcf41
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472
github.com/pingcap/tidb v1.1.0-beta.0.20260715060322-10292a4f8697
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.23.0
github.com/prometheus/client_model v0.6.2
github.com/stretchr/testify v1.11.1
github.com/tidwall/gjson v1.14.4
github.com/tikv/client-go/v2 v2.0.8-0.20260708122311-01bd8f99f4da
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f
go.uber.org/goleak v1.3.0
google.golang.org/grpc v1.79.3
)
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1452,8 +1452,8 @@ github.com/pingcap/fn v1.0.0/go.mod h1:u9WZ1ZiOD1RpNhcI42RucFh/lBuzTu6rw88a+oF2Z
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
github.com/pingcap/kvproto v0.0.0-20241113043844-e1fa7ea8c302/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368 h1:qW0gHsqY3X3qmyiEfESqpYSF3Vu7agUiAyBnPWQXtm8=
github.com/pingcap/kvproto v0.0.0-20260721064811-683dad8fa368/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472 h1:JBrbgynAz4RkeXUvqXAOhySZK5FYFCeHdKWUrj+Z2Vw=
github.com/pingcap/kvproto v0.0.0-20260724054804-059694ae4472/go.mod h1:z6+aAHB7dBkA+LyinEX+48/ImRJ3jag0Hg0c7wkhEvE=
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
github.com/pingcap/log v1.1.1-0.20250917021125-19901e015dc9 h1:qG9BSvlWFEE5otQGamuWedx9LRm0nrHvsQRQiW8SxEs=
Expand Down Expand Up @@ -1598,8 +1598,8 @@ github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3 h1:OoBvgoeWmdNEXtS+eOlhysz/OvhA4GS0OdPVhTXteGA=
github.com/tikv/pd/client v0.0.0-20260708075407-4e05b9d2c2d3/go.mod h1:3/Bu91CJONgkDA+Y0v/cnbROSJnu5tQ09vv7JGybUBA=
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f h1:IYHVxTMV8oXlL4ZaoGDvREUZlszfyA0w3fUK9g2wSlM=
github.com/tikv/pd/client v0.0.0-20260729061341-533858f82c9f/go.mod h1:Xhd/CPuOv+tgP+5LKhWS23tklCXszF0EgKo4R6OZGj0=
github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
Expand Down
35 changes: 32 additions & 3 deletions internal/apicodec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/keyspacepb"
"github.com/pingcap/kvproto/pkg/kvrpcpb"
"github.com/pingcap/kvproto/pkg/mpp"
"github.com/tikv/client-go/v2/tikvrpc"
"github.com/tikv/pd/client/constants"
)
Expand Down Expand Up @@ -107,32 +108,60 @@ func DecodeKey(encoded []byte, version kvrpcpb.APIVersion) ([]byte, []byte, erro
return nil, nil, err
}
return encoded[:keyspacePrefixLen], encoded[keyspacePrefixLen:], nil
case kvrpcpb.APIVersion_V3:
err := checkV3Key(encoded)
if err != nil {
return nil, nil, err
}
return encoded[:apiV3KeyspacePrefixLen], encoded[apiV3KeyspacePrefixLen:], nil
}
return nil, nil, errors.Errorf("unsupported api version %s", version.String())
}

func setAPICtx(c Codec, r *tikvrpc.Request) {
r.ApiVersion = c.GetAPIVersion()
r.KeyspaceId = uint32(c.GetKeyspaceID())
keyspaceMeta := c.GetKeyspaceMeta()
if keyspaceMeta != nil {
r.KeyspaceName = keyspaceMeta.Name
if identity := keyspaceMeta.GetKeyspaceIdentity(); identity != nil {
r.Keyspace = &kvrpcpb.Context_KeyspaceIdentity{KeyspaceIdentity: identity}
} else {
r.Keyspace = &kvrpcpb.Context_KeyspaceId{KeyspaceId: uint32(c.GetKeyspaceID())}
}
} else {
r.Keyspace = &kvrpcpb.Context_KeyspaceId{KeyspaceId: uint32(c.GetKeyspaceID())}
}

switch r.Type {
case tikvrpc.CmdMPPTask:
mpp := *r.DispatchMPPTask()
// Shallow copy the meta to avoid concurrent modification.
meta := *mpp.Meta
meta.KeyspaceId = r.KeyspaceId
meta.ApiVersion = r.ApiVersion
setMPPKeyspace(&meta, r)
mpp.Meta = &meta
r.Req = &mpp

case tikvrpc.CmdCompact:
compact := *r.Compact()
compact.KeyspaceId = r.KeyspaceId
compact.ApiVersion = r.ApiVersion
setCompactKeyspace(&compact, r)
r.Req = &compact
}
}

func setMPPKeyspace(meta *mpp.TaskMeta, r *tikvrpc.Request) {
if identity := r.GetKeyspaceIdentity(); identity != nil {
meta.Keyspace = &mpp.TaskMeta_KeyspaceIdentity{KeyspaceIdentity: identity}
return
}
meta.Keyspace = &mpp.TaskMeta_KeyspaceId{KeyspaceId: r.GetKeyspaceId()}
}

func setCompactKeyspace(compact *kvrpcpb.CompactRequest, r *tikvrpc.Request) {
if identity := r.GetKeyspaceIdentity(); identity != nil {
compact.Keyspace = &kvrpcpb.CompactRequest_KeyspaceIdentity{KeyspaceIdentity: identity}
return
}
compact.Keyspace = &kvrpcpb.CompactRequest_KeyspaceId{KeyspaceId: r.GetKeyspaceId()}
}
15 changes: 15 additions & 0 deletions internal/apicodec/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ func TestDecodeKey(t *testing.T) {
assert.NotNil(t, err)
assert.Empty(t, pfx)
assert.Empty(t, key)

pfx, key, err = DecodeKey([]byte{'x', 1, 2, 3, 4, 5, 6, 7, 8, 9}, kvrpcpb.APIVersion_V3)
assert.Nil(t, err)
assert.Equal(t, []byte{'x', 1, 2, 3}, pfx)
assert.Equal(t, []byte{4, 5, 6, 7, 8, 9}, key)

pfx, key, err = DecodeKey([]byte{'x', 1, 2, 3}, kvrpcpb.APIVersion_V3)
assert.Nil(t, err)
assert.Equal(t, []byte{'x', 1, 2, 3}, pfx)
assert.Empty(t, key)

pfx, key, err = DecodeKey([]byte{'x', 1, 2}, kvrpcpb.APIVersion_V3)
assert.NotNil(t, err)
assert.Empty(t, pfx)
assert.Empty(t, key)
}

func TestEncodeUnknownRequest(t *testing.T) {
Expand Down
Loading
Loading