Skip to content

Commit

Permalink
server: clean up code for better understanding
Browse files Browse the repository at this point in the history
Signed-off-by: dragonly <[email protected]>
  • Loading branch information
dragonly committed Sep 8, 2021
1 parent a7cba16 commit 3c16f5e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1706,23 +1706,20 @@ func (cc *clientConn) handleQuery(ctx context.Context, sql string) (err error) {
}
retryable, err = cc.handleStmt(ctx, stmt, parserWarns, i == len(stmts)-1)
if err != nil {
if !retryable || !errors.ErrorEqual(err, storeerr.ErrTiFlashServerTimeout) {
break
}
_, allowTiFlashFallback := cc.ctx.GetSessionVars().AllowFallbackToTiKV[kv.TiFlash]
if allowTiFlashFallback && errors.ErrorEqual(err, storeerr.ErrTiFlashServerTimeout) && retryable {
if allowTiFlashFallback {
// When the TiFlash server seems down, we append a warning to remind the user to check the status of the TiFlash
// server and fallback to TiKV.
warns := append(parserWarns, stmtctx.SQLWarn{Level: stmtctx.WarnLevelError, Err: err})
func() {
delete(cc.ctx.GetSessionVars().IsolationReadEngines, kv.TiFlash)
defer func() {
cc.ctx.GetSessionVars().IsolationReadEngines[kv.TiFlash] = struct{}{}
}()
_, err = cc.handleStmt(ctx, stmt, warns, i == len(stmts)-1)
}()
delete(cc.ctx.GetSessionVars().IsolationReadEngines, kv.TiFlash)
_, err = cc.handleStmt(ctx, stmt, warns, i == len(stmts)-1)
cc.ctx.GetSessionVars().IsolationReadEngines[kv.TiFlash] = struct{}{}
if err != nil {
break
}
} else {
break
}
}
}
Expand Down

0 comments on commit 3c16f5e

Please sign in to comment.