Skip to content

fix(clickhouse): keep IAM-role S3 test TTL within toDateTime range#4434

Merged
dtunikov merged 1 commit into
mainfrom
fix/clickhouse-raw-table-ttl-test-overflow
Jun 16, 2026
Merged

fix(clickhouse): keep IAM-role S3 test TTL within toDateTime range#4434
dtunikov merged 1 commit into
mainfrom
fix/clickhouse-raw-table-ttl-test-overflow

Conversation

@dtunikov

Copy link
Copy Markdown
Collaborator

Problem

connectors/clickhouse/TestIAMRoleCanIssueSelectFromS3 is failing on main (e.g. this run). It loads a 3-row Avro fixture into a raw table and asserts COUNT(*) == 3, but gets 0 — the rows are silently evicted by the table TTL.

Root cause

#4425 changed the raw-table TTL expression to wrap the timestamp in toDateTime():

TTL toDateTime(fromUnixTimestamp64Nano(_peerdb_timestamp)) + INTERVAL N DAY

toDateTime is a 32-bit type capped at 2106-02-07. The test deliberately sets PEERDB_CLICKHOUSE_RAW_TABLE_TTL_DAYS=36500 (100 years) because the fixture rows carry 2025 timestamps and the default 90-day TTL would otherwise evict them. With the old DateTime64 expression 2025 + 100y ≈ 2125 was fine; with toDateTime it overflows the 2106 ceiling and wraps to a past date, so the TTL evaluates as already-expired and ClickHouse drops the rows → COUNT(*) = 0.

The production default (90 days) never overflows, so this only affects the test's large override. The backward-compat toDateTime fix from #4425 is left intact.

Fix

Lower the test's TTL override from 36500 to 25000 days (~68y, lands around 2093), keeping it within the toDateTime range while still preventing eviction of the 2025 fixture rows. Added a comment explaining the 2106 ceiling.

🤖 Generated with Claude Code

TestIAMRoleCanIssueSelectFromS3 set PEERDB_CLICKHOUSE_RAW_TABLE_TTL_DAYS
to 36500 (100y) so the 2025-dated fixture rows wouldn't be evicted. After
#4425 wrapped the raw-table TTL expression in toDateTime() (a 32-bit type
capped at 2106-02-07), a 2025 base + 100y overflows that ceiling and wraps
to a past date, so ClickHouse evicted the rows immediately and COUNT(*)
returned 0 instead of 3.

Lower the test override to 25000 days (~68y, ~2093) so it stays within the
toDateTime range while still keeping the fixture rows.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@dtunikov
dtunikov requested a review from a team as a code owner June 16, 2026 09:24
@claude

claude Bot commented Jun 16, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@pfcoperez pfcoperez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nit comment on the need of going that far in the future. 10/20 years are well over 90s TTL while still within the product expected lifetime.

// Fixture rows have _peerdb_timestamp values from 2025; push the raw-table TTL far enough out that it doesn't
// evict them. The TTL expression wraps the timestamp in toDateTime() (a 32-bit type capped at 2106-02-07), so the
// 2025 base + INTERVAL must stay under that ceiling; 25000 days (~68y) lands around 2093, comfortably within range.
t.Setenv("PEERDB_CLICKHOUSE_RAW_TABLE_TTL_DAYS", "25000")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we just add 10 years?

@dtunikov
dtunikov merged commit af9170c into main Jun 16, 2026
16 checks passed
@dtunikov
dtunikov deleted the fix/clickhouse-raw-table-ttl-test-overflow branch June 16, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants