Skip to content

Do not log one message per decompressed block in CompressedReadBufferFromFile - #111546

Merged
pufit merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-compressed-read-buffer-per-block-log
Jul 23, 2026
Merged

pufit merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-compressed-read-buffer-per-block-log

Conversation

@groeneai

@groeneai groeneai commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator

Do not log one message per decompressed block in CompressedReadBufferFromFile

Related: #107941

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):

...

Description

CompressedReadBufferFromFile::nextImpl and readBig emitted one LOG_TEST "Decompressing ..." line per decompressed block. For a column stored in many tiny compressed blocks this is one log message per block. The LogSeriesLimiter member does not help here: it decides once per buffer instance and then lets every subsequent message through, so a single long-lived buffer logs every block.

At test log level (used by the stress test) this becomes a log storm. Example from the arm_debug stress hung-check on the head of #110188: the fuzzed query select json.a from test format Null over a JSON column with max_compress_block_size = 128 decompressed ~1.39M blocks and produced ~1.39M LogTest messages, spending 486 of 493 seconds inside the logger (LoggerElapsedNanoseconds), tripping the hung-check. This is one sub-cause of the chronic #107941.

Fix: drop the two per-block "Decompressing ... bytes" logs. The per-open ("Decompressing {file}") and per-seek logs are kept, so the diagnostic still shows which file is read and where it seeks. No behavior change outside test-level logging (at other levels these lines were already skipped before formatting).

Reproduced locally on a debug build: first cold read of such a column produced LogTest == CompressedReadBufferBlocks (86077 for a 300-row part) before the change and LogTest = 19 after, with the same number of decompressed blocks. Added 04545_compressed_read_buffer_no_per_block_log_storm which asserts the TEST log count stays small while many blocks are decompressed.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110188&sha=a164a556c0b418fb645e8db05d908f1fc976bd2b&name_0=PR&name_1=Stress%20test%20%28arm_debug%29

Version info

  • Merged into: 26.8.1.45 (included in 26.8 and later)

…FromFile

CompressedReadBufferFromFile::nextImpl and readBig logged one LOG_TEST message
per decompressed block. For a column stored in many tiny compressed blocks this
is one message per block; the LogSeriesLimiter member does not help because it
decides once per buffer instance and then lets every message through.

At test log level (stress tests) this is a log storm: the fuzzed query
'select json.a from test format Null' over a JSON column with
max_compress_block_size=128 decompressed ~1.39M blocks and spent 486 of 493
seconds inside the logger, tripping the hung-check (one sub-cause of ClickHouse#107941).

Drop the two per-block logs; keep the per-open and per-seek logs.

Related: ClickHouse#107941
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110188&sha=a164a556c0b418fb645e8db05d908f1fc976bd2b&name_0=PR&name_1=Stress%20test%20%28arm_debug%29

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Fresh JSON(max_dynamic_paths=0) table, max_compress_block_size=128, wide part, first cold SELECT json.a ... FORMAT Null with --send_logs_level=test. LogTest == CompressedReadBufferBlocks every run (86077 @300 rows, 705908 @2000 rows). Not a "1% repro".
b Root cause explained? Yes. nextImpl/readBig emit one LOG_TEST per decompressed block; LogSeriesLimiter decides once per instance then lets every message through. At test level under the stress ThreadFuzzer this is a log storm (486 of 493s inside the logger, tripping the hung-check). Analysis phase was 23ms, not the bottleneck.
c Fix matches root cause? Yes. Removes exactly the two per-block log sites; keeps the per-open and per-seek logs. No per-block LOG_IMPL invocation remains.
d Test intent preserved / new tests? New test 04545_compressed_read_buffer_no_per_block_log_storm. No existing test asserted on these logs (nothing greps "Decompressing"). No test weakened.
e Both directions? Yes. Same 86058 blocks. Baseline (HEAD): LogTest=86077 -> assertion fails. Fixed: LogTest=19 -> passes. 10/10 stable.
f General, not a narrow patch? Yes. Checked siblings: only CompressedReadBufferFromFile logs per compressed block. CachedCompressedReadBuffer, ReadBufferFromS3, ReadBufferFromEncryptedFile, ReadBufferFromPocoSocketChunked log per open/seek/range/chunk (bounded), not per tiny block. No sibling needs the same change.
g Generalizes across inputs? N/A - a logging-frequency change, input/type independent; applies to all callers of nextImpl/readBig.
h Backward compatible? Yes. No setting/format/validation change. Only removes two test-level (most verbose) log lines; at other levels these were already skipped before formatting. No SettingsChangesHistory entry needed.
i Invariants/contracts preserved? Yes. The removed statements sat between readCompressedData and getAdditionalSizeAtTheEndOfBuffer, touching no buffer state, positions, or error paths. The log member is still used by the surviving logs.

Session id: cron:clickhouse-author-slot-5:20260723-062000

@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)

An independent model reviewed the resulting code before this PR was opened. Findings and dispositions:

❌ Blockers: none.

⚠️ Majors:

  • Test could pass unfixed under randomized use_uncompressed_cache=1 — AGREE. The functional-test harness randomizes use_uncompressed_cache, which routes reads through CachedCompressedReadBuffer (a different class, without the removed logs) while still incrementing CompressedReadBufferBlocks. Verified: on the parent build at 300 rows, cache=1 drops LogTest from 86077 to 42606 — enough that a different scale/randomization could cross the assertion threshold and hide a regression. Pinned use_uncompressed_cache = 0 in the measured query; re-verified both directions (parent fails, patched passes; 10/10 stable).

💡 Nits:

  • Verbose test header comment — AGREE. Condensed to the regression invariant; backticked identifiers.
  • Commit message lacked CI report / issue links — AGREE. Added the canonical CI report URL and Related: #107941 to the commit message.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @scanhex12 — could you review this? It removes a per-decompressed-block LOG_TEST in CompressedReadBufferFromFile (nextImpl/readBig) that, at test log level, produced ~1 message per compressed block (~1.39M for a JSON column with tiny compress blocks), spending 486 of 493s in the logger and tripping the stress hung-check. The per-open and per-seek logs are kept.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Jul 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2482e58]

Summary: ✅


AI Review

Summary

This PR removes the two per-decompressed-block LOG_TEST calls from CompressedReadBufferFromFile and adds a stateless regression test that forces the uncached CompressedReadBufferFromFile path, then verifies the query still decompresses many blocks while ProfileEvents['LogTest'] stays bounded. The fix matches the reproduced hung-check root cause, covers both decompression entry points in the class, and the test already addresses the main false-negative path from use_uncompressed_cache.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 23, 2026
The style check forbids the global SYSTEM FLUSH LOGS form
(ci/jobs/scripts/check_style/various_checks.sh); the test only reads
system.query_log, so flush just that table.

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

clickhouse-gh Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.20% 86.20% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 78.30% 78.30% +0.00%

Changed lines: Changed C/C++ lines covered: 5/6 (83.33%) · Uncovered code

Full report · Diff report

@pufit pufit self-assigned this Jul 23, 2026
@pufit
pufit added this pull request to the merge queue Jul 23, 2026
Merged via the queue into ClickHouse:master with commit 59e48d4 Jul 23, 2026
180 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 23, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…d-buffer-per-block-log

Do not log one message per decompressed block in CompressedReadBufferFromFile
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-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.

4 participants