tests: scope failpoint lock counts to each test's own keys (fixes #525, mitigates #516) - #551
tests: scope failpoint lock counts to each test's own keys (fixes #525, mitigates #516)#551eduralph wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughFailpoint transaction tests now generate keys in isolated bands and scope lock counting, polling, and cleanup to those bands or individual keys. Cleanup, async-commit, lock-resolution, and rollback assertions use bounded helpers. ChangesFailpoint lock assertions
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
🚥 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 |
5cc7b3f to
dde652f
Compare
|
@pingyu - ping for review |
|
How about prepend a distinct prefix to generated keys for each case, and scan locks in the range This solution would be more comprehensive. Test cases run in separated key ranges and there will be less interference with each other. |
dde652f to
76c7808
Compare
|
Thanks — good call. Each case now writes into its own disjoint band of the key space and scans (and cleans up) locks only within that band, so one case's residual locks can't be seen by another. One adjustment worth flagging: I started with a literal one-byte prefix as you suggested, but that confines all ~512 keys to Also rebased onto latest master (was conflicting after #550/#553). PTAL. |
There was a problem hiding this comment.
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 `@tests/failpoint_tests.rs`:
- Around line 178-186: Update the test cleanup after the scoped lock-count
assertion: disable the before-cleanup-locks failpoint, run real cleanup for this
test’s band, and assert the band-scoped lock count reaches zero before calling
scenario.teardown().
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: eb5449e1-6626-40bb-947e-4eb3f05c97d6
📒 Files selected for processing (1)
tests/failpoint_tests.rs
The txn_cleanup_* failpoint tests share one cluster and run serially, and they counted locks with a whole-keyspace scan. Async-commit locks resolve in the background and drain at an unpredictable rate, so a later test's unbounded scan would catch an earlier test's still-draining residue and over-count (flaky '575 vs 512'; tikv#525). txn_cleanup_locks_batch_size is the worst offender: it stubs resolution via before-cleanup-locks and leaves 512 async-commit locks behind. Fix, test-only. Give each lock-counting case its own disjoint band of the u32 key space and scope both its lock scans and its cleanup_locks calls to that band, so a neighbour's residual locks are never fetched or counted. Single-key tests scan only their own key. The bands are a large fraction of the key space rather than a one-byte prefix, so under MULTI_REGION each still spans several regions and the cross-region cleanup/retry paths these tests exist to exercise stay covered. - Partition the key space into NUM_KEY_BANDS bands; write_data generates keys inside a given band; count_locks_in_band / wait_for_locks_count_in_band scope the scans; count_locks_of_key scopes the single-key tests. - Scope every cleanup_locks call to the acting test's band (the batch-size test's resolved_locks assertion depended on this). - Drop the whole-keyspace helpers. Suite is stable across repeated runs locally, including MULTI_REGION=1; no client (src/) change. Signed-off-by: Eduard R. <eduard@ralphovi.net>
76c7808 to
3a73fcf
Compare
|
@pingyu — some concrete evidence that this PR helps with #516 (the CI timeouts), not only #525. #544's That drain-wait is This PR removes exactly that pattern: each lock scan becomes bounded to the test's own key band (~1/10 of the keyspace, hence far fewer regions per scan), so the drain-wait ( |
The
txn_cleanup_*failpoint tests count locks with a whole-keyspace scan (count_locks/wait_for_locks_countover..).txn_cleanup_locks_batch_sizestubs cleanup via thebefore-cleanup-locksfailpoint and leaves its locks in place — and since they're async-commit locks, they resolve in the background and drain at an unpredictable rate. A later serial test's unbounded scan then catches the still-draining residue and over-counts — the flaky575 vs 512/513 vs 512in #525.Fix (test-only)
count_locks_of/wait_for_locks_count_ofthat count only the caller's own keys, making the assertions immune to residual locks from other tests.txn_cleanup_*count assertions to the scoped variants.txn_cleanup_locks_batch_sizeresolve its own locks before returning, so it no longer seeds residue for the next serial test.No client (
src/) change.Fixes #525.
Scope note: this does not address #516 (the
txn_cleanup_2pc_locks600s timeout). An earlier revision of this description suggested it might, by removing residue that amplifiescleanup_locks— that reasoning was wrong:txn_cleanup_2pc_locksruns first in the serial suite (it is consistently reported as( 1/54 )), so no residue from the other cleanup tests can reach it. #516 is a separate, still-undiagnosed stall and is left untouched here.Testing
Ran the suite repeatedly against a local multi-region cluster (
MULTI_REGION=1, the aggressive-splitconfig/tikv.toml) — stable across 10+ runs at ~5s each; the previously-observed count drift does not recur.make checkclean.Summary by CodeRabbit