Skip to content

Fix CompareDbtEndpoints crash with timestamp-aware comparators (#14601)#14611

Closed
laurynas-biveinis wants to merge 1 commit intofacebook:mainfrom
laurynas-biveinis:range-lock-udt-fix
Closed

Fix CompareDbtEndpoints crash with timestamp-aware comparators (#14601)#14611
laurynas-biveinis wants to merge 1 commit intofacebook:mainfrom
laurynas-biveinis:range-lock-udt-fix

Conversation

@laurynas-biveinis
Copy link
Copy Markdown
Contributor

Summary:
RangeTreeLockManager::CompareDbtEndpoints() called Comparator::Compare() on range lock endpoint keys that never contain user-defined timestamps. With a timestamp-aware comparator (timestamp_size() > 0), this caused assertion failures in debug builds and silent endpoint misordering in release builds.

Replace Compare() with the 4-argument CompareWithoutTimestamp() using a_has_ts=false, b_has_ts=false, which is the correct contract for serialized range lock endpoints (format: [1-byte suffix][key bytes], no timestamp).

Test Plan:

  • New test RangeLockWithTimestampComparator reopens with BytewiseComparatorWithU64Ts and exercises range lock acquisition, conflict detection, and non-overlapping success with short keys.
  • Verified RED (assertion failure) before fix, GREEN after.
  • Full range_locking_test suite passes (16/16).
  • Stress tested with COERCE_CONTEXT_SWITCH=1 --gtest_repeat=5.

…ook#14601)

Summary:
`RangeTreeLockManager::CompareDbtEndpoints()` called `Comparator::Compare()`
on range lock endpoint keys that never contain user-defined timestamps.
With a timestamp-aware comparator (`timestamp_size() > 0`), this caused
assertion failures in debug builds and silent endpoint misordering in
release builds.

Replace `Compare()` with the 4-argument `CompareWithoutTimestamp()` using
`a_has_ts=false, b_has_ts=false`, which is the correct contract for
serialized range lock endpoints (format: `[1-byte suffix][key bytes]`,
no timestamp).

Test Plan:
- New test `RangeLockWithTimestampComparator` reopens with
  `BytewiseComparatorWithU64Ts` and exercises range lock acquisition,
  conflict detection, and non-overlapping success with short keys.
- Verified RED (assertion failure) before fix, GREEN after.
- Full `range_locking_test` suite passes (16/16).
- Stress tested with `COERCE_CONTEXT_SWITCH=1 --gtest_repeat=5`.
@meta-cla meta-cla Bot added the CLA Signed label Apr 14, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Apr 14, 2026

@laurynas-biveinis has imported this pull request. If you are a Meta employee, you can view this in D100775201.

@github-actions
Copy link
Copy Markdown

✅ clang-tidy: No findings on changed lines

Completed in 48.0s.

@xingbowang
Copy link
Copy Markdown
Contributor

/claude-review

@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Apr 15, 2026

@laurynas-biveinis merged this pull request in 94b6566.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants