Skip to content

Re-enable SQLancer in CI - #98390

Merged
alexey-milovidov merged 61 commits into
masterfrom
fix-sqlancer-ci
May 12, 2026
Merged

alexey-milovidov merged 61 commits into
masterfrom
fix-sqlancer-ci

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Mar 1, 2026 •

Copy link
Copy Markdown
Member

Re-enable the SQLancer job in master and PR CI workflows. SQLancer was disabled after #81835 which forbids creating tables without insertable columns; the upstream SQLancer fix is in sqlancer/sqlancer#1296.

This PR:

  • Switches the SQLancer Docker image to use the ClickHouse fork (https://github.com/ClickHouse/sqlancer) pinned to a specific commit.
  • Fixes SQLancer CI job result reporting: writes the result file to the path Praktika expects (result_<normalized_job_name>.json) and adds an EXIT trap so server logs are always uploaded as artifacts.
  • Hardens ci/jobs/sqlancer_job.sh: enables pipefail so SQLancer non-zero exits are captured, terminates the server via PID_FILE instead of name-based pkill, and uses proper JSON escaping via python3 for assertion text.

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

SQLancer was disabled after #81835
which forbids creating tables without insertable columns (e.g., with only
`MATERIALIZED` or `ALIAS` columns). SQLancer's random table generator could
produce such definitions, causing an `AssertionError`.

The fix adds `EMPTY_LIST_OF_COLUMNS_PASSED` to SQLancer's expected errors.
The table creation retry loop in `ClickHouseProvider.generateDatabase` already
handles expected errors by regenerating the table definition.

The fix was submitted upstream: sqlancer/sqlancer#1296
and applied to the ClickHouse fork: https://github.com/ClickHouse/sqlancer

This PR switches CI to use the ClickHouse fork (pinned to a specific commit)
and re-enables the SQLancer job in the master workflow.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Mar 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3fe64c0]

Summary: ✅


AI Review

Summary

This PR re-enables the SQLancer (amd_debug) CI job on both master and PR workflows, switches the SQLancer image source to the ClickHouse fork at a pinned commit, and hardens ci/jobs/sqlancer_job.sh for result reporting and safer process shutdown. I found no remaining correctness or safety issues in the current diff, and previously raised bot threads are addressed in the latest code.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Mar 1, 2026
alexey-milovidov and others added 4 commits March 1, 2026 05:15
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add SQLancer job to the PR workflow, matching the pattern used for
other fuzzer jobs (ast_fuzzer, buzzhouse) with dependency on parallel
blocking functional tests.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The SQLancer job was writing its result to `result.json` but Praktika
expects `result_job.json` (the "experimental" filename). This caused
Praktika to never find the job result, report "Job killed or terminated,
no Result provided", and skip uploading attached files including the
server crash logs.

Changes:
- Fix result filename from `result.json` to `result_job.json`
- Add EXIT trap to always write result with server logs as attached
  files, even on early script exit
- Break test loop when server crashes instead of continuing
- Use `grep 'AssertionError'` instead of `grep -i assert` to avoid
  false positives in error detection

Co-Authored-By: Claude Opus 4.6 <[email protected]>
In `cancelImpl`, the code only checked `!out->isCanceled()` before
attempting to flush data to the downstream buffer. However, the
downstream buffer could also be already finalized (not just canceled).

This happens in the HTTP handler error path: when `cancelWithException`
sends an error response to the client, it finalizes the HTTP response
buffer (`out_holder`), but the intermediate compression buffer
(`wrap_compressed_holder`) is left un-finalized. When `Output::cancel`
is then called, the compression buffer's `cancelImpl` tries to flush
its remaining data to the already-finalized downstream buffer, triggering
a "Cannot write to finalized buffer" exception (which is a logical error
that aborts the server in debug builds).

The fix adds `&& !out->isFinalized()` to the validity check, and also
restructures the code to skip `this->next()` and `out->next()` calls
when the downstream buffer is not writable.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default and removed pr-ci labels Mar 1, 2026
alexey-milovidov and others added 8 commits March 1, 2026 23:00
…rror responses

Test sends queries that fail during analysis via HTTP with various
compression encodings (lz4, gzip, zstd, br, deflate) and verifies the
server returns an error without crashing.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Pin to ClickHouse/sqlancer commit 308cb3b that upgrades the JDBC driver
from ru.yandex.clickhouse:clickhouse-jdbc:0.3.2 to
com.clickhouse:clickhouse-jdbc:0.9.6.

The old driver failed to decompress error responses from the server,
throwing "Magic is not correct" IOException instead of the actual error.
This caused all SQLancer tests to fail with 0 queries executed.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
`-DskipTests` only skips test execution but still compiles tests.
The test code references `ClickHouseDataType` which no longer exists
after the JDBC driver upgrade, causing a compilation failure.

Use `-Dmaven.test.skip=true` instead, which skips both test
compilation and execution.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Resolve conflicts with `sqllogic_test` job addition, keeping both
SQLancer and SQLLogic test jobs. Regenerated workflow YAML files.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The `isFilterAlwaysFalseForDefaultValueInputs` function in ActionsDAG
assumed the filter predicate always evaluates to UInt8, using
`value.safeGet<UInt8>()`. However, filter expressions like `radians()`,
`sin()`, or `sign()` return Float64 or Int8, causing a BAD_GET exception
when used in WHERE clauses with RIGHT or FULL OUTER JOINs.

The fix checks the actual Field type (UInt64, Int64, Float64) and
compares against zero accordingly. For any other type, it conservatively
returns false (i.e., does not convert the join).

This was found by the SQLancer CI job.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Mar 4, 2026
Two bugs fixed in `ActionsDAG`:

