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

lock: add delay clean table lock when session close #11038

Merged
merged 7 commits into from
Jul 4, 2019

Conversation

crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented Jul 2, 2019

What problem does this PR solve?

Add delay-clean-table-lock configuration to control delay clean table lock.

It is used for TiSpark.

Before This PR:

The logic of TiSpark to use the table lock is:

  1. lock table
  2. prewrite data.
  3. check whether the locked table session is closed.
  4. if the session doesn't close, do commit.
  5. if the session was closed by unexpected, do a rollback.

The problem is, What if the session was closed by unexpected between step 3 and 4, It will cause some problem.

TiFlash need to delayed release table lock before do commit.

What is changed and how it works?

Add sleep in session.Close if delay-clean-table-lock has been configed.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

Related changes

  • Need to cherry-pick to the release branch 3.0

@crazycs520
Copy link
Contributor Author

/run-all-tests

@codecov
Copy link

codecov bot commented Jul 2, 2019

Codecov Report

Merging #11038 into master will decrease coverage by 0.0584%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##             master     #11038        +/-   ##
================================================
- Coverage   81.0145%   80.9561%   -0.0585%     
================================================
  Files           419        419                
  Lines         89732      89336       -396     
================================================
- Hits          72696      72323       -373     
- Misses        11773      11778         +5     
+ Partials       5263       5235        -28

@crazycs520
Copy link
Contributor Author

/run-all-tests

Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -57,6 +57,9 @@ treat-old-version-utf8-as-utf8mb4 = true
# enable-table-lock is used to control table lock feature. Default is false, indicate the table lock feature is disabled.
enable-table-lock = false

# delay-clean-table-lock is used to control delay release table lock when the abnormal situation. (Milliseconds)
Copy link
Contributor

Choose a reason for hiding this comment

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

is used to control delay release table lock when the abnormal situation. -> is used to control whether delayed-release the table lock in the abnormal situation.

config/config.toml.example Outdated Show resolved Hide resolved
Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

LGTM

@crazycs520
Copy link
Contributor Author

/run-all-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants