Repository navigation
Conversation
`AppendTS` and `TtlMergeOperator` store the low 32 bits of the current time, which is correct as an unsigned value until 2106. `SanityCheckTimestamp` read it back as `int32_t`, so from 2038-01-19T03:14:08Z every stored timestamp is negative and below `kMinTimestamp`: `Get` and `MultiGet` return `Corruption: Error: Timestamp < ttl feature release time!`, `KeyMayExist` returns false, and `TtlIterator::value()` fails its assert in debug builds. Read the timestamp as `uint32_t`. The on-disk format does not change, and values already written after 2038 become readable. Fixes meta#15826 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hi @groeneai! 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:
DBWithTTLappends the low 32 bits of the current time to each value (AppendTS,TtlMergeOperator), which is valid as an unsigned value until 2106.DBWithTTLImpl::SanityCheckTimestampdecodes it asint32_t, so from 2038-01-19T03:14:08Z every newly written value fails thekMinTimestampcheck:GetandMultiGetreturnCorruption: Error: Timestamp < ttl feature release time!,KeyMayExistreturns false, andTtlIterator::value()fails its assert in debug builds. Expiry in the compaction filter (IsStale) is not affected.This decodes the timestamp as
uint32_t. The on-disk format does not change, and values already written after 2038 become readable.Not changed:
TtlIterator::ttl_timestamp()also returnsint32_t; onlyldbuses it.Fixes #15826. The same change is in ClickHouse's RocksDB fork (ClickHouse#37), where
EmbeddedRocksDBtables with a TTL hit this with the clock shifted past 2038.Test Plan:
Two new tests in
utilities/ttl/ttl_test.ccuse the existing mock clock. Without the fix,TtlTest.ReadAfterYear2038passes att=2147483647and fails att=2147483648, andTtlTest.CompactionAfterYear2038fails reading a fresh value. With the fix, all 28ttl_testcases pass (Debug, gcc 13) and the two new tests pass 5 times in a row. clang-format 21.1.2 reports no changes, andbuild_tools/check-sources.shpasses.