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

tikv: collapse duplicate resolve locks in region requests (#16838) #16925

Merged
merged 2 commits into from
Apr 29, 2020

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented Apr 29, 2020

cherry-pick #16838 to release-4.0


What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:

When txn1, txn2 meet txn1's lock, and txn1 is large txn that modify many keys

both txn1, txn2 will try to resolve(after check txn status) the whole region even if txn1 meet lock at k1 and txn2 meet lock at k2.

we can deduplicate resolve requests that try to resolve the whole region.

What is changed and how it works?

Proposal: xxx

What's Changed:

At first glance, we should do it in LockResolver, but the question is it's hard to maintain backoff behavior at LockResolver level:

if we collapse multiple lock requests into one request at LockResolver level, working request maybe meet many error and backoff(e.g. regionMiss, notLeader, kvRpc...), we are hard to let those backoff info feedback to collapsed requests that waiting for working request.

so this PR chooses to do it in lower level ---- at TiClient that this level, we only need to take care context.Cancel and timeout.

How it Works:

collapse multi resolve request into one request using singleflight.

and chose DoChan to impl request level timeout and context.Cancel

Related changes

  • Need to cherry-pick to the release branch(after test..)

Check List

Tests

  • Integration test(old test)

Side effects

  • reduce kv resolve request count

Release note

collapse duplicate resolve locks in region requests


This change is Reviewable

@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 29, 2020

/run-all-tests

@tiancaiamao
Copy link
Contributor

LGTM

[2020-04-29T02:45:24.414Z] ----------------------------------------------------------------------
[2020-04-29T02:45:24.414Z] FAIL: <autogenerated>:1: tidbTestSerialSuite.SetUpSuite
[2020-04-29T02:45:24.414Z] 
[2020-04-29T02:45:24.414Z] tidb_test.go:92:
[2020-04-29T02:45:24.414Z]     c.Assert(err, IsNil)
[2020-04-29T02:45:24.414Z] ... value *errors.withStack = listen tcp 0.0.0.0:10094: bind: address already in use ("listen tcp 0.0.0.0:10094: bind: address already in use")
[2020-04-29T02:45:24.414Z] 
[2020-04-29T02:45:24.414Z] 
[2020-04-29T02:45:24.414Z] ----------------------------------------------------------------------

@tiancaiamao tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 29, 2020
Copy link
Contributor

@crazycs520 crazycs520 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 requested a review from jackysp April 29, 2020 09:03
@lysu
Copy link
Contributor

lysu commented Apr 29, 2020

@jackysp need a approve and merge thx~

@jackysp
Copy link
Member

jackysp commented Apr 29, 2020

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 29, 2020
@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 29, 2020

/run-all-tests

@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 29, 2020

@sre-bot merge failed.

@lysu
Copy link
Contributor

lysu commented Apr 29, 2020

/run-integration-copr-test

@jackysp jackysp merged commit 1e321d3 into pingcap:release-4.0 Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tikv status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/enhancement The issue or PR belongs to an enhancement. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants