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

*: add a variable to control the back off time and disable txn auto retry by default #10266

Merged
merged 7 commits into from
May 8, 2019

Conversation

jackysp
Copy link
Member

@jackysp jackysp commented Apr 25, 2019

What problem does this PR solve?

If TiKV doesn't return a retryable error, TiDB should not retry the transaction. But we need a way to control the back off time to avoid the SQL failing when the PD/TiKV is not available.

What is changed and how it works?

Add a variable to control the back off time, and disable txn auto retry by default.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

  • Increased code complexity

@jackysp
Copy link
Member Author

jackysp commented Apr 25, 2019

/run-all-tests

@jackysp
Copy link
Member Author

jackysp commented Apr 25, 2019

/rebuild

1 similar comment
@zhouqiang-cl
Copy link
Contributor

/rebuild

@zhouqiang-cl
Copy link
Contributor

/run-all-tests

@codecov
Copy link

codecov bot commented Apr 29, 2019

Codecov Report

Merging #10266 into master will decrease coverage by 0.0138%.
The diff coverage is 77.7777%.

@@               Coverage Diff                @@
##             master     #10266        +/-   ##
================================================
- Coverage   77.8343%   77.8204%   -0.0139%     
================================================
  Files           410        410                
  Lines         84306      84330        +24     
================================================
+ Hits          65619      65626         +7     
- Misses        13797      13807        +10     
- Partials       4890       4897         +7

@codecov
Copy link

codecov bot commented Apr 29, 2019

Codecov Report

Merging #10266 into master will decrease coverage by 0.0102%.
The diff coverage is 76.923%.

@@               Coverage Diff                @@
##             master     #10266        +/-   ##
================================================
- Coverage   77.3234%   77.3131%   -0.0103%     
================================================
  Files           412        412                
  Lines         85542      85543         +1     
================================================
- Hits          66144      66136         -8     
- Misses        14383      14387         +4     
- Partials       5015       5020         +5

@disksing
Copy link
Contributor

I think you can split it into 2 PRs. One for the weight variable, one for refactor write conflict error.

@jackysp
Copy link
Member Author

jackysp commented Apr 29, 2019

It is not a big PR. I think it is not necessary.

Copy link
Contributor

@AndreMouche AndreMouche left a comment

Choose a reason for hiding this comment

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

Should we split this PR into two? It seems we both add tidb_back_off_weight and fix the retryableMark for network error?

kv/variables.go Outdated Show resolved Hide resolved
@@ -241,6 +241,9 @@ func (b *Backoffer) WithVars(vars *kv.Variables) *Backoffer {
if vars != nil {
b.vars = vars
}
if math.MaxInt32/b.vars.BackOffWeight >= b.maxSleep {
b.maxSleep *= b.vars.BackOffWeight
Copy link
Contributor

Choose a reason for hiding this comment

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

So all backoff will use this weight? How about specifying only prewrite,commit,get_tso which will only be used in 2pc?

Copy link
Member Author

Choose a reason for hiding this comment

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

What are the benefits of doing this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean, if there is a physical failure, the need to change the backoff should be similar. Still keeping other values fixed, which may make this parameter very useless.

@jackysp jackysp force-pushed the control_backoff branch from 47fcc9f to f525557 Compare May 5, 2019 07:21
@jackysp jackysp changed the title *: add a variable to control the back off time *: add a variable to control the back off time and disable txn auto retry by default May 5, 2019
Signed-off-by: Shuaipeng Yu <[email protected]>
@jackysp jackysp force-pushed the control_backoff branch from f22e526 to 4128691 Compare May 5, 2019 11:25
@jackysp
Copy link
Member Author

jackysp commented May 5, 2019

/run-all-tests

@jackysp
Copy link
Member Author

jackysp commented May 5, 2019

/run-common-test tidb-test=pr/800

1 similar comment
@jackysp
Copy link
Member Author

jackysp commented May 5, 2019

/run-common-test tidb-test=pr/800

AndreMouche
AndreMouche previously approved these changes May 6, 2019
Copy link
Contributor

@AndreMouche AndreMouche left a comment

Choose a reason for hiding this comment

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

LGTM

@jackysp jackysp removed the status/DNM label May 6, 2019
@jackysp jackysp requested a review from lysu May 6, 2019 09:57
@jackysp
Copy link
Member Author

jackysp commented May 6, 2019

PTAL @disksing @lysu

@lysu lysu added the status/LGT1 Indicates that a PR has LGTM 1. label May 6, 2019
@lysu
Copy link
Contributor

lysu commented May 6, 2019

@jackysp Please add more description or comment about background & how-to-use for BackOffWeight, it hard to understand, why we should

	if math.MaxInt32/b.vars.BackOffWeight >= b.maxSleep {
		b.maxSleep *= b.vars.BackOffWeight
	}

and how and when to choose right BackOffWeight value for new viewer like me :D

Signed-off-by: Shuaipeng Yu <[email protected]>
Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

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

LGTM

@lysu lysu added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 7, 2019
@disksing
Copy link
Contributor

disksing commented May 7, 2019

LGTM

@disksing disksing added status/LGT3 The PR has already had 3 LGTM. and removed status/LGT2 Indicates that a PR has LGTM 2. labels May 7, 2019
@disksing
Copy link
Contributor

disksing commented May 7, 2019

/run-all-tests

@@ -18,6 +18,9 @@ type Variables struct {
// BackoffLockFast specifies the LockFast backoff base duration in milliseconds.
BackoffLockFast int

// BackOffWeight specifies the weight of the max back off time duration.
BackOffWeight int
Copy link
Member

Choose a reason for hiding this comment

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

backoff weight is a little confusion, how about directly set the max backoff time?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are many kinds of backoffs. Maybe set them separately in the future.

@jackysp jackysp merged commit d8589df into pingcap:master May 8, 2019
@jackysp jackysp deleted the control_backoff branch May 29, 2019 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/P1 The issue has P1 priority. sig/transaction SIG:Transaction status/LGT3 The PR has already had 3 LGTM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants