Repository navigation
Conversation
|
Hi @tavplubix, Could I kindly request a review on this PR? This addresses a silent data loss scenario: when a TTL expression like day + toIntervalDay(46000) overflows the Date (UInt16) range, the result wraps around to a past date, causing ClickHouse to treat all rows as expired and delete them during merge — with no warning at all. This has already caused real data loss for production users. The user's intent was to retain data longer, but the system silently deleted everything. The fix is minimal and low-risk: it evaluates the TTL expression a second time using widened types (Date32/DateTime64) and raises an error if the results diverge — stopping the deletion before any rows are removed. Normal (non-overflowing) TTL paths are completely unaffected. Thanks you for your time! |
|
Does this PR fix #101763? |
You're right, it's a duplicate — I'll close this one. Thanks! |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Why this matters: silent data loss
When a user writes TTL day + toIntervalDay(46000), their intent is clear: "keep data for ~126 years." However, because Date is backed by UInt16 (max representable year: 2149), the addition silently wraps around to a past date. ClickHouse then concludes "all data has expired" and silently deletes everything.
The user wanted data to live longer; the system deleted all of it. The outcome is the exact opposite of the intent.
Prevent silent data deletion when TTL expressions overflow
Date/DateTimerange. Previously,Date + toIntervalDay(large_number)silently wrapped around due toUInt16arithmetic, corrupting part min/max TTL metadata and causing entire parts to be dropped during merge. The fix detects overflow by evaluating the TTL expression with widened types (Date32/DateTime64) and throws an error if the results differ.Documentation entry for user-facing changes
When a TTL expression such as
day + toIntervalDay(46000)overflows theDate(UInt16) range, ClickHouse now throws aVALUE_IS_OUT_OF_RANGE_OF_DATA_TYPEerror instead of silently corrupting TTL metadata. Users should either reduce the interval or use wider column types (Date32/DateTime64) in their TTL expressions.