Repository navigation
Conversation
Limit the common prefix to the current user key when internal keys share bytes into the footer. The report in meta#15439 supplied this writer bound. Recover correct seeks in existing affected data and internal-key index blocks without rewriting SSTs. Retain boundary shortcuts when the target differs before the guaranteed user-key prefix; otherwise compare full keys. Cover footer overlap, legacy blocks, reopen, and compaction. Fixes meta#15439 Assisted-by: Codex
|
Hi @xgbtxy! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Summary
Fix stale values, missed keys, and deleted values reappearing when
ReverseBytewiseComparator()is used with format 8 common-prefix optimization.A non-restart internal key can share bytes with its predecessor beyond the end of its user key. The writer counted those footer bytes toward the block's common user-key prefix. A seek for the shorter key could then incorrectly skip its newest value or deletion. Thanks to @hanke580 for the reproducer, diagnosis, and writer-side correction in #15439.
The writer now bounds that shared length by the current user-key length. The reader also handles existing affected data blocks and internal-key index blocks by comparing full keys when prefix stripping is unsafe. It keeps the boundary shortcut when the target differs before the guaranteed user prefix: stored prefix length minus the eight-byte footer.
Compatibility and performance
No public API or serialized-format change is required, and existing SSTs can be read correctly without rewriting them. Format 7 and user-key index behavior are preserved.
Reverse internal-key targets that differ only within the final eight prefix bytes still require full-key search. In a same-runner A/B/A microbenchmark (128 keys, 69-byte common prefix, 200,000 seeks per repeat, three repeats), matching-key and early-mismatch timings stayed near baseline. The two tail-mismatch cases cost about 123/465 ns versus 40/21 ns for the repeated baseline. This is a measured legacy-read tradeoff, not a production throughput claim.
Testing
Linux x86-64, GCC 13.3, base
87d4427:Seekreaches the end.COERCE_CONTEXT_SWITCH=1: 100 runs of each new test, 400 passes, no failures or timeouts.make check: exit 0; 44,166 GTests pass, and all 1,054 native test/check jobs succeed. Source checks ran sequentially before the suite, following CI'sSKIP_FORMAT_BUCK_CHECKSarrangement. The Actions wrapper subsequently failed to parse Make's progress banner; the preserved native logs were revalidated.Validation record and underlying runs.
Fixes #15439.
AI assistance was used for implementation, test development, and investigation.