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

Projects
None yet
3 participants
@crazycs520
Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Jul 2, 2019

/run-all-tests

@codecov

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor Author

commented Jul 2, 2019

/run-all-tests

crazycs520 added some commits Jul 4, 2019

@bb7133
Copy link
Contributor

left a comment

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)

This comment has been minimized.

Copy link
@winkyao

winkyao Jul 4, 2019

Member

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.

Show resolved Hide resolved config/config.toml.example Outdated
@winkyao
Copy link
Member

left a comment

LGTM

@winkyao

winkyao approved these changes Jul 4, 2019

@crazycs520

This comment has been minimized.

Copy link
Contributor Author

commented Jul 4, 2019

/run-all-tests

@crazycs520 crazycs520 merged commit fba5e6f into pingcap:master Jul 4, 2019

14 checks passed

ci/circleci Your tests passed on CircleCI!
Details
idc-jenkins-ci-tidb/build Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/build_check_race Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev_2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/common-test job succeeded
Details
idc-jenkins-ci-tidb/integration-common-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-compatibility-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-ddl-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/mybatis-test job succeeded
Details
idc-jenkins-ci-tidb/sqllogic-test-1 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/sqllogic-test-2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/unit-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.