-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tidb, variable: refactor retry, add TransactionContext #2256
Conversation
All variables that has transaction scope can be cleaned up at once.
if err := s.checkSchemaValid(); err != nil { | ||
if !s.sessionVars.RetryInfo.Retrying && s.isRetryableError(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it safe to remove retry here? @zimulala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I see... it's just moved to somewhere else...
return s | ||
} | ||
|
||
func (s *testSessionSuite) TestRetryAttempts(c *C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't use it any more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
LGTM |
@@ -594,6 +564,7 @@ func (s *session) ExecutePreparedStmt(stmtID uint32, args ...interface{}) (ast.R | |||
if err != nil { | |||
return nil, errors.Trace(err) | |||
} | |||
PrepareTxnCtx(s) | |||
st := executor.CompileExecutePreparedStmt(s, stmtID, args...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
executor.GetInfoSchema(s)
can be used in the function of CompileExecutePreparedStmt
.
if s.txn == nil { | ||
return nil | ||
} | ||
defer func() { | ||
s.txn = nil | ||
s.sessionVars.SetStatusFlag(mysql.ServerStatusInTrans, false) | ||
binloginfo.ClearBinlog(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to remove clear binlog value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Binlog isn't stored in context.SetValue
anymore, it will be cleared when TransactionContext is cleared.
LGTM |
Add TransactionContext which is used to store transaction scope variables, so we can clean up multiple variables at once.
Refactor session Retry related code, improves readability.