Skip to content

Commit

Permalink
server: add tiflash fallback testcase (#23248)
Browse files Browse the repository at this point in the history
Co-authored-by: Yiding Cui <[email protected]>
  • Loading branch information
xuyifangreeneyes and winoros authored Mar 12, 2021
1 parent 6d258c7 commit 413ba4c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 5 additions & 1 deletion server/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,11 @@ func (ts *ConnTestSuite) TestTiFlashFallback(c *C) {
c.Assert(cc.handleQuery(ctx, "select * from t t1 join t t2 on t1.a = t2.a"), NotNil)
c.Assert(failpoint.Disable("github.com/pingcap/tidb/server/secondNextErr"), IsNil)

// TODO: simple TiFlash query (unary + non-streaming)
// simple TiFlash query (unary + non-streaming)
tk.MustExec("set @@tidb_allow_batch_cop=0; set @@tidb_allow_mpp=0;")
c.Assert(failpoint.Enable("github.com/pingcap/tidb/store/tikv/tikvStoreSendReqResult", "return(\"requestTiFlashError\")"), IsNil)
testFallbackWork(c, tk, cc, "select sum(a) from t")
c.Assert(failpoint.Disable("github.com/pingcap/tidb/store/tikv/tikvStoreSendReqResult"), IsNil)

// TiFlash query based on batch cop (batch + streaming)
tk.MustExec("set @@tidb_allow_batch_cop=1; set @@tidb_allow_mpp=0;")
Expand Down
5 changes: 0 additions & 5 deletions store/mockstore/unistore/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,6 @@ func (c *RPCClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.R
case tikvrpc.CmdRawScan:
resp.Resp, err = c.rawHandler.RawScan(ctx, req.RawScan())
case tikvrpc.CmdCop:
failpoint.Inject("copRpcErr"+addr, func(value failpoint.Value) {
if value.(string) == addr {
failpoint.Return(nil, errors.New("cop rpc error"))
}
})
resp.Resp, err = c.usSvr.Coprocessor(ctx, req.Cop())
case tikvrpc.CmdCopStream:
resp.Resp, err = c.handleCopStream(ctx, req.Cop())
Expand Down
4 changes: 4 additions & 0 deletions store/tikv/region_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ func (s *RegionRequestSender) SendReqCtx(
if sType == kv.TiDB {
failpoint.Return(nil, nil, ErrTiKVServerTimeout)
}
case "requestTiFlashError":
if sType == kv.TiFlash {
failpoint.Return(nil, nil, ErrTiFlashServerTimeout)
}
}
})

Expand Down

0 comments on commit 413ba4c

Please sign in to comment.