Skip to content

Add missing <atomic> include in DeserializationPrefixesCache - #108678

Merged
alexey-milovidov merged 5 commits into
ClickHouse:masterfrom
coderashed:fix/missing-atomic-include-deserialization-prefixes-cache
Jul 21, 2026
Merged

alexey-milovidov merged 5 commits into
ClickHouse:masterfrom
coderashed:fix/missing-atomic-include-deserialization-prefixes-cache

Conversation

@coderashed

@coderashed coderashed commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

DeserializationPrefixesCache.h uses std::atomic_bool but does not include <atomic>.

This was previously masked by two independent factors:

  1. In C++20, libc++'s <mutex> conditionally includes <atomic> (#if _LIBCPP_STD_VER <= 20). ClickHouse uses C++23, so this condition is false and the transitive include never fires.
  2. PR Remove transitive libc++ includes #92523 added _LIBCPP_REMOVE_TRANSITIVE_INCLUDES=1 to the bundled libcxx build, which removes transitive includes regardless of standard version.

Either change alone is sufficient to break a clean build. The breakage is invisible in CI because sccache reuses object files compiled before these changes landed — only a fresh build from scratch exposes it.

Related: #92523

Changelog category (leave one):

  • Not for changelog

Version info

  • Merged into: 26.7.1.1305 (included in 26.7 and later)

@CLAassistant

CLAassistant commented Jun 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderashed
coderashed force-pushed the fix/missing-atomic-include-deserialization-prefixes-cache branch from 612519b to 32cb61d Compare June 27, 2026 03:14
`std::atomic_bool` requires `<atomic>`, which was previously pulled in
transitively via `<mutex>` in libc++ C++20 mode. After PR ClickHouse#92523 removed
transitive libc++ includes (`_LIBCPP_REMOVE_TRANSITIVE_INCLUDES=1`) and
the codebase moved to C++23 (where `<mutex>` no longer includes `<atomic>`
even without that flag), the include became missing and the build breaks.

Related: ClickHouse#92523
@coderashed
coderashed force-pushed the fix/missing-atomic-include-deserialization-prefixes-cache branch from 32cb61d to 68d7aee Compare June 27, 2026 03:18
@coderashed

Copy link
Copy Markdown
Contributor Author

Force push cleaned LLM bloat from commit message and then changing associated email address to properly associate the CLA to my github account.

@alexey-milovidov alexey-milovidov self-assigned this Jun 28, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9bb1b46]

Summary: ✅


AI Review

Summary

This PR fixes the missing <atomic> include for DeserializationPrefixesCache, but the header is still not self-contained: it also uses std::optional without owning <optional>. I would keep the PR open until that same-class include gap is fixed in the same header.

Findings

⚠️ Majors

  • [src/Storages/MergeTree/DeserializationPrefixesCache.h:27] DeserializationPrefixesCache still depends on transitive STL includes because prefixes is a std::optional<...> but the touched include block adds only <atomic>. That leaves the header exposed to the same clean-build breakage class described in the PR body: an unrelated include cleanup can make this header stop compiling again.
    Suggested fix: add #include <optional> alongside <atomic> and <mutex>.
Final Verdict
  • Status: ⚠️ Request changes

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jun 28, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

Merged the latest master into this branch (it was ~909 commits behind). The merge is clean — the net diff against master remains exactly the single added line #include <atomic> in src/Storages/MergeTree/DeserializationPrefixesCache.h. I verified master still declares std::atomic_bool is_set in that header without including <atomic>, so the fix is still needed and correct.

The only red check on the previous run was Stress test (arm_tsan), which is unrelated to this change:

  • The job was killed by SIGTERM (ERROR: Run failed with exit code [-15]) after ~3 hours, with the teardown SYSTEM STOP DISTRIBUTED SENDS commands timing out because the server was unresponsive at the end of the stress run.
  • The log shows no ThreadSanitizer data-race report, no server crash, no OOM, and no fatal signal.
  • This PR adds zero runtime behavior — it is purely an #include hygiene fix — so it cannot affect stress-test execution.

The AI review verdict is ✅ Approve and there are no unresolved review threads. Pushing the merge re-triggers CI.

@alexey-milovidov

Copy link
Copy Markdown
Member

