diff --git a/tidb.go b/tidb.go index 59240c18c9..e56d84bd61 100644 --- a/tidb.go +++ b/tidb.go @@ -218,7 +218,10 @@ func runStmt(ctx context.Context, s stmt.Statement, args ...interface{}) (rset.R err = ctx.FinishTxn(false) // We should retry for autocommit if terror.ErrorEqual(err, kv.ErrConditionNotMatch) { - return nil, ctx.(Session).Retry() + se, ok := ctx.(Session) + if ok { + return nil, se.Retry() + } } } return rs, errors.Trace(err)