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: only wake up waiters when locks are indeed released (#7379) #7549

Closed
wants to merge 1 commit into from

Conversation

sre-bot
Copy link
Contributor

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

cherry-pick #7379 to release-3.0


Signed-off-by: youjiali1995 zlwgx1023@gmail.com

What problem does this PR solve?

Problem Summary:
TiKV will wake up waiters as long as it receives requests that may release locks, e.g., pessimistic_rollback, rollback, commit. If a request doesn't release locks, typically the lock doesn't exist, it needn't wake up waiters.

In TiDB, if a pessimistic DML meets write conflict, it will use pessimistic_rollback to clean up all locks it needs to lock in this DML and then retry the DML. If a transaction is waked up and there are other transactions waiting for the lock, these transactions will be waked up by pessimistic_rollback one by one. It dramatically affects performance and results in useless retry.

What is changed and how it works?

What's Changed:
Only wake up waiters when locks are indeed released and small refactor.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Manual test (add detailed scripts or steps below)
  • No code

I think existing tests are enough and I benched it using sysbench with the workload below:

con:query(CREATE TABLE wmtest(k INT PRIMARY KEY, v INT))
con:query(string.format("UPDATE wmtest SET v = v + 1 WHERE k IN (%d, 1)", sysbench.rand.uniform(2, sysbench.opt.table_size)))

master:

threads tps avg lat(ms) .95 lat(ms) .99 retry count
1 783 1.28 1.79 0
100 71 1393 2493 800
500 16 30111 72316 1457
1000 12 71181 100000 654

This PR:

threads tps avg lat(ms) .95 lat(ms) .99 retry count
100 772 129 155 1
500 724 688 787 1
1000 647 1534 1903 5

image

Release note

Fix the issue that needless wake-up results in useless retry and performance reduction in heavy contention workloads.

Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor Author

sre-bot commented Apr 20, 2020

/run-all-tests

@sre-bot sre-bot added sig/transaction SIG: Transaction type/bugfix Type: PR - Fix a bug type/cherry-pick Type: PR - Cherry pick labels Apr 20, 2020
@sre-bot sre-bot added this to the v3.0.13 milestone Apr 20, 2020
Copy link
Contributor

@nrc nrc left a comment

Choose a reason for hiding this comment

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

There's quite a lot of rebasing errors where diff markers have been left in

=======
mod incremental_get;
mod key;
>>>>>>> b4dd42f... txn: only wake up waiters when locks are indeed released (#7379):tests/benches/misc/storage/mod.rs
Copy link
Contributor

Choose a reason for hiding this comment

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

rebase error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/transaction SIG: Transaction type/bugfix Type: PR - Fix a bug type/cherry-pick Type: PR - Cherry pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants