Repository navigation
Conversation
With a UInt64 timestamp, sequenceNextNode stored each event time in a UInt32 (`NodeBase::event_time` was `DataTypeDateTime::FieldType`) and `add` narrowed it, so events were sorted, merged and serialized by `t mod 2^32`. A group whose events straddle a multiple of 2^32 (every ~49.7 days of a millisecond epoch) was misordered: (1700807049215, 'A'), (1700807049217, 'B') returned NULL instead of 'B' on 26.9.9.28 and master. The node now keeps the full UInt64 (still 32 bytes), and the UInt64 instantiation gets state version 1 at protocol revision 54494, following the scheme of `uniq` (fa37ee3): - version 1 is a flags byte (bit 0: the times carry only their low 32 bits) followed by the version 0 layout with 8-byte event times; - unversioned types keep the version 0 bytes, so persisted states and older peers are unaffected; a fresh state spells version 1 in its type and a fresh table gets it pinned at DDL time; - the version 0 writer of a full state sorts and prunes by the low 32 bits, so its bytes and its `sorted` mark are those of an older server; - a state read at version 0 is marked as truncated, and merging a full state with it truncates the full side first: such a merge orders like older servers, which is correct when a group fits in one 2^32 block; - a version 1 head/tail state also keeps the nodes the low 32-bit order would keep (skipped when all times are in one 2^32 block, where the two orders coincide), so a later merge with version 0 data gives the same result whether or not the state was serialized first; - the low 32-bit order breaks ties of equal low bits and value by the full time, so it does not depend on the order in which states arrive. Other timestamp types keep the unversioned state and identical bytes. Alternatives: widening only the in-memory value leaves distributed queries, spills and -State/-Merge truncating; changing the layout without a version breaks old parts and mixed-version clusters; rejecting timestamps >= 2^32 rejects documented input. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the version 1 dual-summary comment in sequenceNextNode serialize() to one line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 4 findings) plus my own review (3 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-self-slot-58:20261009-232900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-self-slot-57:20261009-215600 |
|
Workflow [PR], commit [6a70e4c] Summary: ❌
AI ReviewSummaryThe PR preserves full Version flow checked: Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block Preserve full timestamps through projection persistence and |
CI finish ledger - 7d673a4Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261010-060011 |
…uint64-timestamps Resolve the protocol revision conflict: master took 54494 (`DBMS_MIN_REVISION_WITH_MERGE_COMBINATOR_STATE_VERSION`) and 54495 (`DBMS_MIN_REVISION_WITH_INSERT_RETURNING`), so `DBMS_MIN_REVISION_WITH_SEQUENCE_NEXT_NODE_FULL_TIMESTAMPS` moves to 54496 and `DBMS_TCP_PROTOCOL_VERSION` to 54496. The native-protocol docs follow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
`ColumnAggregateFunction::updateHashFast` serialized the states without the
column's version, unlike `updateHashWithValue` and `computeHashInto`. A
`sequenceNextNode` state with `UInt64` timestamps written at version 0 keeps
only the low 32 bits of each event time, so two version 1 states that differ
only in the high bits hashed the same. The planner keys `IN` sets by the
constant's tree hash and the aggregate projection matcher compares `IN` sets
by content hash, so one set was reused for the other:
materialize(<state of (4294967297, 'A'), (2, 'B')>) IN (<state of (1, 'A'), (2, 'B')>),
materialize(<state of (4294967297, 'A'), (2, 'B')>) IN (<state of (4294967297, 'A'), (2, 'B')>)
returned `0 0` instead of `0 1`, and a projection grouping by membership in
one state was used for a query grouping by membership in the other.
Reported by the automated review on ClickHouse#125015.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 4ecf844Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261024-173006 |
…uint64-timestamps Master took protocol revision 54496 (`DBMS_MIN_PROTOCOL_VERSION_WITH_PROFILE_EVENTS_IN_SECONDARY_INSERT`), so `DBMS_MIN_REVISION_WITH_SEQUENCE_NEXT_NODE_FULL_TIMESTAMPS` moves to 54497 and `DBMS_TCP_PROTOCOL_VERSION` to 54497. The native-protocol docs (`format.mdx`, `protocol.mdx`) follow the new number; master's 54496 entries are kept as they are. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/Storages/System/CMakeFiles/clickhouse_storages_system.dir/StorageSystemChangelog.generated.cpp.o |
3.10 MiB | 4.00 MiB | +921.19 KiB (+29.02%) |
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionSequenceNextN… |
447.79 KiB | 500.45 KiB | +52.66 KiB (+11.76%) |
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units
128 translation units recompiled, 733 s compile time in total, 128 of them have a recent master baseline.
Symbol sizes
| Binary | Symbol | Master | PR | Δ |
|---|---|---|---|---|
programs/clickhouse |
DB::auto_changelog |
292.03 KiB | 371.81 KiB | +79.78 KiB (+27.32%) |
CI finish ledger - 1881890Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261108-203007 |
|
About the |
|
Fixing PR for the |
|
Fixing PR for the |
…uint64-timestamps Master took protocol revision 54497 for DBMS_MIN_REVISION_WITH_CURRENT_AGGREGATION_VARIANT_SELECTION_METHOD, so the sequenceNextNode full-timestamp revision moves to 54498 (and DBMS_TCP_PROTOCOL_VERSION with it); the native-protocol docs follow. Git merged ProtocolDefines.h without a conflict, which would have left both features on 54497. The new sequenceNextNode overrides get [[nodiscard]], as master's modernize-use-nodiscard now requires. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A backward/tail state with six nodes across a 2^32 boundary is sent at version 1 and merged with a version 0 state. The answer depends on the serialized state keeping the last nodes of the low 32-bit order: dropping them gives U, keeping the head's nodes instead gives Q, the legacy answer is R. Co-Authored-By: Claude Opus 5.5 <[email protected]>
std::iota deduces its counter type from the initial value, so the literal 0
made the counter a signed int while the vector holds size_t. A version 1
Head/Tail state with 2^31 or more nodes (add and merge do not cap the node
count, only deserialize does) would overflow the counter and store huge
indexes. Start the sequence at size_t{0}.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 6a70e4cEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The Session id: cron:our-pr-ci-monitor:20261124-063028 |
Related: #124812
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
sequenceNextNodewith aUInt64timestamp now orders events by the full timestamp instead of its low 32 bits, so groups whose timestamps cross a multiple of 2^32 (every ~49.7 days of millisecond epochs) return the correct next node. Its state gets version 1 with 8-byte event times; states written by older servers stay readable.Description
Found while working on #124812.
With a
UInt64timestamp,sequenceNextNodekept only the low 32 bits of each event time (NodeBase::event_timewasUInt32), so events were ordered byt mod 2^32:The in-memory event time is now
UInt64, and theUInt64instantiation gets state version 1 at protocol revision 54498, following theuniqscheme (#115393): a flags byte, then the old layout with 8-byte times. Unversioned types keep the old bytes, so existing tables and older peers read and write what they did. As withuniq, a new column is pinned to version 1, which older servers accept but write in the version 0 layout, so create such tables after every replica is upgraded. A state from version 0 data has only the low 32 bits; merging a full state with it drops the high bits of the full one, so such a merge orders like older servers (correct when a group fits in one 2^32 block). Version 1 head/tail states also keep the nodes the low 32-bit order would keep, so that result does not depend on where the state was serialized.ColumnAggregateFunction::updateHashFastnow hashes at the state version, so states that differ only in the high bits no longer share anINset or an aggregate projection. Other timestamp types are unchanged;windowFunnel,sequenceMatchandsequenceCountalready keep the full timestamp.Aggregate projections still store version 0 states and so still order by the low 32 bits: projection column types carry no state version, which already makes
quantileDeterministicanswer differently through a projection on released versions. That is a separate issue.Validation: the new test fails on master; mutating each mechanism reddens its line; 50 randomized runs pass; on-disk and
remote()checks against 26.9.9.28 pass in both directions.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125015]