Skip to content

fix(storages): reject shared locks at disaggregated resolver#10900

Merged
ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
wfxr:enchance-shared-lock-tests
Jun 16, 2026
Merged

fix(storages): reject shared locks at disaggregated resolver#10900
ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
wfxr:enchance-shared-lock-tests

Conversation

@wfxr

@wfxr wfxr commented Jun 15, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: ref #10902 ref #10704

Problem Summary:

TiFlash read paths should treat shared locks as read-compatible and skip them before reporting locked errors. If a shared-lock wrapper reaches the disaggregated lock resolver, resolving it would hide an upstream invariant violation and could interpret invalid wrapper transaction fields as a real lock.

What is changed and how it works?

fix(storages): reject shared locks at disaggregated resolver

TiFlash read paths should skip shared locks before emitting locked errors. Treat a shared-lock wrapper at the disaggregated resolver as an invariant violation so it is not retried or resolved with invalid wrapper txn fields.

Keep ordinary lock conversion covered so existing lock-resolution behavior remains intact.

This PR documents the shared-lock test coverage design, rejects shared-lock wrappers at the two disaggregated lock resolver boundaries, and adds unit coverage for both ordinary lock conversion and shared-lock wrapper rejection.

Check List

Tests

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

Unit test:

release-linux-llvm/build-unit-tests-shared-lock/dbms/gtests_dbms --gtest_filter=StorageDisaggregatedHelpersTest.MakeLocksForDisaggResolve*'

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

None

Summary by CodeRabbit

Summary

  • Refactor

    • Standardized conversion of disaggregated lock information into lock objects used during lock resolution.
  • Bug Fixes

    • Improved locked-error handling for disaggregated reads with clearer “locked error” wording while retaining the same lock details for debugging.
  • Tests

    • Added unit tests covering lock conversion behavior (key/primary/transaction/TTL/lock type preservation) and verification that unsupported shared-lock inputs are rejected with a logical error.

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 15, 2026
@pingcap-cla-assistant

pingcap-cla-assistant Bot commented Jun 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Two inline helpers (makeLockForDisaggResolve, makeLocksForDisaggResolve) are added to StorageDisaggregatedHelpers.h to convert kvrpcpb::LockInfo protobuf objects into pingcap::kv::LockPtr objects, throwing LOGICAL_ERROR on SharedLock wrappers. Both disaggregated LockedError call sites in the remote and columnar paths are updated to use these helpers, and two unit tests verify the field-preservation and rejection behaviors.

Changes

Disaggregated Lock Resolution Guard

Layer / File(s) Summary
Lock-conversion helpers with SharedLock guard
dbms/src/Storages/StorageDisaggregatedHelpers.h
Adds includes for kvrpcpb.pb.h, pingcap/kv/LockResolver.h, Common/RedactHelpers.h, and standard library headers. Introduces makeLockForDisaggResolve that throws LOGICAL_ERROR on SharedLock wrappers and constructs pingcap::kv::Lock otherwise; makeLocksForDisaggResolve batches conversion over a RepeatedPtrField<LockInfo>.
Call-site updates in remote and columnar paths
dbms/src/Storages/StorageDisaggregatedRemote.cpp, dbms/src/Storages/StorageDisaggregatedColumnar.cpp
StorageDisaggregatedRemote.cpp replaces manual lock-vector construction with makeLocksForDisaggResolve and updates log wording from "retryable error" to "locked error"; StorageDisaggregatedColumnar.cpp replaces std::make_shared<pingcap::kv::Lock>(lock_info) with makeLockForDisaggResolve.
Unit tests for lock-conversion helpers
dbms/src/Storages/tests/gtest_disagg_remote.cpp
Adds include for kvproto/kvrpcpb.pb.h. Implements two StorageDisaggregatedHelpersTest cases: one verifies field preservation (key, primary, txn_id, ttl, lock_type) for a normal LockInfo, and one verifies LOGICAL_ERROR with "Unexpected SharedLock" message for a SharedLock-typed LockInfo.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Suggested reviewers

  • JinheLin
  • Lloyd-Pottiger
  • yongman