1. `isFilterAlwaysFalseForDefaultValueInputs` assumed the filter result was
   always `UInt8` and called `safeGet<UInt8>()`.  When the WHERE clause uses
   a non-boolean expression (e.g. `sin(col)`, `radians(col)`, `sign(col)`),
   the result type is `Float64` or `Int8`, causing a `BAD_GET` exception.
   Fix: check the Field type and use the matching `safeGet` variant.

2. `removeUnusedConjunctions` replaced the predicate DAG node in-place with
   constant 1 when the entire filter was pushed down past a JOIN.  When the
   same expression appeared in both WHERE and SELECT (a common pattern in
   SQLancer TLP queries), this corrupted the output—every row showed
   constant 1 instead of the actual computed value.  For `Float64` predicates
   this also triggered a `BAD_GET` because `createColumnConst(0, 1)` passes
   an `Int64` field to a `Float64` column.
   Fix: keep the original expression in the DAG so output values are correct;
   still signal `is_filter_const = true` so the caller converts the
   `FilterStep` to an `ExpressionStep` (which evaluates but does not filter).

The reference for `02861_filter_pushdown_const_bug` is updated because it
previously matched the buggy behavior (constant 1 in output).

#98390

Co-Authored-By: Claude Opus 4.6 <[email protected]>
alexey-milovidov and others added 6 commits March 4, 2026 01:47
# Conflicts:
#	.github/workflows/master.yml
#	.github/workflows/pull_request.yml
#	ci/workflows/pull_request.py
#	src/Interpreters/ActionsDAG.cpp
Merge conflict resolution left six non-existent job references in
`finish_workflow` needs: `stateless_tests_amd_binary_old_analyzer_*`,
`stateless_tests_amd_binary_parallelreplicas_*`, and
`stateless_tests_amd_debug_asyncinsert_*`. This caused GitHub Actions
to reject the entire workflow file, preventing CI from running.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Comment thread ci/jobs/sqlancer_job.sh Resolved
alexey-milovidov and others added 21 commits May 6, 2026 05:24
The local YAML regeneration adds back the `sqlancer_amd_debug` job that
the master merge removed, but pushing those changes is rejected because
the gh CLI token in this environment lacks the `workflow` scope. Restore
workflow files to byte-identical content from the previous remote PR tip
so the push of the master merge can proceed. The `Check Workflows` CI
job will continue to fail until the regenerated YAML is pushed from an
environment that has the `workflow` scope.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Re-runs `python3 -m praktika yaml` so the YAML matches `ci/workflows/master.py` and
`ci/workflows/pull_request.py`, fixing the `Check Workflows` CI failure.
Also restores `vectorsearchstress.yml` to the current praktika output (`arm-large-storage`),
matching `origin/master`.
OAuth-scope-restricted token cannot push workflow files; only the small
`vectorsearchstress.yml` regeneration (one-line `runs-on:` change) goes through.
`Check Workflows` will continue to fail for `master.yml`/`pull_request.yml`
until someone with `workflow` scope re-runs `python3 -m praktika yaml` and pushes.
…g master

`Check Workflows` was failing because `.github/workflows/master.yml` and
`.github/workflows/pull_request.yml` were out of sync with the praktika
config in `ci/workflows/`. Regenerated via `python3 -m praktika yaml`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ow push without workflow scope

The maintainer token in this session lacks the `workflow` OAuth scope, so
pushing commits that modify `.github/workflows/*.yml` is rejected by GitHub.
Restoring those two files to their previous remote tip lets the rest of
this branch (master merge, CI job script and config) land. The Praktika
`Check Workflows` job will continue to flag the YAML drift until they are
regenerated by a session with `workflow` scope (or via the GitHub UI).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…g master

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ow push without workflow scope

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The previous regeneration was reverted to allow push without `workflow`
OAuth scope; that left `master.yml`/`pull_request.yml` out of sync with
`ci/workflows/*.py` and the `Check Workflows` CI job fails.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98390&sha=8ba158232a19b98d3ce1d4b6023cf1fa0b3d49b1&name_0=PR&name_1=Config%20Workflow

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…er result

Praktika's CIDB inserter calls
`datetime.utcfromtimestamp(result.start_time)` and fails with
`'NoneType' object cannot be interpreted as an integer` when
`start_time` is `null`, blocking `Finish Workflow` for the
`SQLancer (amd_debug)` job:

  ERROR: Failed to insert data into CI DB, exception
  ['NoneType' object cannot be interpreted as an integer]
  (from: SQLancer (amd_debug))

Capture the job start timestamp at script entry and write real
numeric `start_time` and `duration` values into the result file,
even on the EXIT trap path.

CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98390&sha=latest&name_0=PR
PR: #98390

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…erver

Reviewer noted that the previous switch from name-based `pkill` to
`PID_FILE` did not fully close the original safety concern: the
script still trusted the PID file blindly. If the PID file is stale
or the PID has been reused, `kill "$(cat "$PID_FILE")"` could signal
an unrelated process on a shared runner.

Validate the PID before sending a signal: ensure it is numeric,
that the process still exists, and that `/proc/<pid>/comm` reports
`clickhouse`. Otherwise log a warning and skip the kill.

PR: #98390

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
On shared runners a stale `clickhouse-server.pid` could still match an
unrelated `clickhouse` process by `/proc/<pid>/comm`. Compare against the
resolved path of the binary this job started so a reused PID belonging
to a different `clickhouse` build is rejected.
@alexey-milovidov alexey-milovidov self-assigned this May 12, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue May 12, 2026
Merged via the queue into master with commit b847f77 May 12, 2026
166 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-sqlancer-ci branch May 12, 2026 22:36
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants