mirror of https://github.com/tikv/client-go.git
attach keyspace_id for manual compact request (#737)
This commit is contained in:
parent
f555fdd2c9
commit
eb0bd61645
2
go.mod
2
go.mod
|
|
@ -14,7 +14,7 @@ require (
|
||||||
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-20220801062533-2eaa32854a6c
|
github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c
|
||||||
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-20230228041042-1e9aca94bab6
|
github.com/pingcap/kvproto v0.0.0-20230312142449-01623096c924
|
||||||
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3
|
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/prometheus/client_golang v1.14.0
|
github.com/prometheus/client_golang v1.14.0
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -147,8 +147,8 @@ github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c h1:CgbKAHto5CQgW
|
||||||
github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c/go.mod h1:4qGtCB0QK0wBzKtFEGDhxXnSnbQApw1gc9siScUl8ew=
|
github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c/go.mod h1:4qGtCB0QK0wBzKtFEGDhxXnSnbQApw1gc9siScUl8ew=
|
||||||
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
|
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 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-20230228041042-1e9aca94bab6 h1:bgLRG7gPJCq6aduA65ZV7xWQBThTcuarBB9VdfAzV4g=
|
github.com/pingcap/kvproto v0.0.0-20230312142449-01623096c924 h1:z6WwBPP0Txmal5zf+H7vf/lSmKZtSS8BTNwiLjEjdnA=
|
||||||
github.com/pingcap/kvproto v0.0.0-20230228041042-1e9aca94bab6/go.mod h1:KUrW1FGoznGMMTssYBu0czfAhn6vQcIrHyZoSC6T990=
|
github.com/pingcap/kvproto v0.0.0-20230312142449-01623096c924/go.mod h1:KUrW1FGoznGMMTssYBu0czfAhn6vQcIrHyZoSC6T990=
|
||||||
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8IDP+SZrdhV1Kibl9KrHxJ9eciw=
|
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/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ require (
|
||||||
github.com/ninedraft/israce v0.0.3
|
github.com/ninedraft/israce v0.0.3
|
||||||
github.com/pingcap/errors v0.11.5-0.20221009092201-b66cddb77c32
|
github.com/pingcap/errors v0.11.5-0.20221009092201-b66cddb77c32
|
||||||
github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c
|
github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c
|
||||||
github.com/pingcap/kvproto v0.0.0-20230228041042-1e9aca94bab6
|
github.com/pingcap/kvproto v0.0.0-20230312142449-01623096c924
|
||||||
github.com/pingcap/tidb v1.1.0-beta.0.20230207083958-f1d450ff7aa4
|
github.com/pingcap/tidb v1.1.0-beta.0.20230207083958-f1d450ff7aa4
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/stretchr/testify v1.8.1
|
github.com/stretchr/testify v1.8.1
|
||||||
|
|
|
||||||
|
|
@ -338,8 +338,8 @@ github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c/go.mod h1:4qGtCB
|
||||||
github.com/pingcap/fn v0.0.0-20200306044125-d5540d389059 h1:Pe2LbxRmbTfAoKJ65bZLmhahmvHm7n9DUxGRQT00208=
|
github.com/pingcap/fn v0.0.0-20200306044125-d5540d389059 h1:Pe2LbxRmbTfAoKJ65bZLmhahmvHm7n9DUxGRQT00208=
|
||||||
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-20230228041042-1e9aca94bab6 h1:bgLRG7gPJCq6aduA65ZV7xWQBThTcuarBB9VdfAzV4g=
|
github.com/pingcap/kvproto v0.0.0-20230312142449-01623096c924 h1:z6WwBPP0Txmal5zf+H7vf/lSmKZtSS8BTNwiLjEjdnA=
|
||||||
github.com/pingcap/kvproto v0.0.0-20230228041042-1e9aca94bab6/go.mod h1:KUrW1FGoznGMMTssYBu0czfAhn6vQcIrHyZoSC6T990=
|
github.com/pingcap/kvproto v0.0.0-20230312142449-01623096c924/go.mod h1:KUrW1FGoznGMMTssYBu0czfAhn6vQcIrHyZoSC6T990=
|
||||||
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/log v1.1.1-0.20221116035753-734d527bc87c h1:crhkw6DD+07Bg1wYhW5Piw+kYNKZqFQqfC2puUf6gMI=
|
github.com/pingcap/log v1.1.1-0.20221116035753-734d527bc87c h1:crhkw6DD+07Bg1wYhW5Piw+kYNKZqFQqfC2puUf6gMI=
|
||||||
github.com/pingcap/log v1.1.1-0.20221116035753-734d527bc87c/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
github.com/pingcap/log v1.1.1-0.20221116035753-734d527bc87c/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,14 @@ func attachAPICtx(c Codec, req *tikvrpc.Request) (*tikvrpc.Request, error) {
|
||||||
mpp := *r.DispatchMPPTask()
|
mpp := *r.DispatchMPPTask()
|
||||||
mpp.Meta.KeyspaceId = ctx.KeyspaceId
|
mpp.Meta.KeyspaceId = ctx.KeyspaceId
|
||||||
r.Req = &mpp
|
r.Req = &mpp
|
||||||
|
case tikvrpc.CmdCompact:
|
||||||
|
compact := *r.Compact()
|
||||||
|
compact.KeyspaceId = ctx.KeyspaceId
|
||||||
|
compact.ApiVersion = ctx.ApiVersion
|
||||||
|
r.Req = &compact
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = tikvrpc.AttachContext(&r, ctx)
|
tikvrpc.AttachContext(&r, ctx)
|
||||||
|
|
||||||
return &r, nil
|
return &r, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -488,6 +488,18 @@ func (s *mockTikvGrpcServer) KvPrepareFlashbackToVersion(context.Context, *kvrpc
|
||||||
return nil, errors.New("unreachable")
|
return nil, errors.New("unreachable")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *mockTikvGrpcServer) EstablishDisaggTask(context.Context, *disaggregated.EstablishDisaggTaskRequest) (*disaggregated.EstablishDisaggTaskResponse, error) {
|
||||||
|
return nil, errors.New("unreachable")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *mockTikvGrpcServer) FetchDisaggPages(*disaggregated.FetchDisaggPagesRequest, tikvpb.Tikv_FetchDisaggPagesServer) error {
|
||||||
|
return errors.New("unreachable")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *mockTikvGrpcServer) TabletSnapshot(_ tikvpb.Tikv_TabletSnapshotServer) error {
|
||||||
|
return errors.New("unreachable")
|
||||||
|
}
|
||||||
|
|
||||||
func (s *testRegionRequestToSingleStoreSuite) TestNoReloadRegionForGrpcWhenCtxCanceled() {
|
func (s *testRegionRequestToSingleStoreSuite) TestNoReloadRegionForGrpcWhenCtxCanceled() {
|
||||||
// prepare a mock tikv grpc server
|
// prepare a mock tikv grpc server
|
||||||
addr := "localhost:56341"
|
addr := "localhost:56341"
|
||||||
|
|
|
||||||
|
|
@ -689,8 +689,9 @@ type MPPStreamResponse struct {
|
||||||
Lease
|
Lease
|
||||||
}
|
}
|
||||||
|
|
||||||
// AttachContext sets the request context to the request.
|
// AttachContext sets the request context to the request,
|
||||||
func AttachContext(req *Request, ctx *kvrpcpb.Context) error {
|
// return false if encounter unknown request type.
|
||||||
|
func AttachContext(req *Request, ctx *kvrpcpb.Context) bool {
|
||||||
switch req.Type {
|
switch req.Type {
|
||||||
case CmdGet:
|
case CmdGet:
|
||||||
req.Get().Context = ctx
|
req.Get().Context = ctx
|
||||||
|
|
@ -781,9 +782,9 @@ func AttachContext(req *Request, ctx *kvrpcpb.Context) error {
|
||||||
case CmdPrepareFlashbackToVersion:
|
case CmdPrepareFlashbackToVersion:
|
||||||
req.PrepareFlashbackToVersion().Context = ctx
|
req.PrepareFlashbackToVersion().Context = ctx
|
||||||
default:
|
default:
|
||||||
return errors.Errorf("invalid request type %v", req.Type)
|
return false
|
||||||
}
|
}
|
||||||
return nil
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetContext set the Context field for the given req to the specified ctx.
|
// SetContext set the Context field for the given req to the specified ctx.
|
||||||
|
|
@ -794,7 +795,10 @@ func SetContext(req *Request, region *metapb.Region, peer *metapb.Peer) error {
|
||||||
ctx.RegionEpoch = region.RegionEpoch
|
ctx.RegionEpoch = region.RegionEpoch
|
||||||
}
|
}
|
||||||
ctx.Peer = peer
|
ctx.Peer = peer
|
||||||
return AttachContext(req, ctx)
|
if !AttachContext(req, ctx) {
|
||||||
|
return errors.Errorf("invalid request type %v", req.Type)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenRegionErrorResp returns corresponding Response with specified RegionError
|
// GenRegionErrorResp returns corresponding Response with specified RegionError
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue