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

session: add a global/session variable 'tidb_disable_txn_auto_retry' #6872

Merged
merged 3 commits into from
Jun 21, 2018

Conversation

coocood
Copy link
Member

@coocood coocood commented Jun 20, 2018

What have you changed? (mandatory)

  • Add a global/session variable 'tidb_disable_txn_auto_retry' that controls if a transaction should retry automatically.

What are the type of the changes (mandatory)?

  • Improvement (non-breaking change which is an improvement to an existing feature)

How has this PR been tested (mandatory)?

  • unit test

Does this PR affect documentation (docs/docs-cn) update? (optional)

  • yes

@coocood
Copy link
Member Author

coocood commented Jun 20, 2018

@shenli @tiancaiamao @jackysp PTAL

tk1.Se.NewTxn()
// session 2 update the value.
tk2.MustExec("update no_retry set id = 4")
// Non-autocommit update will retry, so it would not fail.
Copy link
Member

Choose a reason for hiding this comment

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

It should be Autocommit.


// session 1 starts a transaction early.
// execute a select statement to .
tk1.MustExec("select 1")
Copy link
Member

Choose a reason for hiding this comment

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

Why add select 1 here?

@@ -198,6 +201,7 @@ const (
DefTiDBMemQuotaNestedLoopApply = 32 << 30 // 32GB.
DefTiDBGeneralLog = 0
DefTiDBRetryLimit = 10
DefTiDBDisableTxnAutoRetry = false
Copy link
Member

Choose a reason for hiding this comment

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

I think it could be true as default.

Copy link
Member

Choose a reason for hiding this comment

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

This should be false by default for now. Because many users rely on the auto-retry.

@@ -346,6 +346,15 @@ func (s *session) doCommitWithRetry(ctx context.Context) error {
err := s.doCommit(ctx)
if err != nil {
commitRetryLimit := s.sessionVars.RetryLimit
if s.sessionVars.DisableTxnAutoRetry {
Copy link
Member

Choose a reason for hiding this comment

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

For the internal sessions, we need always enable the auto-retry.

// For explicit transactions, the statement count is more than 1.
history := GetHistory(s)
if history.Count() > 1 {
commitRetryLimit = 0
Copy link
Member

Choose a reason for hiding this comment

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

Can we return here.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, there are extra works to do below.

@disksing
Copy link
Contributor

/rebuild

@shenli
Copy link
Member

shenli commented Jun 21, 2018

/run-all-tests

@coocood
Copy link
Member Author

coocood commented Jun 21, 2018

@shenli @jackysp PTAL

@shenli
Copy link
Member

shenli commented Jun 21, 2018

LGTM

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@shenli
Copy link
Member

shenli commented Jun 21, 2018

/run-all-tests

@zimulala zimulala added the status/LGT2 Indicates that a PR has LGTM 2. label Jun 21, 2018
@shenli
Copy link
Member

shenli commented Jun 21, 2018

/run-all-tests

@tiancaiamao tiancaiamao merged commit 8bec188 into pingcap:master Jun 21, 2018
@coocood coocood deleted the disable-auto-retry-option branch June 21, 2018 09:44
coocood added a commit to coocood/tidb that referenced this pull request Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants