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

store/tikv: resolve all locks no matter they're expired or not in BatchResolveLocks #12784

Merged
merged 4 commits into from Oct 25, 2019

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Oct 17, 2019

What problem does this PR solve?

Should GC rollback a transaction even its lock TTL is not expired? That's hard to answer.

If we choose YES, transactions may be killed unexpectedly by GC.
If we choose NO, then the GC processing would be blocked by active transactions.
We're in a dilemma.

After we introduce the support for large transactions, the TTL may be updating.
It's hard to guarantee when GC could run if we let active transactions block GC.

The simpler solution is to let GC rollback transactions, which is the same as the elder version TiDB does.

What is changed and how it works?

In #11999 we choose to not resolve large transaction's lock, that's not a thoughtful change, and has potential correctness issues.

In this commit, BatchResolveLocks would resolve all locks no matter they're expired or not.

Check List

Tests

  • No code

@tiancaiamao tiancaiamao added require-LGT3 Indicates that the PR requires three LGTM. component/GC labels Oct 17, 2019
@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @MyonKeminta @jackysp

@codecov
Copy link

codecov bot commented Oct 17, 2019

Codecov Report

Merging #12784 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #12784   +/-   ##
===========================================
  Coverage   79.9755%   79.9755%           
===========================================
  Files           465        465           
  Lines        107294     107294           
===========================================
  Hits          85809      85809           
  Misses        15000      15000           
  Partials       6485       6485

@MyonKeminta
Copy link
Contributor

Is there any test for it?

Copy link
Contributor

@MyonKeminta MyonKeminta left a comment

Choose a reason for hiding this comment

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

The code LGTM. But I think there need some tests.

@coocood
Copy link
Member

coocood commented Oct 21, 2019

LGTM

@tiancaiamao
Copy link
Contributor Author

tiancaiamao commented Oct 21, 2019

Is there any test for it?

Construct a counterexample that does unsafe GC in the unit test is not easy work. @MyonKeminta

@MyonKeminta
Copy link
Contributor

@tiancaiamao How about try to test only the BatchResolveLock function, and check whether it cleans up locks correctly and returns correct results?

@tiancaiamao
Copy link
Contributor Author

@tiancaiamao How about try to test only the BatchResolveLock function, and check whether it cleans up locks correctly and returns correct results?

Sounds reasonable ...

@tiancaiamao
Copy link
Contributor Author

PTAL @MyonKeminta

@tiancaiamao
Copy link
Contributor Author

Ping @MyonKeminta

@tiancaiamao
Copy link
Contributor Author

PTAL @MyonKeminta

Copy link
Contributor

@MyonKeminta MyonKeminta left a comment

Choose a reason for hiding this comment

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

LGTM

@tiancaiamao
Copy link
Contributor Author

/rebuild

@tiancaiamao tiancaiamao added the status/LGT2 Indicates that a PR has LGTM 2. label Oct 25, 2019
@tiancaiamao
Copy link
Contributor Author

PTAL @jackysp

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

@jackysp jackysp added the status/can-merge Indicates a PR has been approved by a committer. label Oct 25, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 25, 2019

Your auto merge job has been accepted, waiting for 12878

@jackysp jackysp added status/LGT3 The PR has already had 3 LGTM. and removed status/LGT2 Indicates that a PR has LGTM 2. labels Oct 25, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 25, 2019

/run-all-tests

@sre-bot sre-bot merged commit c242d2b into pingcap:master Oct 25, 2019
@tiancaiamao tiancaiamao deleted the gc-batch-resolve-locks branch October 25, 2019 07:01
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/GC require-LGT3 Indicates that the PR requires three LGTM. status/can-merge Indicates a PR has been approved by a committer. status/LGT3 The PR has already had 3 LGTM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants