Skip to content

txn_status_cache: avoid deadlock in txn_status_cache with Pipelined DML#18385

Merged
ti-chi-bot[bot] merged 3 commits intotikv:masterfrom
ekexium:fix-txn-status-cache-deadlock
Apr 15, 2025
Merged

txn_status_cache: avoid deadlock in txn_status_cache with Pipelined DML#18385
ti-chi-bot[bot] merged 3 commits intotikv:masterfrom
ekexium:fix-txn-status-cache-deadlock

Conversation

@ekexium
Copy link
Contributor

@ekexium ekexium commented Apr 11, 2025

What is changed and how it works?

Issue Number: Close #18384

What's Changed:

Fix the deadlock issue in txn_status_cache.
When both large_txn_cache and normal_cache needs locking, always acquire large_txn_cache first.

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 the deadlock issue in txn_status_cache.

Signed-off-by: ekexium <eke@fastmail.com>
@ti-chi-bot ti-chi-bot bot added dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/needs-triage-completed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Apr 11, 2025
@ekexium ekexium requested a review from Copilot April 11, 2025 07:46
@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 11, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/storage/txn/txn_status_cache.rs:494

  • [nitpick] The fail_point identifier 'txn_status_cache_upsert_after_normal_before_large' is misleading given that the locks are now acquired in the order (large then normal). Consider renaming it to something like 'txn_status_cache_upsert_after_lock_acquisition' for clarity.
fail_point!("txn_status_cache_upsert_after_normal_before_large");

src/storage/txn/txn_status_cache.rs:1562

  • Using a fixed sleep duration to wait for threads to reach failpoints might be unreliable. Consider using a synchronization primitive (e.g., a barrier or a notification mechanism) to ensure both threads have reached the intended state before removing the failpoints.
thread::sleep(Duration::from_millis(300));

Signed-off-by: ekexium <eke@fastmail.com>
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 11, 2025
@cfzjywxk cfzjywxk requested a review from MyonKeminta April 14, 2025 02:04
Signed-off-by: ekexium <eke@fastmail.com>
@ekexium ekexium force-pushed the fix-txn-status-cache-deadlock branch from d5d0147 to c3d754d Compare April 14, 2025 06:32
@ekexium
Copy link
Contributor Author

ekexium commented Apr 15, 2025

/retest

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Apr 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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:
  • OWNERS [MyonKeminta,cfzjywxk]

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 Apr 15, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Apr 15, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-04-11 10:40:32.116857403 +0000 UTC m=+2425725.801093491: ☑️ agreed by cfzjywxk.
  • 2025-04-15 02:52:21.814386905 +0000 UTC m=+2743235.498623001: ☑️ agreed by MyonKeminta.

@ti-chi-bot ti-chi-bot bot merged commit 0b8c6bd into tikv:master Apr 15, 2025
8 checks passed
@ti-chi-bot ti-chi-bot bot added this to the Pool milestone Apr 15, 2025
@ti-chi-bot
Copy link
Member

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

ti-chi-bot bot pushed a commit that referenced this pull request Apr 16, 2025
…ML (#18385) (#18395)

close #18384

Fix the deadlock issue in txn_status_cache.
When both large_txn_cache and normal_cache needs locking, always acquire large_txn_cache first.

Signed-off-by: ekexium <eke@fastmail.com>

Co-authored-by: ekexium <eke@fastmail.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. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Deadlock in txn_status_cache with Pipelined DML

5 participants