Bypass locks invisible to read snapshot (#243) - #244
Conversation
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthrough
ChangesRead lock bypass and scan propagation
Mock TiKV test readiness
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Snapshot
participant Scanner
participant LockResolver
participant TxnStatus
Snapshot->>Scanner: request scan batch
Scanner->>LockResolver: resolveLocks(for_write=false)
LockResolver->>TxnStatus: evaluate transaction status
TxnStatus-->>LockResolver: return bypass eligibility
LockResolver-->>Scanner: return pushed timestamps
Scanner->>Scanner: add resolved-lock timestamps to scan context
Scanner-->>Snapshot: return scan results
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
/test pull-build-test |
|
@windtalker: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn 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. |
|
/ok-to-test |
|
/test pull-build-test |
|
@windtalker: No presubmit jobs available for tikv/client-c@master DetailsIn 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. |
|
/retest |
| if (!for_write && canBypassLockForRead(status, caller_start_ts)) | ||
| { | ||
| pushed.push_back(lock->txn_id); | ||
| break; |
There was a problem hiding this comment.
The lock will not be resolved, so it must be put into resolved_locks to skip it in tikv. However the scanner doesn't use the returned pushed?
There was a problem hiding this comment.
In client-c, pushed will be treated as min_commit_ts_pushed in
client-c/src/coprocessor/Client.cc
Lines 723 to 727 in 6b91f49
And min_commit_ts_pushed wil be added to add_resolved_locks when constructing request
client-c/src/coprocessor/Client.cc
Lines 705 to 708 in 6b91f49
There was a problem hiding this comment.
I mean here
Lines 95 to 96 in 6b91f49
There was a problem hiding this comment.
Good catch. Scanner missed this path. Fixed it by adding returned pushed into snap.min_commit_ts_pushed after resolving scan response locks, and by adding snap.min_commit_ts_pushed to ScanRequest.context.resolved_locks on retry. Also added a scanner regression test for the committed-after-read case.
Test added |
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
fe5182d to
d667e41
Compare
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
|
/retest |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ekexium, gengliqi The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
2 similar comments
|
/retest |
|
/retest |
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
ci/build-test.sh (2)
32-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer graceful termination over
kill -9.Using
kill -9(SIGKILL) as a first resort is generally discouraged because it prevents the process from cleaning up resources, temporary files, or child processes. Consider using a standardkill(SIGTERM) to allowmock-tikvto shut down gracefully.♻️ Proposed refactor
mock_kv_pid="" cleanupMockTiKV() { if [ -n "$mock_kv_pid" ]; then - kill -9 "$mock_kv_pid" 2>/dev/null || true + kill "$mock_kv_pid" 2>/dev/null || true fi } trap cleanupMockTiKV EXIT🤖 Prompt for 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. In `@ci/build-test.sh` around lines 32 - 38, Update cleanupMockTiKV to send the default graceful termination signal with kill instead of forcing SIGKILL, while preserving the existing PID check, suppressed errors, and EXIT trap.
48-48: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winEnsure the script fails if
mock-tikvis not ready.If
set -eis not active in this script, callingwaitForMockTiKVand having it return1will not stop the script. The tests would then run (and fail) against a missing mock server. Explicitly handling the failure makes the intent clear and ensures a fast failure in CI.♻️ Proposed refactor
-waitForMockTiKV +waitForMockTiKV || exit 1🤖 Prompt for 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. In `@ci/build-test.sh` at line 48, Update the call to waitForMockTiKV in the build-test script to explicitly stop execution when it returns a nonzero status, ensuring tests do not run unless mock-tikv is ready.
🤖 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.
Nitpick comments:
In `@ci/build-test.sh`:
- Around line 32-38: Update cleanupMockTiKV to send the default graceful
termination signal with kill instead of forcing SIGKILL, while preserving the
existing PID check, suppressed errors, and EXIT trap.
- Line 48: Update the call to waitForMockTiKV in the build-test script to
explicitly stop execution when it returns a nonzero status, ensuring tests do
not run unless mock-tikv is ready.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e3ef9f4b-61b4-4fc1-b239-731dcaa27a59
📒 Files selected for processing (3)
ci/build-test.shsrc/kv/Scanner.ccsrc/test/lock_resolve_test.cc
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
This pr cherry pick #243 to master branch
Summary by CodeRabbit