mirror of https://github.com/tikv/client-go.git
fix attach api ctx error for unknown requests like StoreSafeTS (#720)
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
This commit is contained in:
parent
596b79404d
commit
11d34cbd8a
|
@ -101,10 +101,7 @@ func attachAPICtx(c Codec, req *tikvrpc.Request) (*tikvrpc.Request, error) {
|
||||||
r.Req = &mpp
|
r.Req = &mpp
|
||||||
}
|
}
|
||||||
|
|
||||||
err := tikvrpc.AttachContext(&r, ctx)
|
_ = tikvrpc.AttachContext(&r, ctx)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &r, nil
|
return &r, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/pingcap/kvproto/pkg/kvrpcpb"
|
"github.com/pingcap/kvproto/pkg/kvrpcpb"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/tikv/client-go/v2/tikvrpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParseKeyspaceID(t *testing.T) {
|
func TestParseKeyspaceID(t *testing.T) {
|
||||||
|
@ -46,3 +47,13 @@ func TestDecodeKey(t *testing.T) {
|
||||||
assert.Empty(t, pfx)
|
assert.Empty(t, pfx)
|
||||||
assert.Empty(t, key)
|
assert.Empty(t, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEncodeUnknownRequest(t *testing.T) {
|
||||||
|
req := &tikvrpc.Request{
|
||||||
|
Type: tikvrpc.CmdStoreSafeTS,
|
||||||
|
Req: &kvrpcpb.StoreSafeTSRequest{},
|
||||||
|
}
|
||||||
|
c := NewCodecV1(ModeTxn)
|
||||||
|
_, err := c.EncodeRequest(req)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue