Skip to content

Support animated PNG in the PNG format - #112846

Merged
alexey-milovidov merged 20 commits into
masterfrom
animated-png
Aug 12, 2026
Merged

alexey-milovidov merged 20 commits into
masterfrom
animated-png

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

Support animated PNG in the PNG format.

If the result has a t column of an integer type, the format produces an animated PNG (APNG) instead of a still image. Records are grouped into frames by the value of t, which is the relative time offset of the frame. Every frame is an independent image: the canvas is empty at the start of each frame, and in the implicit coordinate mode the cursor restarts from the top-left corner. The t column can be combined with either coordinate mode.

The unit of t is set by the new settings output_format_image_time_multiplier_seconds (default 1) and output_format_image_time_divisor_seconds (default 60), so one unit of t is 1/60 of a second by default. A frame is displayed until the next one begins, and the last frame is displayed for as long as the frame before it.

The new setting output_format_image_streaming_animation (default false) writes each frame out as soon as the next value of t is seen, instead of buffering all the frames in memory, so a viewer can display the frames while the query is still running. It requires t to be non-decreasing and throws otherwise.

It defaults to false because of a constraint of the format itself: the acTL chunk must precede the first IDAT and must declare the total number of frames, which a forward-only writer does not know. This is why the APNG muxer of ffmpeg seeks back to patch acTL and warns when the output is not seekable; a ClickHouse WriteBuffer cannot seek. The streaming mode therefore declares an upper bound rather than the exact count. Measured behaviour of real decoders on such a file:

  • Firefox plays it. The APNG patch of libpng emits a non-fatal png_warning("Number of actual frames fewer than expected") at IEND.
  • Chrome plays the real frames, but keeps the image in the "still loading" state: SkPngRustCodec::parseAdditionalFrameInfos maps the frames that never arrive to kIncompleteInput.
  • Pillow reports the declared count and then raises OSError: Truncated File Read past the last real frame.

With the default false the frame count is exact and the output conforms to the specification.

The sixel protocol cannot represent an animation at all, and the Kitty graphics protocol animates only through a separate flow of per-frame commands, so both reject a result with a t column. The iterm protocol carries the whole datastream as a single payload, so the frames cannot reach the terminal early there; since that payload is fully buffered before it is sent, the exact frame count is patched into acTL and the payload conforms to the specification even in the streaming mode.

SELECT
    number % 60 AS t,
    toInt32(intDiv(number, 60) % 64) AS x,
    toInt32((number * 7) % 64) AS y,
    toUInt8(255) AS v
FROM numbers(60 * 64)
INTO OUTFILE 'animation.png'
FORMAT PNG
SETTINGS output_format_image_width = 64, output_format_image_height = 64;

Changelog category (leave one):

  • New Feature

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

Support animated PNG in the PNG output format. A t column turns the result of a query into an animation, with the time scale of t set by output_format_image_time_multiplier_seconds and output_format_image_time_divisor_seconds, and output_format_image_streaming_animation to write the frames out as the query produces them instead of buffering them in memory.

Version info

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

A `t` column of integer type turns the result of a query into an animation
(`APNG`). Records are grouped into frames by the value of `t`, which is the
relative time offset of the frame. Every frame is an independent image: the
canvas is empty at the start of each frame, and in the implicit coordinate
mode the cursor restarts from the top-left corner.

The unit of `t` is set by the new settings
`output_format_image_time_multiplier_seconds` and
`output_format_image_time_divisor_seconds`, which default to 1 and 60, so one
unit of `t` is 1/60 of a second by default. A frame is displayed until the next
one begins, and the last frame is displayed for as long as the frame before it.

The new setting `output_format_image_streaming_animation` writes each frame out
as soon as the next value of `t` is seen, instead of buffering all the frames in
memory, so that a viewer can display them while the query is still running. The
`acTL` chunk has to precede the first `IDAT` and declare the total number of
frames, which a forward-only writer does not know, so the streaming mode
declares an upper bound instead of the exact count. Browsers play such a file,
but decoders that trust the declared count report an error after the last real
frame, so the setting defaults to false and the default output is a
specification-conforming `APNG`.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov
alexey-milovidov requested a review from a team as a code owner August 1, 2026 02:09
@clickhouse-gh

