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

table: Add PessimisticLazyDupKeyCheckMode to determine lazy mode in pessimistic txn #55360

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

lcwangchao
Copy link
Collaborator

What problem does this PR solve?

Issue Number: close #54397

What changed and how does it work?

This PR introduced a new table option PessimisticLazyDupKeyCheckMode to determine the lazy check mode in pessimistic mode. It has two values:

type PessimisticLazyDupKeyCheckMode uint8

const (
	// PessimisticKeyCheckInLock indicates to check the duplicated key when acquiring the pessimistic lock.
	PessimisticKeyCheckInLock PessimisticLazyDupKeyCheckMode = iota
	// PessimisticKeyCheckInPrewrite indicates to check the duplicated key in the prewrite step when committing.
	// Please notice that if it is used, the duplicated key error may not be returned immediately after each statement,
	// because the duplicated key is not checked when acquiring the pessimistic lock.
	PessimisticKeyCheckInPrewrite
)

If PessimisticLazyDupKeyCheckMode is not specified, it is defaulted to PessimisticKeyCheckInLock.

PessimisticLazyDupKeyCheckMode only works when DupKeyCheckMode is DupKeyCheckLazy in pessimistic mode.

This PR also removed method GetSessionVars in table.MutateContext to make the context simple.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 12, 2024
Copy link

tiprow bot commented Aug 12, 2024

Hi @lcwangchao. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@lcwangchao lcwangchao force-pushed the pessimisticlazymode branch 5 times, most recently from 6c7dada to 4e5b3cc Compare August 12, 2024 07:21
Copy link

codecov bot commented Aug 12, 2024

Codecov Report

Attention: Patch coverage is 94.44444% with 2 lines in your changes missing coverage. Please review.

Project coverage is 73.9827%. Comparing base (bab3667) to head (f2f3d98).

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55360        +/-   ##
================================================
- Coverage   74.9797%   73.9827%   -0.9970%     
================================================
  Files          1576       1576                
  Lines        365580     440666     +75086     
================================================
+ Hits         274111     326017     +51906     
- Misses        71737      94715     +22978     
- Partials      19732      19934       +202     
Flag Coverage Δ
integration 45.8321% <91.6666%> (?)
unit 71.9044% <63.8888%> (-2.0768%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9567% <ø> (-2.2327%) ⬇️
parser ∅ <ø> (∅)
br 46.2505% <ø> (-1.5679%) ⬇️

@lcwangchao lcwangchao requested a review from cfzjywxk August 12, 2024 10:01
@lcwangchao lcwangchao force-pushed the pessimisticlazymode branch from 4e5b3cc to dd875ed Compare August 14, 2024 01:46
@lcwangchao lcwangchao force-pushed the pessimisticlazymode branch from dd875ed to f2f3d98 Compare August 14, 2024 01:48
@lcwangchao lcwangchao requested a review from YangKeao August 14, 2024 01:49
Copy link
Contributor

@cfzjywxk cfzjywxk left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 14, 2024
Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Aug 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Aug 14, 2024
Copy link

ti-chi-bot bot commented Aug 14, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-14 02:11:47.813376009 +0000 UTC m=+320392.516845652: ☑️ agreed by cfzjywxk.
  • 2024-08-14 03:07:21.594026092 +0000 UTC m=+323726.297495727: ☑️ agreed by YangKeao.

@ti-chi-bot ti-chi-bot bot merged commit 0e47f9a into pingcap:master Aug 14, 2024
21 of 23 checks passed
@lcwangchao lcwangchao deleted the pessimisticlazymode branch August 14, 2024 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove GetSessionVars in table.MutateContext
3 participants