Repository navigation
Fix DBWithTTL reads of values written after 2038-01-19 - #37
Merged
alexey-milovidov merged 1 commit intoNov 29, 2026
Merged
alexey-milovidov merged 1 commit into
alexey-milovidov merged 1 commit into
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. Upstream report: meta#15826 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alexey-milovidov
approved these changes
Nov 29, 2026
alexey-milovidov
merged commit Nov 29, 2026
8a970a0
into
ClickHouse:ClickHouse/v11.8.1
1 check passed
gugulogs
pushed a commit
to gugulogs/ClickHouse
that referenced
this pull request
Nov 30, 2026
DBWithTTLImpl::SanityCheckTimestamp decoded the stored 4-byte creation
timestamp as int32_t, so every value written after 2038-01-19 was reported
as Corruption ("Timestamp < ttl feature release time!") on Get/MultiGet and
hit the assert in TtlIterator::value(). The writers store the low 32 bits of
the Unix time, which is valid as an unsigned value until 2106; the reader now
decodes it as uint32_t.
Fork PR: ClickHouse/rocksdb#37
Upstream: meta/rocksdb#15826
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DBWithTTLstores the low 32 bits of the current time after each value, which is correct as an unsigned value until 2106.DBWithTTLImpl::SanityCheckTimestampread it back asint32_t, so from 2038-01-19T03:14:08Z every read of a newly written value fails:GetandMultiGetreturnCorruption: Error: Timestamp < ttl feature release time!,KeyMayExistreturns false, andTtlIterator::value()fails its assert in debug builds. Expiry by the compaction filter was not affected.This reads the timestamp as
uint32_t. The on-disk format does not change, and values already written after 2038 become readable.ClickHouse's
EmbeddedRocksDBusesDBWithTTLwhen a table has a TTL;02416_rocksdb_delete_updatefails this way with the clock shifted past 2038 (ClickHouse/ClickHouse#135354).Tests: two new cases in
utilities/ttl/ttl_test.ccuse the existing mock clock. Without the fix,ReadAfterYear2038passes att=2147483647and fails att=2147483648, andCompactionAfterYear2038fails reading a fresh value; with it, all 25ttl_testcases pass (Debug, gcc 13).Not changed:
TtlIterator::ttl_timestamp()also returnsint32_t; onlyldbuses it, and ClickHouse does not buildldb.Upstream report: meta#15826
Note
Low Risk
Small, localized type fix on read-path validation with new regression tests; no format or compaction semantics change.
Overview
Fixes DBWithTTL reads failing once system time passes the 32-bit signed boundary (2038-01-19). TTL values store the low 32 bits of Unix time as an unsigned field;
SanityCheckTimestampwas decoding and comparing that suffix asint32_t, so newly written values looked “below”kMinTimestampandGet,MultiGet,KeyMayExist, and iterators returned corruption or misses. The on-disk format is unchanged—decoded timestamps are nowuint32_twith an unsigned compare.Adds
ReadAfterYear2038(mock clock at 2037/2038/2039 exercises put/read paths) andCompactionAfterYear2038(expired keys still drop after compaction post-2038).Reviewed by Cursor Bugbot for commit f004392. Bugbot is set up for automated code reviews on this repo. Configure here.