clickhouse-gh Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [77543a0]

Summary: ✅


AI Review

Summary

This PR adds APNG support to FORMAT PNG, including t-driven frame grouping, time-scale settings, and an opt-in streaming mode. The buffered path and the follow-up fixes look solid, but I still see one blocker in the raw streaming path and one remaining semantics gap in how t is interpreted.

Findings

❌ Blockers

  • [src/Formats/PNGSerializer.cpp:757] [dismissed by author -- https://github.com/Support animated PNG in the PNG format #112846#discussion_r3762517140] output_format_image_streaming_animation = 1 still makes successful direct-output queries emit non-conforming APNGs by hard-coding acTL.num_frames to 2147483647 for every multi-frame animation. The PR and tests explicitly acknowledge that strict decoders such as Pillow then treat the file as truncated, so this is an incorrect PNG result rather than a benign compatibility tradeoff.
  • Suggested fix: keep the raw-output path spec-conforming by buffering until the exact frame count is known, or reject/gate the unsafe path instead of exposing it as ordinary PNG output.

⚠️ Majors

  • [src/Formats/PNGSerializer.cpp:742] The code only preserves differences between consecutive distinct values of t, not the documented frame offsets themselves. With t = 10, 20, the first frame is emitted immediately for 10 units, so t = 0, 10 and t = 10, 20 produce the same animation; a non-zero or negative starting offset is silently discarded.
  • Suggested fix: either reject a first t different from zero, document that the timeline is normalized so min(t) becomes zero, or synthesize an initial empty frame to preserve leading offsets.
Final Verdict

❌ Changes requested. The buffered animation support looks solid, but the raw streaming mode still returns invalid APNG output and the current t semantics do not match the advertised frame-offset contract.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.70% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 79.00% 79.00% +0.00%

Changed lines: Changed C/C++ lines covered: 393/437 (89.93%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Aug 1, 2026
Comment thread src/Formats/PNGSerializer.cpp Resolved
Comment thread src/Formats/PNGSerializer.cpp Resolved
Comment thread src/Formats/PNGSerializer.cpp Resolved
@mintlify

mintlify Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟢 Ready View Preview Aug 1, 2026, 3:42 AM

…maller issues

`delayFromUnits` scaled an over-long delay down by `(num + MAX_DELAY_PART - 1) / MAX_DELAY_PART`.
With `num` close to the maximum of `UInt64` - two frames at the two ends of the `t` domain with
`output_format_image_time_divisor_seconds = 1` - that addition wraps around, the factor comes out
as zero and the next division is undefined behavior. This is also what the `arm_tidy` build
reported as `clang-analyzer-core.DivideZero`. The ceil-division is now written so that it cannot
overflow, and the factor is clamped to at least one.

The value of `t` was read through `getInt` and carried as `Int64`, so a `UInt64` `t` above the
maximum of `Int64` wrapped negative, which reordered the frames in the buffered mode and made the
streaming mode reject a monotonic sequence as decreasing. It is now mapped to an order-preserving
`UInt64` key, which keeps the whole domain of both signed and unsigned `t`; a difference of two
keys is still the difference of the two values, so the frame delays are unchanged.

In the streaming mode `acTL` declared `MAX_DECLARED_FRAMES` even when the very first frame was
handed over from `finalizeFrames`, i.e. when the whole result had already been read and the
animation has exactly one frame - an empty result, or a result where every row has the same `t`.
Such an output looked truncated to a decoder that trusts `acTL`; the exact count is now declared.

`resetFormatterImpl` called `clear` on `animation_buffer`, which keeps the capacity. The buffer
holds the whole encoded animation, so a large animated `iterm` or `kitty` payload pinned that
memory for the lifetime of a reused formatter such as `MessageQueueSink`. It is now swapped with
an empty one.

Tests cover a one-frame and an empty animation in the streaming mode, `t` of `UInt64` above the
maximum of `Int64` in both modes, and the widest possible gap over the `Int64` domain.
`IOutputFormat` flushes only after a whole chunk has been consumed, so a chunk holding many distinct
values of `t` kept all of its completed frames in the output `WriteBuffer` until the chunk ended.
The streaming mode is meant to let a viewer display the frames while the query is still running, so
`writeFrame` now flushes after each frame when the datastream goes straight to the output.
`flushImpl` rather than `flush`, because the writing mutex is already held by the caller of
`consume`. With an inline terminal image protocol the datastream is a single payload that cannot be
sent early anyway, so nothing is flushed there.

Verified over HTTP with a query of four frames spaced by `sleepEachRow`: the first `fcTL` chunk
reaches the client after 1.2 s of a 2.4 s query.
@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 357/402 (88.81%) · Uncovered code

Full report · Diff report

The Kitty graphics protocol does have animation, but it is a separate flow
of per-frame commands (`a=f` to transmit a frame, `a=a` to control playback),
not an animated datastream. `writeImageKitty` transmits a single PNG payload
with `f=100,a=T`, so an `APNG` would be decoded by Kitty as its default image
only, silently turning the animation into a still image.

Reject `kitty` for a result with a `t` column, the same way `sixel` is
rejected, instead of advertising an animation that does not play.
Comment thread src/Formats/PNGSerializer.cpp Resolved
alexey-milovidov and others added 2 commits August 4, 2026 13:03
When the delay numerator did not fit into the 16-bit part of `fcTL`,
both parts of the fraction were floor-divided by the scaling factor,
which distorts a ratio whose parts the factor does not divide: a gap of
65536 units with `output_format_image_time_divisor_seconds = 3` came
out as 32768/1 instead of ~65536/3, half as long again. Now the largest
denominator that brings the numerator into 16 bits is taken and the
numerator is rounded to the nearest integer, so 65536/3 becomes 43691/2.

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

Co-Authored-By: Claude Fable 5 <[email protected]>
The only conflict is `docs/en/interfaces/formats/PNG.md`, which `master`
deleted along with the rest of the legacy Docusaurus tree in "Docs: remove
legacy Docusaurus documentation" (9440ca7), while this branch documented
the animation in it. The deletion is taken as is: the documentation of the
`PNG` format now lives in the `Documentation` struct registered by
`registerOutputFormatPNG` in `src/Processors/Formats/Impl/PNGOutputFormat.cpp`,
from which `docs/reference/formats/PNG.mdx` is generated, and this branch
already carries the same animation sections there. The deleted page was a
duplicate of that source, so nothing is lost.

#112846
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Both stress-test failures on 90e1101 are unrelated to this PR:

All 7 png stateless tests pass locally on the merged branch.

Comment thread src/Formats/PNGSerializer.cpp Resolved
The streaming mode declares `MAX_DECLARED_FRAMES` in `acTL` as an upper
bound, but nothing stopped `emitFrame` from writing more frames than that,
after which the declared count would not be even an upper bound and the
APNG would be invalid. The buffered path likewise narrowed
`buffered_frames.size()` to `UInt32` without a check. Now a frame past
the 31-bit limit of `acTL` throws `TOO_MANY_ROWS` before it is written
(or buffered).

#112846
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112846&sha=89a5889df1c52785320be8d2ed3f3f48a5d5d89c&name_0=PR&name_1=Integration%20tests%20%28amd_binary_excluded_from_llvm%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. The failure is test_named_collections_encrypted2/test.py::test_zookeeper_encrypted_storage with a kazoo.exceptions.NoNodeError reading {ZK_PATH}/enc_test.sql — unrelated to this PR (which only touches the PNG output format), and there is no open issue for it; a similar flake in the same test file was fixed in #105175.

Comment thread src/Formats/PNGSerializer.cpp Resolved
@groeneai

Copy link
Copy Markdown
Collaborator

No fix is in flight for either. Both need a private-side change, which I cannot make: this account gets 404 on ClickHouse/clickhouse-private.

1. 04545_replace_shared_set_join_dropped_inner. Private-only code: no SharedDatabaseCatalog.h or StorageSharedSetJoin.h in the public tree. One lead, unverified against code I cannot read. SharedSet/SharedJoin own inner tables and use the same CREATE OR REPLACE rename-exchange path as MaterializedView; DatabaseReplicated::dropTable special-cases exactly those five engines to drop the inner table while the metadata transaction is live (src/Databases/DatabaseReplicated.cpp:2513). That path carried this bug class publicly: commitCreateTable skipped the ZK metadata node under isCreateOrReplaceQuery(), but the exchange never renames the inner table, so the node was never written and a later DROP failed with No node. Fixed in bf05b5e4ce9 by writing it for inner tables anyway (:2626). Given the test name, the SharedCatalog counterpart of that gap is where I would look first.

2. amd_msan ... sequential, 2/2. #113414 is not the fix: it raised amd_msan, WasmEdge, parallel to 3 batches and left the sequential pair at 2 on purpose. On master, ci/defs/job_configs.py:825 against :834. Your shard is the meta in keeper, s3 storage variant, whose ParamSet is not in the public job_configs.py at all, so the batch bump is a private-repo one-liner.

I did check whether the public twins need the same bump: 4 kills in 9463 and 9370 runs over 30 days, against the 16-in-7-days that justified the parallel split, so I am not splitting them. Growth is +31 and +24 s/day on p50, about seven weeks of p99 headroom.

pull Bot pushed a commit to Haofei/ClickHouse that referenced this pull request Aug 10, 2026
Parsing the first argument of the `remote`, `mysql`, and similar table
functions rebuilt the whole set of accumulated strings once per ordinary
character (`append` created `elem_to + elem_what` for a single-element
set), making the parsing quadratic in the description length. A fuzzed
1 MiB zero-padded `FixedString` address, such as
`mysql(toFixedString('127.0.0.1:9004', 1048575), ...)`, therefore hung
during query analysis for tens of minutes under TSan, where neither
`KILL QUERY` nor `max_execution_time` could interrupt it, and failed the
stress test hung check:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112846&sha=b6c24302410686f74109c91177b6585a898cb349&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29
(found on ClickHouse#112846)

Now a single-element set is appended to each accumulated string in
place, which is linear. A 1.6 MiB address went from 25.6 s to 0.29 s in
a release build.

Co-Authored-By: Claude Fable 5 <[email protected]>
…e delay

The settings 'output_format_image_time_multiplier_seconds' and
'output_format_image_time_divisor_seconds' define the time unit of 't' as
a fraction, and only its reduced form ends up in the 'fcTL' frame delay,
so validating each setting against 65535 separately rejected exactly
representable scales such as 100000/60 = 5000/3. The fraction is now
normalized by its greatest common divisor before validation, and only a
reduced denominator over the 16-bit limit is rejected: the denominator is
stored verbatim in 'delay_den', while an over-large numerator only means
that delays past the longest expressible one are clamped, which
'delayFromUnits' does for long delays anyway.

The test gained a positive case for the 100000/60 scale, and the negative
case that hard-coded its rejection now uses the irreducible 1/100000.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Triage of the CI on 598fd12's predecessor c688531:

  • The AI review Major (the time-scale validation rejecting reducible fractions such as 100000/60) is fixed in 598fd12 — see the review thread.
  • The only red, Stress test (arm_release), is unrelated to this PR: an AST-fuzzer query aborted with the logical error Cannot capture column 2 because it has incompatible type: got Nullable(UInt64), but UInt64 is expected. in ColumnFunction::appendArguments via ActionsDAG::evaluatePartialResult during ExpressionStep construction — constant folding of a lambda capture at planning time, nothing to do with the PNG format. The fix is in progress: Avoid server abort on type mismatch during partial result evaluation #109747 ("Avoid server abort on type mismatch during partial result evaluation", same evaluatePartialResult → ExecutableFunctionCapture path).

Comment thread src/Formats/PNGSerializer.cpp Resolved
…he bare unit

`fcTL` stores the actual frame delay, not the base time unit, so a
setting like `output_format_image_time_divisor_seconds = 100000` is
valid whenever the observed gaps of `t` reduce it into the 16-bit
delay parts: two frames at `t = 0` and `t = 2` give `2/100000 =
1/50000`, which is exactly representable, yet the constructor used to
throw on the bare unit before reading any rows. The fit check moves
to `delayFromUnits`, after the per-frame `gcd` reduction: a delay of
`MAX_DELAY_PART` seconds or more is clamped as before, a sub-second
delay whose reduced denominator is still over the limit throws
`BAD_ARGUMENTS`, and an over-large numerator keeps the rounded
rescaling.

#112846
/// covers an empty result and the common case of a single distinct value of `t`, which would otherwise
/// produce a spec-conforming file that looks truncated to a decoder that trusts `acTL`.
if (streaming_animation)
return (finalizing && emitted_frames == 0) ? 1 : PNGWriter::MAX_DECLARED_FRAMES;

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.

output_format_image_streaming_animation is documented as a memory/latency tradeoff, but this path makes a successful direct-output query emit a non-conforming APNG whenever more than one frame is streamed. acTL.num_frames is required to equal the real frame count, and here it stays at 2147483647; the PR description already notes that validating decoders such as Pillow then treat the file as truncated. That means the opt-in setting does not just reduce compatibility, it turns FORMAT PNG into an incorrect file-format result.

Please keep the raw-output path spec-conforming, for example by buffering unless the transport can be patched later, or by rejecting/gating this unsafe path instead of exposing it as a normal PNG setting.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is on-purpose.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Test:

WITH
    intDiv(number, 100000) AS t,
    number % 100000 - 50000 AS n,
    n / 1000 AS alpha,
    (500 * pow(abs(n) / (abs(n) + 1000), 10)) AS rad,
    ((2 * pi()) * t) / 50 AS phase,
    1. - (abs(n) / 50000) AS v,
    colorOKLCHToSRGB((0.7 * v, 0.15, v * 360)) AS color
SELECT
    t,
    512 + CAST((rad * cos(alpha + phase)), 'Int16') AS x,
    512 + CAST((rad * sin(alpha + phase)), 'Int16') AS y,
    color.1::UInt8 AS r, color.2::UInt8 AS g, color.3::UInt8 AS b
FROM numbers(10000000)
FORMAT PNG

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Triage of the three stress reds on 5379e4e1d9a9 — all three are the same known master-wide PromQL storm, unrelated to PNG:

The cause was removed from master by the revert #114326 (merged 2026-08-12 01:14 UTC, after this branch's previous master merge), so I re-merged master to pull it in. The merge was clean and touched none of this PR's files; incremental build is clean and all 7 local png stateless tests pass.

const auto next_frame = std::next(it);
/// Every frame is displayed until the next one begins; the last one reuses the previous duration.
const UInt64 delay_units = next_frame != buffered_frames.end()
? static_cast<UInt64>(next_frame->first) - static_cast<UInt64>(it->first)

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.

t is documented as the frame's relative time offset, but both animation paths only use gaps between consecutive distinct values. A concrete trace is t = 10, 20: the first frame is emitted immediately for 10 units, so t = 0, 10 and t = 10, 20 produce the same animation. That silently discards the leading offset instead of preserving the advertised start times.

Please either reject a first t different from zero, document that the timeline is normalized so min(t) becomes zero, or synthesize an initial empty frame so non-zero starting offsets survive serialization.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Which isn't a problem.

groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 12, 2026
@ alexbakharew asked on both LeakCheck::SkipQuietly call sites why the comment
does not state that the LeakSanitizer check is skipped. Each of the three
comments now leads with the fact, then the invariant that requires it: which
memory is still owned at that point (clickhouse-local, server) or that the leak
check deadlocks in signal context under the allocator lock (client), and why the
notice is quiet or reported there.

Comments only; no behaviour change.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112846&sha=2e6a38112ad4dacef62f5cc4cdb396cc297282eb&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29
Related: ClickHouse#112846

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Aug 12, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 12, 2026
Merged via the queue into master with commit 91b7007 Aug 12, 2026
181 checks passed
@alexey-milovidov
alexey-milovidov deleted the animated-png branch August 12, 2026 17:55
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 12, 2026
Blargian pushed a commit to Blargian/ClickHouse that referenced this pull request Aug 13, 2026
On ASan builds the server's forced-shutdown branch calls safeExit(0), which
calls __lsan_do_leak_check(). That branch is taken precisely because connection
handlers and refresh tasks missed the drain timeout, so LSan stops the world and
classifies chunks those threads are still using. The reports are unattributable
by construction.

Two were reported on 2026-08-08 as a uniqExact hash-table "direct leak" (2 MiB
on ClickHouse#112846, 4 MiB on ClickHouse#101264). Both are a single allocation with zero indirect
leaks, and the two green asan_ubsan jobs on the same commit of ClickHouse#112846 also
force-shutdown with connections live while reporting nothing, so neither is an
aggregation bug. Since ClickHouse#113608 made previously unattributed sanitizer reports
nameable, these compete with real leaks in every stress report.

safeExit gets a defaulted run_leak_check parameter, so every existing caller
keeps today's behavior, and the two force-exit branches reached while handler
threads are still running pass false. A stderr line records that coverage was
skipped rather than passed; its wording avoids "<Name>Sanitizer:" so that CI log
parsing does not read it as a failure.

Keeper's identical-looking branch is left alone on purpose: it calls
server_pool.joinAll() first, so no handler is still running there and this
report class cannot arise. The client's SIGINT/SIGQUIT handler keeps the
default. Clean shutdowns never reach safeExit, so they keep full leak coverage
through the ordinary at-exit check.

Two mechanisms that look plausible were measured and rejected. __lsan_disable()
does not suppress the check: it is an allocation-time per-thread flag, and a
probe still reported the leak. Omitting the call does not re-arm the at-exit
check either: that check is installed with Atexit(), which _exit() bypasses, so
omission can only remove reports, never add any.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator

The one-week re-census, as promised. #114053 merged 2026-08-13 08:40 UTC.

Headline: the unattributable class is gone. No uniqExact LSan report on any arm since the merge.

I am reporting the master-only arm, because a PR branch only contains the fix once it merges master, so the all-PR population is a mixture of fixed and unfixed builds. Every master build after the merge has it, so that arm has no dilution. Jobs matching %asan_ubsan%, which carry 435 of the 437 LSan rows in the period (the other 2 are PR-only bugfix-validation rows).

window master runs runs with an LSan report rate uniqExact rows
pre-fix (08-07 to 08-12 01:14) 2448 26 1.06% 1
post-revert, pre-fix (to 08-13 08:40) 1123 3 0.27% 0
post-fix (to now) 1569 0 0.00% 0

The middle window matters: the 145 and 150 row days on 08-10/08-11 were mostly the PromQL query-tree storm, which your revert #114326 removed on 08-12 01:14, before this fix. Comparing raw pre-merge days against now would credit that revert to this change, so the honest baseline is the post-revert window, and the effect being claimed here is 0.27% to 0.00%.

With 0 in 1569 runs the rate is not "zero", it is at most about 0.19% (rule of three). The post-merge observation window is 2.3 days, so that bound is what limits the claim, not the count.

The fix is verifiably live rather than merely correlated with quiet CI. On Stress test (arm_asan_ubsan) for #102499, sha 4d0d815d8c53fa1a, 08-14 04:27 UTC, the log carries Not running the leak check: other threads are still running. and the row is still red on a real UndefinedBehaviorSanitizer report (StorageMerge.cpp:768:51, STID 3542-4308). So the skip path executes, and the whole-line allow-list did not swallow a genuine report sharing the log.

Controls: %asan_ubsan% throughput held at 7.4k to 11.4k runs/day across the merge, so the zeros are not missing CI, and other sanitizer families kept reporting normally (08-14 alone has 13 ASan and 25 TSan rows). Two LSan rows do exist post-merge and neither is this family: STID 1367-26c6 on #108862, indirect-only, and an 88 byte direct leak on #94148 in La Casa Del Dolor. Both have uniqExact = 0.

One measurement note in case it is useful elsewhere: test_name here is Sanitizer (STID: ...), so keying a query on it gives a false zero, and keying on the Sanitizer (STID prefix instead over-counts, since it also matches Address and Thread sanitizer rows. That predicate reported 38 leak rows on 08-14 where there were none. These counts key on test_context_raw.

leshikus pushed a commit to leshikus/ClickHouse that referenced this pull request Oct 13, 2026
04665 is claimed by two live open PRs (ClickHouse#112846, ClickHouse#112849). The collision is
silent: the filenames differ so git reports no conflict, and
check_gaps_in_tests_numbers only rejects gaps of 100 or more, never
collisions. 04666, 04670, 04674 and 04675 are claimed too, by ClickHouse#112816,
ClickHouse#112458 and unpublished branches respectively.

Co-Authored-By: Claude Fable 5 <[email protected]>

This branch was successfully deployed

1 active deployment
staging - docs — 77543a09 Deployed Aug 12, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature 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