Repository navigation
Add a differential fuzzer for data lake tables written by foreign tools - #128295
Conversation
`tests/integration/helpers/foreign_writer_fuzz` generates seeded random histories of appends, overwrites, row-level deletes, updates, merges, schema and partition evolution, compaction and snapshot expiry, executes them with Spark Iceberg, PyIceberg through a REST catalog, Spark Delta, delta-rs, Spark Hudi, Spark Paimon, and ClickHouse writing Iceberg and Delta, and after each step checks that ClickHouse returns exactly what the writer's own reader returns (content, counts, aggregates, random filtered reads, time travel). Open ClickHouse bugs are gated in `known_issues.py` so that the PR run stays green. `test_datalake_foreign_writer_fuzz` runs it with a small budget per PR (one fixed seed, six operations and 30 s per writer); `FOREIGN_WRITER_FUZZ_*` environment variables configure a long fuzzing run or a replay. Ported from ClickHouse/clickhouse-private#84109, with the ruff `F401` failures of its style check fixed, black formatting applied, and the Spark session stopped at module teardown.
|
Workflow [PR], commit [5eb26fd] Summary: ✅ AI ReviewSummaryAdds a seeded differential fuzzer for data lake interoperability and runs it in nightly jobs. Request changes: detected server failures can lose their saved history during shrinking, and the supplied replay commands cannot reliably load their input. Findings
Missing context / blind spots
Tests
Final Verdict |
The `amd_msan` run aborted the server on the `throw_on_match` masking rule: `deltaLake` is not compiled in without `delta-kernel-rs` (no Rust in MSan builds), so its secret arguments have no spec, and the statement was logged with the MinIO secret before `UNKNOWN_FUNCTION` was thrown (#128372). Take the credentials of `deltaLake`, `hudi`, `icebergS3` and the `DeltaLake` engine from the `s3` named collection of `configs/config.d/named_collections.xml`, as the Paimon and ClickHouse Iceberg writers already do, so that no secret is in the query text. `DataLakeCatalog` takes no named collection and keeps positional credentials, which its registered spec masks. Skip the writers that need a table function the server does not have (the Delta Lake writers in MSan builds). CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=128295&sha=106b0b8b1aa1368ac22dc8361e39cde0d55b73d8&name_0=PR&name_1=Integration%20tests%20%28amd_msan%2C%20targeted%29 PR: #128295
- `LType.canon`: match struct fields by name for dict and `Row` values instead of by position, so swapped field values are detected. - `_check_aggregates`: use `minOrNull`/`maxOrNull` instead of overwriting every NULL expectation, so all-NULL nullable columns stay checked. - `_check_time_travel`: choose the historical snapshot in the order snapshots were taken, not by sorted runtime IDs, so the choice is reproducible on replay and while shrinking. - `run_history`: check the server log and liveness after a rejected ClickHouse write and after the last operation, so a write that kills the server is reported. - `shrink`: keep intermediate checks for any failure raised during a time-travel read, including `query_error`. - `temp_view`: make it a context manager that drops the Spark temp view after the operation. - `server_alive`: bound the health probe with a 10 s timeout.
… job The foreign-writer fuzzer is now a standalone tool under `tests/datalake_fuzzer/` (the library `foreign_writer_fuzz/`, the pytest driver `test_fuzz.py` and its cluster fixture) on top of the integration test harness, instead of an integration test module. It no longer runs in PR integration jobs. It runs in the `NightlySQLancer` workflow next to SQLancer and SQLancer++, as `Data lake fuzzer (arm_release)` and `Data lake fuzzer (arm_asan_ubsan)`: `ci/jobs/datalake_fuzzer_job.py` starts docker-in-docker in the integration test runner image, prefetches the MinIO and Iceberg REST catalog images, and runs every writer with random seeds, 20 operations per history and 20 minutes per writer. The job is not cached, since every run draws new seeds. Server logs and the minimal failing histories are attached as `datalake_fuzzer_logs.tar.zst`. `--param` overrides the budget; a comma that is not followed by `KEY=` stays in the value, so `FOREIGN_WRITER_FUZZ_WRITERS=a,b` works. The replay command in a failure report points to the new job. Related: #128295
| shrunk = shrink( | ||
| ctx, failing, result.failure, time.monotonic() + BUDGET.shrink_seconds | ||
| ) | ||
| report = failure_report(result, ctx.cluster.instances_dir, shrunk) |
There was a problem hiding this comment.
When a later ClickHouse write terminates the server, run_history correctly returns a server failure, but this call immediately tries another history against the unavailable server. For ClickHouseIcebergWriter, the next create raises ClickHouseQueryError; creation is outside the operation-level exception handler in run_history, so the exception escapes shrink before failure_report saves anything. The detected failure loses its replay JSON and detailed report, and pytest reports the subsequent connection error instead.
I reproduced this through the current runner and driver with two writes: the first step was checked, the second terminated the simulated server, and shrinking raised with zero calls to failure_report. Persist the original failure before shrinking, and skip shrinking when the server is unavailable.
| def test_replay(fuzz_context): | ||
| with open(BUDGET.replay) as f: | ||
| history = json.load(f) |
There was a problem hiding this comment.
failure_report saves the history under cluster.instances_dir and prints a replay command pointing there. However, pytest initializes fuzz_context before reaching this open, and its ClickHouseCluster constructor deletes that same directory (helpers/cluster.py:1148–1149). Following the generated replay command therefore deletes its input and ends with FileNotFoundError. I verified that the JSON created by the current report generator disappears when the constructor's cleanup runs.
The README's alternative of moving the history to ci/tmp/... also fails: the job runs pytest with cwd=FUZZER_DIR, so this relative open looks under tests/datalake_fuzzer/ci/tmp/.... Resolve repository-relative paths and load the history before constructing the cluster, or otherwise preserve the input outside the directory being cleared.
A seeded, reproducible differential fuzzer for data lake tables written by other tools and read by ClickHouse, and for tables ClickHouse writes for other tools. It targets the class of bugs behind #114933, #113676, #114994, #113360, #113324, #114350, #114848 and #114854: ClickHouse silently returning different data than the writer, or failing on a table shape the writer produces.
A standalone tool under
tests/datalake_fuzzer/(README there): the libraryforeign_writer_fuzz/and a pytest drivertest_fuzz.pyon top of the integration test harness, one ClickHouse node, MinIO and the Iceberg REST catalog container, one Spark session for all formats. It is not part of the integration test suite and does not run in PRs. Only public images and the libraries already in the integration runner image (pysparkwith the Iceberg, Delta, Hudi and Paimon jars,pyiceberg,deltalake) are used.How it works:
IcebergS3(read back by PyIceberg and Spark) andDeltaLake(read back by delta-rs and Spark).icebergS3,DataLakeCatalog,deltaLake,hudi,paimonS3, the engine tables) must match the writer's own read: full row multiset,count()with and without the trivial count, per-columncount/min/max, rows and counts under random predicates withNOT/AND/OR/IN/BETWEEN/IS NULLevaluated in Python with three-valued logic, and time travel to a live older snapshot. Each query uses a random variant of the read settings (pruning, manifest statistics, Parquet push-down, Delta engine predicate, query condition cache,max_threads,max_block_size). The server log is checked for<Fatal>, logical errors and sanitizer reports after each step.known_issues.py, so the nightly run reports only new bugs and every other check stays strict;FOREIGN_WRITER_FUZZ_KNOWN_ISSUES=1opens them.It runs in the
NightlySQLancerworkflow next to SQLancer and SQLancer++, asData lake fuzzer (arm_release)andData lake fuzzer (arm_asan_ubsan)(ci/jobs/datalake_fuzzer_job.py, integration test runner image with docker-in-docker): random seeds, 20 operations per history, 20 minutes per writer (checked between operations), up to 300 s of shrinking per distinct failure, 4 h job timeout. The job is not cached, since every run draws new seeds. Server logs and the minimal failing histories are attached asdatalake_fuzzer_logs.tar.zst. The budget is overridden with--param(FOREIGN_WRITER_FUZZ_BASE_SEED,FOREIGN_WRITER_FUZZ_SEEDS,FOREIGN_WRITER_FUZZ_OPS,FOREIGN_WRITER_FUZZ_TIME_BUDGET,FOREIGN_WRITER_FUZZ_WRITERS,FOREIGN_WRITER_FUZZ_REPLAY), e.g.python -m ci.praktika run "Data lake fuzzer (arm_release)" --workflow NightlySQLancer --param FOREIGN_WRITER_FUZZ_WRITERS=spark_iceberg,spark_delta,FOREIGN_WRITER_FUZZ_TIME_BUDGET=300. A local run with a small budget (2 seeds, 8 operations, 60 s per writer) took 4 minutes 7 seconds for the 8 writers including cluster start, all green.Bugs found while developing it (on master 26.11.1.1329, none fixed here; details and repros in the README, issues not filed yet, so the gates in
known_issues.pycarry placeholders):DATEis read asDate, so dates before 1970 fail withVALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE(Iceberg and Delta useDate32).ROWcolumns make the table unreadable:Unsupported Paimon type: ROW.ALTER TABLE ADD COLUMNSis not visible until the next snapshot (UNKNOWN_IDENTIFIER), Spark already returns the column.RENAME COLUMNfollowed byMERGE INTO: the rewritten rows read NULL in the renamed column.schemafield; PyIceberg cannot open the table.Boolcolumn (Unsupported type for iceberg Bool).insert_overwrite_tableare still read (Hudi: replaced file groups are read after insert_overwrite / clustering —replacecommitis ignored, returning duplicate and resurrected rows #123954), and a blank string Paimon partition value is looked up underc=(Paimon partition dir misspelled for blank strings, floats, legacy-name=false #127547).Related: #123954
Related: #127545
Related: #127547
Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/128295]
Version info
26.11.1.1038-master(included in26.11and later)