Poem

🐇 A SharedLock hops in, the code cries "No way!"
With LOGICAL_ERROR I send it away.
Two helpers now guard the lock-resolving gate,
Converting each LockInfo — none arrive late.
The tests hop in circles confirming it's right,
My burrow is safe through the disaggregated night! 🌙

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: rejecting shared locks at the disaggregated resolver, which is the core objective of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description is comprehensive and follows the required template structure with all major sections completed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/superpowers/specs/2026-06-15-enhance-shared-lock-tests-design.md`:
- Around line 17-18: The worktree paths in the TiFlash and Cloud Storage Engine
lines contain a spelling error where "enchance-shared-lock-tests" should be
"enhance-shared-lock-tests" (missing the 'a'). Correct this typo in both
worktree path lines to align with the correct specification naming and ensure
readers are directed to the proper paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9e88cf67-3f43-455d-8241-b8cb2ae136e8

📥 Commits

Reviewing files that changed from the base of the PR and between 50e6dea and 848420d.

📒 Files selected for processing (5)
  • dbms/src/Storages/StorageDisaggregatedColumnar.cpp
  • dbms/src/Storages/StorageDisaggregatedHelpers.h
  • dbms/src/Storages/StorageDisaggregatedRemote.cpp
  • dbms/src/Storages/tests/gtest_disagg_remote.cpp
  • docs/superpowers/specs/2026-06-15-enhance-shared-lock-tests-design.md

Comment thread docs/superpowers/specs/2026-06-15-enhance-shared-lock-tests-design.md Outdated
@wfxr wfxr force-pushed the enchance-shared-lock-tests branch from 848420d to 4de9ad5 Compare June 15, 2026 08:12
@ti-chi-bot ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 15, 2026
@wfxr wfxr force-pushed the enchance-shared-lock-tests branch from 4de9ad5 to a7f3e7c Compare June 15, 2026 08:48
@wfxr

wfxr commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

/retest

TiFlash read paths should skip shared locks before emitting locked
errors. Treat a shared-lock wrapper at the disaggregated resolver as an
invariant violation so it is not retried or resolved with invalid
wrapper txn fields.

Keep ordinary lock conversion covered so existing lock-resolution
behavior remains intact.

Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
@wfxr wfxr force-pushed the enchance-shared-lock-tests branch from a7f3e7c to 3944181 Compare June 15, 2026 09:04
@wfxr

wfxr commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

/retest

1 similar comment
@wfxr

wfxr commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

/retest

@JaySon-Huang

Copy link
Copy Markdown
Contributor

/test pull-unit-test

Comment thread dbms/src/Storages/StorageDisaggregatedHelpers.h Outdated
Include the rejected lock key and transaction metadata when a SharedLock
wrapper reaches the disaggregated resolver boundary. This keeps
invariant violations easier to diagnose without attempting to resolve
the wrapper.

Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
@wfxr wfxr requested a review from JaySon-Huang June 16, 2026 05:55

@JaySon-Huang JaySon-Huang 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.

LGTM

@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 16, 2026
@JaySon-Huang JaySon-Huang requested review from JinheLin and yongman June 16, 2026 06:41
@ti-chi-bot

ti-chi-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, yongman

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 [JaySon-Huang,yongman]

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 Jun 16, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

[LGTM Timeline notifier]

Timeline:

  • 2026-06-16 06:35:06.740228636 +0000 UTC m=+1460207.810546026: ☑️ agreed by JaySon-Huang.
  • 2026-06-16 06:47:55.25986837 +0000 UTC m=+1460976.330185760: ☑️ agreed by yongman.

@wfxr

wfxr commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

/retest

@ti-chi-bot ti-chi-bot Bot merged commit 044990a into pingcap:master Jun 16, 2026
11 checks passed
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.

3 participants