Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 3 min read Opinion mediumAdept

Decorating a Christmas Tree With the Help Of Flaky Tests

ClickHouse treats flaky tests as bugs to investigate rather than noise to mute or retry, and deliberately makes tests flakier to surface hidden issues. Its practices include randomizing the environment on every run, running new tests 100 times before merge, using new tests as a fuzzing corpus, injecting random sleeps and core switches around mutex operations, and running in parallel on slow machines. Results of all test runs, nearly 1.8 billion records and 5–9 million runs per day, are stored in ClickHouse itself. A 561-day by 3772-test pass/fail pixel map of the stateless functional tests, rendered by JavaScript querying ClickHouse directly, forms a 'Christmas tree' where horizontal red lines mark flaky tests and vertical red lines mark days master was broken.

Assumes: CI test pipelinessanitizers (ASan/TSan)

Related posts

  • Fuzzing ClickHouse

    ClickHouse mediumAdept

    ClickHouse's AST-based query fuzzer takes SQL queries from the regression test suite, parses them, and randomly mutates the AST. It swaps in bad numeric values such as NaN and integer limits, perturbs strings and arrays, and splices function arguments, expressions and tables from other test queries. The core is about 700 lines of C++ and has found more than 200 bugs, including segfaults and logic errors. Much of that comes from pairing it with assertions, a distinct LOGICAL_ERROR exception for internal bugs, and clang sanitizers. In CI it weights permutations toward new tests in pull requests and needs settings constraints, since it once disabled its own execution-time limit.

  • Fuzzing collaboration with WINGFUZZ - Part 1

    ClickHouse easyNovice

    WINGFUZZ, a DBMS fuzzing engine, found eight new bugs in ClickHouse, some introduced only four months earlier, using two techniques. Grammar-free mutation builds a metadata graph from built-in SQL tests, reshuffles statements, and fixes semantic errors by metadata-guided substitution (Griffin). Type-affinity sequence generation uses coverage feedback to learn which SQL statement-type pairs matter and builds new sequences around them. ClickHouse is now integrating WINGFUZZ into its daily testing.

  • Testing the Performance of ClickHouse

    ClickHouse mediumAdept

    ClickHouse catches performance regressions in CI by running the reference and patched servers side by side on the same machine and alternating about 3000 end-to-end test queries between them. This cancels out environmental systematic errors. A non-parametric bootstrap on the difference of median run times yields a noise threshold T, and a change is flagged only when it exceeds both T and 5%. Queries with T of 10% or more are marked unstable. Regressions are investigated with the built-in sampling profiler (system.trace_log), differential flamegraphs, ProfileEvents and hardware counters, while historical results stored in ClickHouse help locate when a change was introduced. Keeping false positives low matters more than producing a green check, and many test queries turned out to measure nothing meaningful.

  • BuzzHouse: Bridging the database fuzzing gap for testing ClickHouse

    ClickHouse mediumAdept

    BuzzHouse is a new ClickHouse fuzzer that generates complex but mostly semantically valid SQL backed by a tracked catalog of tables, filling a gap left by SQLsmith, SQLancer, the AST fuzzer and WINGFUZZ. It has found about 100 new issues. Correctness is checked by dumping and re-reading tables, comparing equivalent queries via SQLancer-style oracles, re-running queries under different settings, and comparing results against another relational database. The design tradeoffs covered include valid versus random identifiers, why coverage-guided fuzzing was skipped, and how statement probabilities (e.g. DROP frequency) shape what the fuzzer can reach.

  • How well is ClickHouse tested? A detailed view of increasing our own coverage

    ClickHouse mediumAdept

    ClickHouse's ~2.6M-line C++ codebase reaches 91.8% line, 81.0% branch and 91.8% function coverage, measured with Clang source-based coverage across 23 CI shards every 3 hours and published at coverage.clickhouse.com. Basic blocks, edges and the two Clang instrumentation modes (SanitizerCoverage vs. source-based) are explained, along with the profraw → profdata → llvm-cov pipeline and the continuous-mode trick that keeps profiles from servers that tests kill on purpose. An AI agent in ClickGap finds stable zero-hit gaps and writes guarded, flakiness-checked tests, merging 16 PRs that cover about 5,600 new lines. Per-test line coverage stored in CIDB (about 36B rows) drives test selection, so expensive sanitizer jobs run only the tests that touch changed code.

The quest for software engineering knowledge.

Look:
Layout: