Skip to content

pessimistic-transaction: clarify Point Get lock behavior for non-existing keys under different isolation levels (#23111)#23138

Merged
ti-chi-bot[bot] merged 3 commits into
pingcap:masterfrom
ti-chi-bot:cherry-pick-23111-to-master
Jul 14, 2026
Merged

pessimistic-transaction: clarify Point Get lock behavior for non-existing keys under different isolation levels (#23111)#23138
ti-chi-bot[bot] merged 3 commits into
pingcap:masterfrom
ti-chi-bot:cherry-pick-23111-to-master

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #23111

What is changed, added or deleted? (Required)

Added a Note in the Behaviors section of pessimistic-transaction.md to clarify that the Point Get and Batch Point Get lock behavior for non-existing keys applies only to the REPEATABLE READ isolation level.

Under the READ COMMITTED isolation level, Point Get and Batch Point Get operators do not lock non-existent keys. This is a behavioral difference that can affect applications using SELECT FOR UPDATE for existence checks followed by INSERT.

Which TiDB version(s) do your changes apply to? (Required)

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)

What is the related PR or file link(s)?

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Verification

This behavior was verified on TiDB v8.5.3:

# Access Method Isolation Level Non-existing Key Lock Acquired?
1 Point Get Repeatable Read id = 999 Yes
2 Point Get Read Committed id = 888 No
3 Batch Point Get Repeatable Read id IN (777, 888) Yes
4 Range Scan Repeatable Read id BETWEEN 100 AND 200 No (no gap lock)

A test script was provided in the PR comments for reviewers to verify the behavior locally.

@ti-chi-bot ti-chi-bot added area/transaction Indicates that the Issue or PR belongs to the area of transaction. lgtm needs-1-more-lgtm Indicates a PR needs 1 more LGTM. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. type/cherry-pick-for-master This PR is cherry-picked to master from a source PR. labels Jun 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the pessimistic transactions documentation to clarify that Point Get and Batch Point Get operators do not lock non-existent keys under the Read Committed isolation level. The review feedback suggests a minor improvement to avoid repeating the operator names in consecutive sentences, enhancing readability in accordance with the style guide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pessimistic-transaction.md
@qiancai

qiancai commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

/approve

@ti-chi-bot

ti-chi-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiancai

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

The pull request process is described here

Details 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 the approved label Jul 14, 2026
@ti-chi-bot ti-chi-bot Bot merged commit 150384e into pingcap:master Jul 14, 2026
11 checks passed
@ti-chi-bot ti-chi-bot Bot deleted the cherry-pick-23111-to-master branch July 14, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved area/transaction Indicates that the Issue or PR belongs to the area of transaction. lgtm needs-1-more-lgtm Indicates a PR needs 1 more LGTM. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. type/cherry-pick-for-master This PR is cherry-picked to master from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants