Repository navigation
Add stateless tests ported from the Cloud-only test suite - #110590
Conversation
These 8 tests exercise generic MergeTree/packed-storage/Dynamic-type behavior that does not depend on SharedMergeTree, Shared Catalog, or any other Cloud-only feature, but previously only existed in the Cloud fork's test suite. Verified against a local build (server + minio) with --no-random-settings before porting. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…tive format Reading a Native-format stream with a corrupted `num_types`/`num_dynamic_types` count close to SIZE_MAX made `std::vector::reserve` throw an uncaught std::length_error instead of a catchable DB::Exception, producing an unhelpful crash-like failure instead of an informative error. Convert that specific exception into `INCORRECT_DATA` with the reported count. Test ported from the Cloud-only test suite (verified failing without this fix, passing with it, against a local build). Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Workflow [PR], commit [1b47fac] Summary: ✅
AI ReviewSummaryThis PR ports several stateless tests from the Cloud-only suite and hardens Findings
Final Verdict
|
…thmetic `reserveOrThrowTooManyTypes` relied on `std::vector::reserve` throwing `std::length_error` to catch a corrupted `num_dynamic_types`. But the call site computed `num_dynamic_types + 1` before reserving, so a corrupted count equal to `SIZE_MAX` wraps around to `0` and bypasses the check entirely. Validate `num_dynamic_types` against `ColumnDynamic::MAX_DYNAMIC_TYPES_LIMIT` before the `+ 1`, and update the `04307_dynamic_flattened_too_many_types` V2 fixture to encode `SIZE_MAX` so it exercises exactly this case. Also add the `no-parallel` tag to `03057_private_attach_disk_web`, matching `03355_mergetree_table_disk` and `03823_table_disk_cache_key_collision`: without it, CI runs multiple copies of the test concurrently, which collide on the test's hardcoded table UUID (`TABLE_ALREADY_EXISTS` "UUID collision"). Drop `02790_packed_parts_refcount` and `04401_packed_skip_indices_concurrent_read_long`: packed part storage (`min_bytes_for_full_part_storage`) isn't wired up on master yet, so these currently don't exercise what they claim to, and both paths are already being ported together with the feature itself in #108118.
The previous commit's message described these changes, but a pathspec error in a batched `git add` silently dropped everything except the two test-file deletions from the staged diff.
|
CI notes on unrelated failures from the last run:
Also addressed in the latest push:
|
|
Follow-up on the |
|
Confirmed: #110664 covers this call site. The 'Current component is empty' abort came from 'zero_copy_lock''s dtor issuing the ephemeral-node release when a task is destroyed while still holding the lock (cancellation before the explicit unlock), running from generic background-task cleanup with no component scope. #110664 guards it in explicit destructors for both 'MutateFromLogEntryTask' (reported) and 'MergeFromLogEntryTask' (identical latent sibling), matching the 'DDLWorker::shutdown' / 'EphemeralNodeHolder' precedent and the #109297 / #98663 / #107266 class. Deferring to your PR, no separate one from us. |
|
Investigated and fixed in a separate PR: #110670. Root cause: Reproduced deterministically (s3 zero-copy RMT + |
A replicated zero-copy merge/mutate task owns the zero-copy exclusive lock via its std::optional<ZeroCopyLock> member. When the task is torn down on a MergeTreeBackgroundExecutor thread while the lock is still held, ~ZooKeeperLock issues Keeper requests (exists/remove) to release the ephemeral node. That teardown runs outside any component scope, so with enforce_keeper_component_tracking enabled the server aborts with "Current component is empty, please set it for your scope using Coordination::setCurrentComponent". The Keeper component is set at the highest level that owns the section doing those ZooKeeper requests: the MutateFromLogEntryTask / MergeFromLogEntryTask destructors. Each explicitly releases zero_copy_lock inside the guarded scope, because the member would otherwise be destroyed after the destructor body, outside the guard. Regression test 04546 pauses a mutation task on a new failpoint fired right after tryCreateZeroCopyExclusiveLock() succeeds, so the task provably holds the lock, then drops the table so the task is destroyed with the lock still held. Related: ClickHouse#110590
Address review (AI-review Major on #110590): the previous commits only closed the malformed-count bug for `Dynamic`. `SerializationObject::deserializeObjectStructureStatePrefix` still read the `flattened_paths` / `dynamic_paths` counts straight from an untrusted `Native` stream and passed them to `resize`, so a corrupted `JSON` / `Object` block near `SIZE_MAX` could still throw an uncaught `std::length_error` instead of a normal `DB::Exception`. Translate the `std::length_error` from those `resize` calls (and the nearby `shared_data_paths_statistics.reserve`) into a catchable `INCORRECT_DATA` error, mirroring the `Dynamic` fix. Add `04350_json_native_too_many_paths`, a companion to `04307_dynamic_flattened_too_many_types`, exercising both the `FLATTENED` and the non-flat path-count sites with hand-crafted corrupted `Native` fixtures. Update the `Native` format specification with the normative "malformed counts" contract for both `Dynamic` and `JSON`/`Object`.
|
Addressed the AI-review Request changes verdict from the previous run:
Also merged |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
…NAMIC_TYPES_LIMIT Addresses the AI-review Major on `docs/en/interfaces/specs/NativeFormat.md`: the "Malformed counts" note told a decoder to validate the flattened `Dynamic` `num_types` against `ColumnDynamic::MAX_DYNAMIC_TYPES_LIMIT`. That is wrong for the flattened layout: `flattenDynamicColumn` writes *every* distinct runtime type, including those that had overflowed into the shared variant, so a valid flattened block can legitimately list far more than the limit. A decoder built from that sentence would reject valid flattened streams. Clarify that the `MAX_DYNAMIC_TYPES_LIMIT` bound applies only to the non-flat `V1`/`V2`/`V3` `num_dynamic_types` (which counts regular-variant slots), matching what ClickHouse actually validates in `SerializationDynamic`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…own exception Addresses the AI-review Major on `SerializationObject.cpp`: the malformed-count helpers translated only `std::length_error` into `INCORRECT_DATA`. That is correct for `std::vector::resize`, but a hash table's `reserve` does not throw `std::length_error` for a corrupted `SIZE_MAX`-family count. `reserveOrThrowTooManyPaths` wraps `shared_data_paths_statistics.reserve` (an `UnorderedMapWithMemoryTracking`); on libc++ with ClickHouse's `AllocatorWithMemoryTracking` that path throws `std::bad_alloc`, on libstdc++ `std::bad_array_new_length`. The corrupted count therefore escaped as a non-`DB::Exception`. Replace the catch-based helpers with an up-front check that rejects a count the container cannot possibly hold (`> max_size()`) as `INCORRECT_DATA`, and additionally cap the `reserve` sizing hint so no representable count can overflow the bucket arithmetic or over-allocate -- independent of the standard library and allocator. A legitimate large count still grows the container on demand, and a corrupted count trips a normal read error in the loop that follows. Add gtest `ObjectSerialization.TooManySharedDataPathsStatistics`, which reaches the statistics `reserve` site with `object_and_dynamic_read_statistics` enabled (the MergeTree part read path, which the `Native` input format used by `04350_json_native_too_many_paths` never reaches) and asserts a clean `INCORRECT_DATA`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Addressed the AI-review Request changes verdict (both Majors + the Tests note):
Verified against a freshly built binary: the new gtest passes, |
|
📊 Cloud Performance Report ✅ AI verdict: This PR hardens Native-format and on-disk deserialization of JSON/Object/Dynamic columns against malformed path/type/bucket counts (plus docs and tests); it does not touch the SELECT execution path that ClickBench Q4 and Q15 exercise. Both queries show ~20% faster wall time but flat CPU time (Q4 2658.5→2683.4 ms, Q15 2607.1→2610.4 ms), and both land inside master's current variance band, so the deterministic gate correctly suppressed them as run-to-run variance. No real regressions or improvements attributable to this change. clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
|
The sync PR merges cleanly (
None touch |
The test is a heavy `long` test (10M-row insert, `OPTIMIZE FINAL`, then 51 full-column scans). The flaky check runs each changed test many times with high concurrency (18 workers), and under that load a single run of this test exceeds the 600s per-test timeout. It only surfaced in the merge queue: the test is tagged `no-tsan, no-debug, no-asan, no-msan`, so it was skipped in every flaky check of the pull-request run (all sanitizer/debug builds) and only actually ran in the merge queue's `amd_binary` (release) flaky check, where it timed out. `no-flaky-check` is the intended tag for heavy `long` tests that cannot be run concurrently many times within the per-test timeout; the test still runs normally in the regular stateless test runs. Merge queue report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=gh-readonly-queue/master/pr-110590-b702eb6e293229f8acad13801147208fa5101a03&sha=1ad06830742db2a6e2c9b89e17e3a7d1915de5ad&name_0=MergeQueueCI&name_1=Stateless%20tests%20%28amd_binary%2C%20flaky%20check%29 https://github.com/ClickHouse/ClickHouse/actions/runs/29651650653/job/88100774571 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…the Native spec The "Malformed counts" note in the FLATTENED `Object` section wrongly attributed a `flattened-paths` count to the non-flat `V1`/`V2`/`V3` encodings. Per `SerializationObject::deserializeObjectStructureStatePrefix`, only the `FLATTENED` prefix reads a flattened-paths count; the non-flat `V1`/`V2`/`V3` prefixes carry only the dynamic-paths count (plus a `max_dynamic_paths` value that `V1` reads and discards, and the `V3` shared-data metadata). A decoder written from the old sentence would look for a nonexistent field in non-flat streams and reject valid data. Split the sentence into the actual cases: `num_dynamic_paths` for the FLATTENED layout documented here, and the dynamic-paths count for the non-flat `V1`/`V2`/`V3` encodings. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
| /// Read the sorted list of dynamic paths. | ||
| /// Read the sorted list of dynamic paths (same append-on-demand handling as flattened paths). | ||
| size_t dynamic_paths_size = 0; | ||
| readVarUInt(dynamic_paths_size, *structure_stream); |
There was a problem hiding this comment.
Non-flat Object never legitimately serializes this many explicit dynamic paths. Once a JSON column reaches its max_dynamic_paths, overflow paths move into shared data instead, and the type-level hard cap for dynamic paths is DataTypeObject::MAX_DYNAMIC_PATHS_LIMIT (10000).
With the current code, a payload-backed corrupted count like 50000 is still accepted: deserializeBinaryBulkWithMultipleStreams later does column_object.setMaxDynamicPaths(dynamic_paths_size) and setDynamicPaths(...), so we materialize 50k Dynamic subcolumns instead of rejecting the stream as malformed. The capped reserve fixes the truncated-input OOM, but it still leaves this impossible non-flat V1/V2/V3 count outside the writer-side contract. Please reject dynamic_paths_size > DataTypeObject::MAX_DYNAMIC_PATHS_LIMIT up front and add a focused regression test for MAX_DYNAMIC_PATHS_LIMIT + 1.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 165/179 (92.18%) · Uncovered code |
Manual backport of the guard added in #110590 (commit `73641c7f1d1`). It cannot be cherry-picked, because that commit is an incremental rename of an earlier `throwIfTooManyBuckets` introduced by two predecessor commits which also change the path-count handling and `SerializationDynamic`, and neither of those is backported here. An `Object` V3 structure prefix carries the shared-data bucket count as a bare varint, and that count sizes the per-bucket reader state and `Columns` directly. A malformed `Native` block declaring `0` buckets therefore made `collectSharedDataFromBuckets` index an empty vector, and a count near `SIZE_MAX` escaped as a non-`DB::Exception` allocation failure. Reject anything outside `1 .. MAX_OBJECT_SHARED_DATA_BUCKETS` as `INCORRECT_DATA`, and point the writer-side setting caps at the same constant so the reader guard and the writer bound cannot drift. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Backport #110590 to 26.6: Validate the JSON/Object shared-data bucket count read from a stream
Backport #110590 to 26.3: Validate the JSON/Object shared-data bucket count read from a stream
Manual backport of the guard added in ClickHouse#110590 (commit `73641c7f1d1`). It cannot be cherry-picked, because that commit is an incremental rename of an earlier `throwIfTooManyBuckets` introduced by two predecessor commits which also change the path-count handling and `SerializationDynamic`, and neither of those is backported here. An `Object` V3 structure prefix carries the shared-data bucket count as a bare varint, and that count sizes the per-bucket reader state and `Columns` directly. A malformed `Native` block declaring `0` buckets therefore made `collectSharedDataFromBuckets` index an empty vector, and a count near `SIZE_MAX` escaped as a non-`DB::Exception` allocation failure. Reject anything outside `1 .. MAX_OBJECT_SHARED_DATA_BUCKETS` as `INCORRECT_DATA`, and point the writer-side setting caps at the same constant so the reader guard and the writer bound cannot drift. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…mLogEntryTask destructors Both tasks hold a `zero_copy_lock` (a `ZeroCopyLock` wrapping a `zkutil::ZooKeeperLock`) while performing a replicated mutation/merge with `allow_remote_fs_zero_copy_replication` enabled. The lock is released explicitly in `prepare()`/`finalize()` on the normal paths, but if the task is destroyed while still holding the lock -- e.g. on cancellation before that explicit unlock is reached -- the implicit destructor chain (`~MutateFromLogEntryTask`/`~MergeFromLogEntryTask` -> `~ZeroCopyLock` -> `~ZooKeeperLock` -> `unlock()`) issues a real ZooKeeper request to remove the lock's ephemeral node. That destructor chain runs from `MergeTreeBackgroundExecutor::routine`'s generic task cleanup, which has no Keeper component scope set. With `enforce_keeper_component_tracking=1` (as in integration tests and debug/ sanitizer builds), the request throws `LOGICAL_ERROR: Current component is empty, please set it for your scope using Coordination::setCurrentComponent`, which aborts the server. Add an explicit destructor to each task that resets `zero_copy_lock` under a `Coordination::setCurrentComponent` guard, following the precedent of `DDLWorker::shutdown` explicitly clearing `active_node_holders` under a guard rather than putting the guard in the shared, generic `ZooKeeperLock`/`ZeroCopyLock` destructor itself. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110590&sha=5695f5662ad462d511ecdd527cbfefcd51f46a37&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29 Related: ClickHouse#110590
Address review (AI-review Major on ClickHouse#110590): the previous commits only closed the malformed-count bug for `Dynamic`. `SerializationObject::deserializeObjectStructureStatePrefix` still read the `flattened_paths` / `dynamic_paths` counts straight from an untrusted `Native` stream and passed them to `resize`, so a corrupted `JSON` / `Object` block near `SIZE_MAX` could still throw an uncaught `std::length_error` instead of a normal `DB::Exception`. Translate the `std::length_error` from those `resize` calls (and the nearby `shared_data_paths_statistics.reserve`) into a catchable `INCORRECT_DATA` error, mirroring the `Dynamic` fix. Add `04350_json_native_too_many_paths`, a companion to `04307_dynamic_flattened_too_many_types`, exercising both the `FLATTENED` and the non-flat path-count sites with hand-crafted corrupted `Native` fixtures. Update the `Native` format specification with the normative "malformed counts" contract for both `Dynamic` and `JSON`/`Object`.
…y-tests-to-public Add stateless tests ported from the Cloud-only test suite
…ative `SerializationObject::deserializeObjectStructureStatePrefix` validates the V3 `shared_data_buckets` count read from the stream, but the only coverage is the gtest `ObjectSerialization.InvalidNumberOfSharedDataBuckets`, which drives the serialization directly rather than the `Native` reader. Add a stateless test that feeds crafted `Native` blocks through `format` and asserts the error code for each corner of the guard: `0`, `SIZE_MAX` and `257` are rejected as `INCORRECT_DATA`, while `256` - the maximum - passes the guard and fails only on the truncated payload. The structure is passed to `format` explicitly, otherwise schema inference wraps the error and the query reports `CANNOT_EXTRACT_TABLE_STRUCTURE` instead. The guard itself landed in ClickHouse#110590. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
PROTO: a V3 JSON/Object structure prefix read from a stream (Native input, the format() table function, a corrupted part) with a shared-data bucket count outside 1..256 -> the count sizes the per-bucket reader state unchecked. Effect in the production build a394e92: the backport's test 05059_json_native_invalid_shared_data_buckets kills the server (SIGABRT in collectSharedDataFromBuckets for a bucket count of 0, from one SELECT over format('Native', ...)) and passes on official 26.8.8.8, run on isolated servers (evidence/fix_ci_20260925/upstream_repro/corrected3/). The 26.3 backport takes only this guard from ClickHouse#110590 (a port of Cloud-only tests with several fixes); the other count guards of ClickHouse#110590 are backported separately. Its upstream test 03057_private_attach_disk_web reads a public S3 web disk and is no evidence either way. Upstream patch unchanged, with its test: 05059_json_native_invalid_shared_data_buckets. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…26.3 backport ClickHouse#117748) PROTO: a Dynamic or JSON/Object structure read from a stream (Native input, the format() table function, a corrupted part) with a type or path count near SIZE_MAX -> an uncaught std::length_error instead of a DB::Exception; with a large but representable count, a multi-GB up-front reserve before any type or path is read (OOM/DoS). Also the `num_dynamic_types + 1` wrap-around for SIZE_MAX. Effect in the production build a394e92: the upstream tests 04307_dynamic_flattened_too_many_types and 04350_json_native_too_many_paths fail on it and pass on official 26.8.8.8, run on isolated servers (evidence/fix_ci_20260925/upstream_repro/server_triage_PROD263_vs_UP2688.tsv). ClickHouse#110590 is an upstream port of Cloud-only tests that carries several fixes; its 26.3 (ClickHouse#117748) and 26.6 (ClickHouse#117743) backports take only the shared-data bucket guard. This commit adds its other guards unchanged: SerializationDynamic.cpp (flattened type count, V2 dynamic type count), SerializationObject.cpp (flattened and dynamic path counts; the helper joins the anonymous namespace that ClickHouse#117748 created; the fork keeps its own declarations there) and SerializationObjectSharedData.cpp (granule path and substream counts), with the upstream tests 04307 and 04350 and their four Native fixtures (blob ids equal to the upstream diff). The gtest and documentation changes of ClickHouse#110590 are not included. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… topology check for the open GROUP BY defect - stateless_tests.txt: +77 tests of the third batch and 10319 (13 pyarrow tests run outside the gate). - known_defects.json: +64 KD-UP entries (fixed, each naming its commit), now 145 entries, 1 open. Three entries use the tests their 26.3 backports carry instead of the upstream tests the triage had used: ClickHouse#108728 (26.3 has no CREATE OR REPLACE MATERIALIZED VIEW; 04492_create_or_replace_table_as_select_keeps_merges), ClickHouse#110590 (05059 aborts the production server; 04307/04350 with the separately backported guards; 03057 is external), ClickHouse#117536 (05055 and the fork test 10319; upstream 04401 also needs ClickHouse#108465). - KD-D512-MIXED-GROUPBY-NULLABLE stays open; its decision records the isolated validation of the replica-group upgrade topology and the rules it needs. It is not a rollout approval. - tools/replication/upgrade_topology_check.sh: that validation, vendored from the skill draft. - tools/upstream/triage_server_tests.py: a row whose test came from the upstream PR (the backport does not carry it) is classed `...-upstream-test` (a lead to review, not evidence); https URLs and web disks count as external. - VENDORED.sha256 and README (selection count, the mandatory mixed-version GROUP BY release check - the text still said it was not part of the gate - and the two tools). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds several stateless tests ported from the ClickHouse Cloud-only test suite, and hardens
Native-format deserialization ofDynamicandJSON/Objectcolumns against corrupted type/path count headers.One of the ported tests (
04307_dynamic_flattened_too_many_types) surfaced a real bug: reading aNative-format stream with a corruptednum_types/num_dynamic_typescount close toSIZE_MAXmadestd::vector::reserve/resizethrow an uncaughtstd::length_errorinstead of a normalDB::Exception.SerializationDynamicnow validates the count againstColumnDynamic::MAX_DYNAMIC_TYPES_LIMITbefore doing any arithmetic on it (so a corrupted count of exactlySIZE_MAXcan no longer wrap the+ 1around to0and slip past the check) and throwsINCORRECT_DATAwith the offending count. The same class of unchecked count inSerializationObject::deserializeObjectStructureStatePrefix(theflattened_paths/dynamic_pathssizes) is now translated into a catchableINCORRECT_DATAerror as well (04350_json_native_too_many_paths), and the officialNativeformat specification (docs/en/interfaces/specs/NativeFormat.md) is updated with the normative malformed-count contract.These tests were surveyed out of ~260 stateless and ~118 integration tests that exist only in the private/Cloud fork. Most of the remainder genuinely depend on Cloud-only features (
SharedMergeTree, Shared Catalog, server-side JWT, masking policies, the distributed cache, etc.) and were left out. Two packed-part-storage tests (02790_packed_parts_refcount,04401_packed_skip_indices_concurrent_read_long) were dropped from this PR: packed part storage isn't wired up on public master yet, so they don't currently exercise what they claim to, and both are already being ported together with the feature itself in #108118. A further ~12 tests looked plausible from reading the code but, once actually run against a local build, turned out to depend on things not yet in public master (asystem.parts.part_storage_typecolumn, thetimeSeriesIrateToGrid/timeSeriesIdeltaToGridaggregate functions, acloud_modevalidation check onremote_filesystem_read_method, and a few reference-value mismatches that need further investigation) — those are being tracked separately rather than included here to avoid landing red or under-verified tests.Each test in this PR was run against a freshly built binary (server + local minio where needed,
--no-random-settings --no-random-merge-tree-settings) and confirmed passing before being added.Related: #108118
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed reading a corrupted
Native-format stream whoseDynamictype count orJSON/Objectpath count is close toSIZE_MAX: such malformed input is now rejected with a clearINCORRECT_DATAerror instead of an uncaughtstd::length_error.Documentation entry for a feature (a user-readable short description of the changes that goes into user-facing documentation.md):
N/A
Version info
26.6.5.32,26.3.30.7