The current CI run on the post-merge commit 015510e9 has 5 red checks, and all of them are pre-existing, master-wide flakes — none can be caused by this change, which adds zero runtime behavior (it is purely the single #include <atomic> line in DeserializationPrefixesCache.h):

No code change needed. The fix is correct (the header declares std::atomic_bool is_set but did not include <atomic>), the net diff against master is exactly the one added line, and the PR is already approved.

@alexey-milovidov

Copy link
Copy Markdown
Member

The remaining red check, CH Inc sync, reports tests failed. It appeared after the analysis above and is caused by two pre-existing flaky integration tests, both unrelated to this change (which adds zero runtime behavior — a single #include <atomic> line):

  • test_refreshable_mv_no_multi_read/test.py::test_refreshable_mv_attach_without_multi_read — a tracked flaky test (an AssertionError in a refreshable-materialized-view timing check).
  • test_storage_iceberg_with_spark/test_compaction.py::test_clear_old_files[s3-2] — an Iceberg + Spark + S3 compaction test; this family flakes on Spark-container / S3 timing.

Neither test touches DeserializationPrefixesCache or serialization prefixes, and every build that this header change could affect passed. I re-triggered the two failed jobs; no code change is needed.

@alexey-milovidov

Copy link
Copy Markdown
Member

Re-merged the latest master into this branch (the previous head 015510e9 merged master on 06-30 and was ~1395 commits behind). The merge is clean, with no conflicts; the net diff against master remains exactly the single added line #include <atomic> in src/Storages/MergeTree/DeserializationPrefixesCache.h. I re-verified master still declares std::atomic_bool is_set in that header without including <atomic>, so the fix is still needed and correct.

The reason for the re-merge (beyond clearing the "behind master" state): the Upgrade check (amd_release) red was caused by benign PostgreSQL cleaner-task log noise against the unreachable RFC 5737 host 192.0.2.1:

PostgreSQLConnectionPool: Connection error: connection to server at "192.0.2.1", port 5432 failed: timeout expired
DB::DatabasePostgreSQL::removeOutdatedTables(): Code: 614 ... Connection to `192.0.2.1:5432` failed ...

This exact noise is now allowlisted in tests/docker_scripts/upgrade_runner.sh by #108560, which merged into master at 03:16 UTC today — after the previous CI run on 015510e9. Bringing it in should clear the Upgrade check red on the fresh run. The remaining previously-red checks were all pre-existing, master-wide flakes unrelated to this #include-only change (Stress Hung check #107941, AST-fuzzer Bad cast #107951, and two flaky integration tests under CH Inc sync), and the fresh run re-exercises them.

No code change needed. The PR is already approved and the AI review verdict is ✅ Approve.

@alexey-milovidov

Copy link
Copy Markdown
Member

The fresh Upgrade check (amd_release) run is still red, but for a different reason than the previous PostgreSQL-cleaner noise that #108560 addressed. This run's Error message in clickhouse-server.log failure is the benign encrypted-Backup-engine restore variant:

... is broken and needs manual correction. Reason: Code: 697. DB::Exception:
File data/.../columns.txt is encrypted in the backup, it can be restored only to
an encrypted disk. (CANNOT_RESTORE_TO_NONENCRYPTED_DISK)

This is a leftover-state flake from the 03277/03279 backup-database tests: they CREATE DATABASE ... ENGINE = Backup(...) and drop it, but the upgrade check runs the client with --fake-drop, so the database survives into the upgrade restart; when the run randomly enables --encrypted-storage, the Backup engine reads the encrypted parts through the non-encrypted DiskBackup, and BackupImpl::readFileImpl correctly rejects them with CANNOT_RESTORE_TO_NONENCRYPTED_DISK. No crash, no data loss — expected behavior logged as <Error>.

It is a broad master-wide flake (the Error message in clickhouse-server.log check fails 14–38 distinct PRs/day; this specific encrypted-Backup variant hit #108678, #109006, and #109011, all unrelated master-based changes). It cannot be caused by this PR, which adds zero runtime behavior — the net diff against master is exactly the single line #include <atomic> in DeserializationPrefixesCache.h.

The root-cause fix is already in flight: #109042 (allowlists this exact message in tests/docker_scripts/upgrade_runner.sh). Once it merges, the Upgrade check red will clear on a re-run. No code change is needed on this PR.

#pragma once

#include <DataTypes/Serializations/ISerialization.h>
#include <atomic>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still leaves the header dependent on transitive STL includes. DeserializationPrefixesCache.h also declares std::optional<...> prefixes below, but neither this file nor ISerialization.h includes <optional> directly. That means the same clean-build fragility the PR description is fixing for std::atomic_bool can recur here as soon as an unrelated header stops dragging <optional> in. Please add #include <optional> while touching this include block.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as everything works in our CI, this does not matter.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 21, 2026
Merged via the queue into ClickHouse:master with commit 8eb8850 Jul 21, 2026
180 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 22, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ic-include-deserialization-prefixes-cache

Add missing `<atomic>` include in `DeserializationPrefixesCache`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-not-for-changelog This PR should not be mentioned in the changelog 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.

4 participants