Skip to content
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

Merged
merged 5 commits into from
Dec 16, 2016

Conversation

coocood
Copy link
Member

@coocood coocood commented Dec 15, 2016

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.

if err := s.checkSchemaValid(); err != nil {
if !s.sessionVars.RetryInfo.Retrying && s.isRetryableError(err) {
Copy link
Contributor

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

Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@tiancaiamao
Copy link
Contributor

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...)
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Member Author

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.

@zimulala
Copy link
Contributor

LGTM

@coocood coocood merged commit c24c90b into master Dec 16, 2016
@coocood coocood deleted the coocood/refactor-session branch December 16, 2016 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants