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

Allow configuring the policy when prewrite encounters lock #1501

Merged
merged 4 commits into from
Jan 2, 2025

Conversation

ekexium
Copy link
Contributor

@ekexium ekexium commented Nov 18, 2024

The PR allows the upper layer to control what to do when prewrite encounters lock. A typical usage is for TiDB optimistic autocommit transactions in high-contention scenarios. TiDB will retry the statement in pessimistic mode, so an error can be directly returned to save the effort of backoff, improving efficiency and latency.
A sysbench update_non_index with pareto distribution shows the difference:

If we choose to skip resolving locks when prewrite encounters locks

Throughput:
    events/s (eps):                      1354.3807
    time elapsed:                        300.3328s
    total number of events:              406765

Latency (ms):
         min:                                    0.63
         avg:                                   73.79
         max:                                  582.63
         95th percentile:                      484.44
         sum:                             30015198.03

Master (try resolving locks)

Throughput:
    events/s (eps):                      1172.5760
    time elapsed:                        300.3959s
    total number of events:              352237

Latency (ms):
         min:                                    0.64
         avg:                                   85.23
         max:                                 1028.40
         95th percentile:                      590.56
         sum:                             30019655.50

@ti-chi-bot ti-chi-bot bot added dco-signoff: yes Indicates the PR's author has signed the dco. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 18, 2024
@ekexium ekexium force-pushed the prewrite-encounter-lock-policy branch from 08b47b2 to 8ce525d Compare November 18, 2024 12:45
Signed-off-by: ekexium <[email protected]>
@ekexium ekexium force-pushed the prewrite-encounter-lock-policy branch from 8ce525d to fa81972 Compare November 18, 2024 13:12
@ekexium ekexium requested review from you06 and MyonKeminta November 20, 2024 06:07
@you06
Copy link
Contributor

you06 commented Nov 25, 2024

The comparison data between this PR and master in description is same, is there a typo?

@ekexium
Copy link
Contributor Author

ekexium commented Nov 25, 2024

The comparison data between this PR and master in description is same, is there a typo?

Oops. Updated.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 25, 2024
TryResolvePolicy PrewriteEncounterLockPolicy = iota
// NoResolvePolicy means do not resolve, but return write conflict errors directly.
// This can be used to let the upper layer choose to retry in pessimistic mode.
NoResolvePolicy
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the specific design for using the policy at the upper layer? Is it that autocommit optimistic transactions use NoResolvePolicy while everything else remains unchanged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

autocommit optimistic transactions use NoResolvePolicy while everything else remains unchanged

Yes

Copy link

ti-chi-bot bot commented Jan 2, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, you06

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 2, 2025
Copy link

ti-chi-bot bot commented Jan 2, 2025

[LGTM Timeline notifier]

Timeline:

  • 2024-11-25 09:18:06.29619009 +0000 UTC m=+455273.915844600: ☑️ agreed by you06.
  • 2025-01-02 05:49:19.615761208 +0000 UTC m=+588694.971765771: ☑️ agreed by cfzjywxk.

@ti-chi-bot ti-chi-bot bot merged commit 743aec1 into tikv:master Jan 2, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants