Skip to content

Antalya 26.8 Backport of 7a5f464 - Fix null pointer dereference in executeQueryImpl when use_query_cache=1 and stage=QueryPlan - #2963

Merged
mkmkme merged 1 commit into
antalya-26.8from
fix/antalya-26.8/query-cache-null-ast
Nov 25, 2026
Merged

mkmkme merged 1 commit into
antalya-26.8from
fix/antalya-26.8/query-cache-null-ast

Conversation

@mkmkme

@mkmkme mkmkme commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

When remote() is used with a single address and serialize_query_plan=1, the remote node receives the query with stage=QueryPlan and query_kind=INITIAL_QUERY. In that path, executeQueryImpl skips parsing, leaving out_ast null. The can_use_query_result_cache check at line 1649 then dereferences the null out_ast before the null guard can fire.

Fix: add && out_ast before the as<ASTSelectQuery>() call. The same guard already exists on line 1683 for a nearby check.

Observed in stress test 01018_Distributed__shard_num with fuzz-injected use_query_cache=1:
https://altinity-build-artifacts.s3.amazonaws.com/PRs/1867/0f1a2bdd63003e2d54b41fcaf7d71c020de69cca/stress_test_arm_asan_s3/clickhouse-server.err.log

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fix a failure in tsan stress test

Documentation entry for user-facing changes

...

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • Aarch64 tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • CAS (content-addressed storage; Antalya only)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • OAuth (5m)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

…che=1` and `stage=QueryPlan`

When `remote()` is used with a single address and `serialize_query_plan=1`,
the remote node receives the query with `stage=QueryPlan` and
`query_kind=INITIAL_QUERY`. In that path, `executeQueryImpl` skips
parsing, leaving `out_ast` null. The `can_use_query_result_cache` check
at line 1649 then dereferences the null `out_ast` before the null guard
can fire.

Fix: add `&& out_ast` before the `as<ASTSelectQuery>()` call. The same
guard already exists on line 1683 for a nearby check.

Observed in stress test `01018_Distributed__shard_num` with fuzz-injected
`use_query_cache=1`:
https://altinity-build-artifacts.s3.amazonaws.com/PRs/1867/0f1a2bdd63003e2d54b41fcaf7d71c020de69cca/stress_test_arm_asan_s3/clickhouse-server.err.log

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Workflow [PR], commit [0407173]

@mkmkme mkmkme added the verified Approved for release label Nov 25, 2026
@mkmkme
mkmkme merged commit d86c739 into antalya-26.8 Nov 25, 2026
267 of 271 checks passed
@blau-ai blau-ai mentioned this pull request Nov 26, 2026
9 of 30 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

antalya antalya-26.8 antalya-26.8.39.20001 port-antalya PRs to be ported to all new Antalya releases verified Approved for release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants