Repository navigation
Fix progress bar flicker when the output is redirected - #123549
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
Workflow [PR], commit [12e288f] Summary: ✅
AI ReviewSummaryThis PR narrows the Findings
Final Verdict
LLVM Coverage ReportMeasured on commit 12e288f.
Changed lines: Changed C/C++ lines covered: 12/12 (100.00%) · Uncovered code |
|
Agree with bot, this PR consists of random unrelated changes. |
|
🕵 This branch was accidentally created on top of #108721, so the PR carried all of its changes. Commit 2ef8490 restores everything except the progress bar fix ( |
…minal When the output of `clickhouse-client` or `clickhouse-local` is redirected (e.g. piped into another command), the data never mixes with the progress bar on the terminal, but the progress bar was still cleared before writing every block and redrawn after it, so it flickered and was mostly invisible. Clear the progress only if stdout is a terminal or a pager is used. #80056 Co-Authored-By: Claude Opus 5.5 <[email protected]>
2ef8490 to
12e288f
Compare
| /// The data written to stdout can mix with the progress only if it is displayed on the terminal, | ||
| /// either directly or through a pager. Otherwise (e.g., stdout is redirected to a pipe or a file), | ||
| /// clearing the progress on every flush only makes it flicker. | ||
| const bool output_goes_to_terminal = stdout_is_a_tty || !pager.empty(); |
There was a problem hiding this comment.
The new stdout_is_a_tty || !pager.empty() gate treats every pipe as “not shown on the terminal”, but that is not true for common pipelines like clickhouse-client ... | cat / | tee, where the downstream process forwards the query result right back to the same terminal that tty_buf uses (stderr / /dev/tty). In those cases the flush callback no longer clears the progress before the next block is emitted, so the progress bar / progress table can interleave with forwarded result output again.
This optimization seems safe only for sinks that provably cannot resurface on the same TTY (regular files, /dev/null, etc.), not for generic pipes.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 16 s compile time in total, 7 of them have a recent master baseline. |
|
The problem fixed 🎉 🎉 🎉 |
|
@alexey-milovidov — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
…ress Master's client progress rework (ClickHouse#118536, ClickHouse#123549) moved the CPU, memory and temp-disk reads of `writeProgress` into one `getProfileSnapshot()` call under `profile_events_mutex` and added a "waited" meter. The IO rate now comes from the same snapshot (`ProfileSnapshot::io_rate`), so it is read together with the other values, and the IO counters are summed next to the other `INCREMENT` rows in `ClientBase::onProfileEvents`. The Web UI notebook mode (ClickHouse#115378) moved the resource-meter state from the tab to the cell, so both `payloadMeter` callbacks now add to `cell.resources`. Left as merged, the live one would read `tab.resources`, which no longer exists, and throw on the first result packet. 04548 greps the new spelling and keeps master's new checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ground-queries Master's client progress rework (ClickHouse#118536, ClickHouse#123549) replaced the private `getCPUUsage()` with one `getProfileSnapshot()` for `writeProgress` and added a "waited" meter. Background jobs still read the current CPU rate, so the public `getCPUUsage()` is kept beside `getAverageCPUUsage()`, and the per-host CPU totals keep accumulating next to master's waited sum. The flush callback now clears the progress only when the output reaches the terminal (master), and still checks `tty_buf` under `tty_mutex` (this branch), because a detached job can swap the output while a query runs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
When the output of
clickhouse-clientorclickhouse-localis redirected (e.g.clickhouse-local --progress -q "SELECT * FROM system.numbers" | clickhouse-local ...), the data never mixes with the progress bar on the terminal, but the flush callback of stdout still cleared the progress bar before writing every block, and it was redrawn after the block. As a result, the progress bar flickered and was mostly invisible.Now the progress bar and the progress table are cleared on flush only if stdout is a terminal or a pager is used. The progress is redrawn in place after every block, as before.
Closes: #80056
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The progress bar in
clickhouse-clientandclickhouse-localno longer flickers when the query result is redirected to a pipe or a file.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123549]
Version info
26.10.1.1367-master(included in26.10and later)