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

txn: Check lock's TTL when doing cleanup #5471

Merged
merged 7 commits into from Sep 23, 2019

Conversation

@MyonKeminta
Copy link
Contributor

commented Sep 17, 2019

What have you changed?

This is designed for 3.x version to improve pessimistic lock, and works together with the txn_heart_beat API.

A new field current_ts is added to cleanup requests (and kvproto is already updated by other PRs). If this field is not zero, then TiKV should check whether the lock is expired according it. If the lock is not expired, returns KeyIsLocked error to notify TiDB about the lock.

(By the way, the cherry-picks, if the cherry picker works, should not be merged before updating kvproto. I will update it when cherry-picking txn_heart_beat.)

What is the type of the changes?

Pick one of the following and delete the others:

  • New feature (a change which adds functionality)

How is the PR tested?

By CI

Does this PR affect documentation (docs) or should it be mentioned in the release notes?

No

Does this PR affect tidb-ansible?

No

Refer to a related PR or issue link (optional)

Corresponding PR in TiDB: pingcap/tidb#12212

MyonKeminta added 4 commits Sep 17, 2019
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Fix test
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
@MyonKeminta

This comment has been minimized.

Copy link
Contributor Author

commented Sep 17, 2019

@coocood

This comment has been minimized.

Copy link
Contributor

commented Sep 23, 2019

LGTM

Copy link
Contributor

left a comment

LGTM

// TTL expired. The lock should be removed.
must_cleanup(&engine, k, ts(10, 0), ts(120, 0));
must_unlocked(&engine, k);
must_get_rollback_ts(&engine, k, ts(10, 0));

This comment has been minimized.

Copy link
@youjiali1995

youjiali1995 Sep 23, 2019

Contributor

Add a test about current_ts == 0?

This comment has been minimized.

Copy link
@MyonKeminta

MyonKeminta Sep 23, 2019

Author Contributor

The function rollback actually invokes cleanup with current_ts = 0, and I think there are already many tests for rollback, so I didn't test it here.

src/storage/mvcc/txn.rs Outdated Show resolved Hide resolved
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
cargo fmt
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
@sre-bot

This comment has been minimized.

Copy link
Collaborator

commented Sep 23, 2019

/run-all-tests

@sre-bot sre-bot merged commit 7cbf045 into tikv:master Sep 23, 2019
6 checks passed
6 checks passed
DCO All commits are signed off!
Details
idc-jenkins-ci-tikv/integration-common-test Jenkins job succeeded.
Details
idc-jenkins-ci-tikv/integration-compatibility-test Jenkins job succeeded.
Details
idc-jenkins-ci-tikv/integration-cop-push-down-test Jenkins job succeeded.
Details
idc-jenkins-ci-tikv/integration-ddl-test Jenkins job succeeded.
Details
idc-jenkins-ci/test Jenkins job succeeded.
Details
@sre-bot

This comment has been minimized.

Copy link
Collaborator

commented Sep 23, 2019

cherry pick to release-3.1 failed

@sre-bot

This comment has been minimized.

Copy link
Collaborator

commented Sep 23, 2019

cherry pick to release-3.0 failed

@MyonKeminta MyonKeminta deleted the MyonKeminta:misono/cleanup-check-ttl branch Sep 23, 2019
MyonKeminta added a commit to MyonKeminta/tikv that referenced this pull request Sep 24, 2019
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
@MyonKeminta

This comment has been minimized.

Copy link
Contributor Author

commented Sep 24, 2019

/run-cherry-picker

1 similar comment
@MyonKeminta

This comment has been minimized.

Copy link
Contributor Author

commented Oct 8, 2019

/run-cherry-picker

MyonKeminta added a commit to MyonKeminta/tikv that referenced this pull request Oct 8, 2019
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
sre-bot added a commit that referenced this pull request Oct 8, 2019
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
youjiali1995 added a commit that referenced this pull request Oct 9, 2019
* txn: Check lock's TTL when doing cleanup (#5471)

Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.