Skip to content

cdc: adjust assertion when merge locks#19047

Merged
ti-chi-bot[bot] merged 1 commit intotikv:masterfrom
3AceShowHand:cdc-fix-start-ts-equal-prepare-lock-tracker
Oct 13, 2025
Merged

cdc: adjust assertion when merge locks#19047
ti-chi-bot[bot] merged 1 commit intotikv:masterfrom
3AceShowHand:cdc-fix-start-ts-equal-prepare-lock-tracker

Conversation

@3AceShowHand
Copy link
Contributor

@3AceShowHand 3AceShowHand commented Oct 11, 2025

What is changed and how it works?

Issue Number: Close #19048

What's Changed:

fix potential panic which may happen when subscribe the region and meet rollback and prewrite entry

Similar to the #19025, but the region is subscribed after the rollback prewrite entry stored into the disk and before the prewrite the same key.


The bug may occurs when:
1. T1 prewrites and commits key K (start_ts=100, commit_ts=110)
    → CF_WRITE[K@110] contains T1's committed write

2. T2 prewrites key K as a SECONDARY key (start_ts=111), and CDC subscribe the region 
   → CF_LOCK[K] contains T2's lock
   → CF_LOCK[K@111] scanned out when doing incremental scan by the `scan_locks_from_storage`
   → CDC incremental scan finished and set to the resolver by the `finish_scan_locks`

4. T2 rolls back key K
   → Finds overlapped_write from T1 at commit_ts=110
   → Since K is NOT T2's primary: protected=false
   → make_rollback() returns None (no CF_WRITE entry!)
   → Only deletes from CF_LOCK
   → CDC ignores the DELETE operation

5. T3 prewrites key K
   → Triggers resolve_lock which removes T2's stale lock from CF_LOCK
   → No CDC notification

6. CDC processes T3's prewrite
   → Calls push_lock for T3
   → Finds T2's stale lock still in lock_tracker
   → Assertion fails: different start_ts

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

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

Side effects

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

Release note

fix potential panic which may happen when subscribe the region and meet rollback and prewrite entry

Signed-off-by: 3AceShowHand <jinl1037@hotmail.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-triage-completed needs-cherry-pick-release-9.0-beta.2 needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. and removed do-not-merge/needs-linked-issue do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/needs-triage-completed labels Oct 11, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Oct 13, 2025

@asddongmen: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

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.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Oct 13, 2025
@ti-chi-bot ti-chi-bot bot added the lgtm label Oct 13, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Oct 13, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: asddongmen, cfzjywxk, YuJuncen

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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Oct 13, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Oct 13, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-10-13 03:45:21.013039614 +0000 UTC m=+65827.090292164: ☑️ agreed by cfzjywxk.
  • 2025-10-13 04:33:13.010680491 +0000 UTC m=+68699.087933041: ☑️ agreed by YuJuncen.

@ti-chi-bot ti-chi-bot bot merged commit 2552465 into tikv:master Oct 13, 2025
9 checks passed
@ti-chi-bot ti-chi-bot bot added this to the Pool milestone Oct 13, 2025
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #19051.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-9.0-beta.2: #19052.

3AceShowHand added a commit to 3AceShowHand/tikv that referenced this pull request Oct 13, 2025
close tikv#19048

fix potential panic which may happen when subscribe the region and meet rollback and prewrite entry

Signed-off-by: 3AceShowHand <jinl1037@hotmail.com>
ti-chi-bot bot pushed a commit that referenced this pull request Oct 13, 2025
close #19048

fix potential panic which may happen when subscribe the region and meet rollback and prewrite entry

Signed-off-by: 3AceShowHand <jinl1037@hotmail.com>

Co-authored-by: 3AceShowHand <jinl1037@hotmail.com>
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 needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. needs-cherry-pick-release-9.0-beta.2 release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CDC may panic if subscribe the region between the key rollback and prewrite entry

5 participants