Skip to content

Fix spurious receive timeout on distributed reads caused by a latched timer-readiness flag - #112229

Open
groeneai wants to merge 4 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-async-read-timer-readiness-latch
Open

groeneai wants to merge 4 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-async-read-timer-readiness-latch

Conversation

@groeneai

@groeneai groeneai commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

No related open issue found. The regression test whose invariant this restores is 02805_distributed_queries_timeouts, added by commit 4669951 ("Fix timeout for hedged requests"), removed for flakiness by #66563 and reintroduced with a wider margin by #67106.

CI reports for the failures this fixes (the failing checks belong to unrelated pull requests, so they are linked as reports rather than as pull request references). Each one is labelled with the statement of 02805_distributed_queries_timeouts that failed, so the attribution can be checked in one click:

The same test has also failed once on its synchronous statement (line 6, on master, commit 862617d). That failure carries the peer: ..., local: ..., 7000 ms message, which only ReadBufferFromPocoSocket emits from a Poco::TimeoutException on a single recv, rather than the (socket description, receive timeout N ms) message that both changed carriers produce. It comes from the synchronous path and this change does not address it. That report also contains a RemoteSource: Error occurs on cancellation ... (NETWORK_ERROR) line, so that log alone does not identify the latch: it appears on the synchronous failure too, and on neither of the two hedged failures above. It does appear on the async failure, which is the one path where the latch reaches cancelBefore(). The message that identifies a carrier is the timeout message form, not the cancellation 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 into CHANGELOG.md):

Fixes a spurious SOCKET_TIMEOUT ("Timeout exceeded while reading from socket") on distributed queries. When one epoll wake reported the receive timer and the socket as ready at the same time, the packet was delivered correctly but the connection was permanently marked as timed out, so a later packet failed the query even though the remote replica was responding on time. Affects reads with use_hedged_requests = 1 and with async_socket_for_remote = 1.

Description

PacketReceiver::checkTimeout and RemoteQueryExecutorReadContext::checkTimeout inspect the descriptors returned by one epoll wake, and both set a member flag (is_timeout_expired, is_timer_alarmed) as soon as the timer descriptor appears, before the flag is combined with socket readiness on the next line. Nothing ever clears either flag: each has exactly one write and no assignment back to false, and neither clearAsyncEvent() nor AsyncTaskExecutor::restart() resets it.

A wake in which the socket and the timer are ready at the same time therefore returns true and delivers its packet correctly, while leaving the connection permanently flagged as timed out. What follows depends on the read path:

  • With use_hedged_requests = 1, isPacketReady() is stuck false, so HedgedConnections::resumePacketReceiver can no longer take the packet-ready branch, falls through to isTimeoutExpired() and throws SOCKET_TIMEOUT. The per-packet setTimeout() re-arm in the packet-ready branch also becomes unreachable, which silently disables the property that receive_timeout is a per-packet idle timeout rather than a total query timeout.
  • With async_socket_for_remote = 1, the latched flag makes the guard throw on the first later wake in which the socket is not ready, which is the ordinary case while the remote is still producing the result. It also makes cancelBefore() skip draining the pending packet, so the connection is torn down unsynchronised and cancellation logs Connection to ... terminated (NETWORK_ERROR).

The synchronous path (use_hedged_requests = 0, async_socket_for_remote = 0) has no epoll timer and is unaffected.

Timer readiness observed in a single wake only means "a receive timeout happened" when the socket was not ready in that same wake, so it must not be stored as connection state. This makes the observation a function-local in both places, and keeps a member that records only the verdict of the conjunction, set exclusively in the branch that already declares the timeout. PacketReceiver::setTimeout() clears that verdict, because re-arming the timer starts a new receive interval. ConnectionEstablisherAsync::checkTimeout, the third and only other AsyncTaskExecutor, already uses a function-local for the identical loop and is left unchanged as the reference. No setting, no on-disk or wire format and no protocol is affected.

One consumer therefore sees a narrower predicate, deliberately. cancelBefore() skips draining the pending packet when a timeout has been declared, because waiting would exceed the timeout that already fired. Previously it skipped the drain after any wake in which the timer descriptor had merely appeared, including a wake that delivered a packet; now it skips it only after a timeout was actually declared. For a connection that saw such a wake and is later cancelled, cancellation therefore drains the pending packet again, which is what every connection that never hit the coincidence already did, and is the reason the NETWORK_ERROR on cancellation disappears together with the spurious timeout.

How it was verified

The end-to-end failure needs a scheduling coincidence and is not reliably reproducible, so the fix was measured rather than raced. Instrumented builds counted, on the hedged path under the same scenario: on unfixed master, 12 thrown timeouts arising from a single wake that genuinely observed "timer expired and no data", so 11 of 12 were spurious; with the fix, 8 thrown timeouts backed by exactly 8 such wakes, while simultaneous-readiness wakes were more than twice as frequent. The invariant the fix establishes is that a thrown timeout always corresponds to a wake that actually observed an idle socket.

Two unit tests (seven cases) drive the production checkTimeout() and cancelBefore() against a real connected socket pair without a server or a query, and cover both directions: a simultaneous-readiness wake leaves no residue and the receiver stays usable; a genuine timeout is still declared, still throws SOCKET_TIMEOUT, still persists for HedgedConnections, and still lets cancelBefore() skip waiting for a packet that can no longer arrive; and cancelling a connection that never declared a timeout still drains its pending packet, which is the half that keeps the connection synchronised. Instead of sleeping for a fixed interval, each case waits for the timer descriptor to become readable and fails if it does not, so no case can pass on a wake that never carried the timer. Each of the six production hunks was reverted individually and at least one assertion fails per hunk while the rest still pass; two of the six break two assertions each, because the verdict they record is read in two places.

Because both unit tests reach internals through a friend declaration added to the production headers, the Bugfix validation (unit tests) job cannot build its merge-base "before" binary with only the test files overlaid, and reports that as inconclusive rather than as a reproduction. The equivalent evidence is the mutation run above, which reverts each production hunk on the current tree instead of the whole commit.

02805_distributed_queries_timeouts is the regression test for the per-packet timeout property that the latch was disabling. It is not modified: the fix makes its invariant hold rather than relaxing the test, which had already been widened once and removed once (#66563) for this flakiness. These seven stateless tests were run against a pristine master binary and against the fixed binary, and the failure sets are identical: 01602_max_distributed_connections, 01731_async_task_queue_wait, 01822_async_read_from_socket_crash, 01851_hedged_connections_external_tables, 02466_distributed_query_profiler, 02805_distributed_queries_timeouts, 03444_distributed_hedged_requests_async_socket. They were picked by hand as the ones whose subject is the async or hedged remote-read path itself; a plain grep for receive_timeout, use_hedged_requests or async_socket_for_remote matches 46 stateless tests, of which 19 also perform a distributed or remote read, so the seven are a selection rather than the full grep result.

groeneai and others added 2 commits July 28, 2026 01:29
PacketReceiver::checkTimeout and RemoteQueryExecutorReadContext::checkTimeout
inspect the descriptors of one epoll wake and set a member flag as soon as the
timer descriptor appears, before it is combined with socket readiness on the
next line. Nothing ever clears either flag: each has a single write, two reads
and no assignment back to false, and neither clearAsyncEvent() nor
AsyncTaskExecutor::restart() resets it.

A wake in which the socket and the timer are ready at the same time therefore
returns true and delivers its packet correctly, while leaving the connection
permanently flagged as timed out. With use_hedged_requests = 1 isPacketReady()
is then stuck false, so HedgedConnections::resumePacketReceiver can no longer
take the packet-ready branch, falls through to isTimeoutExpired() and throws
SOCKET_TIMEOUT; the per-packet setTimeout() re-arm in the packet-ready branch
also becomes unreachable, which silently disables the property that
receive_timeout is a per-packet idle timeout rather than a total query timeout
(4669951). With async_socket_for_remote = 1 the latched flag makes the
guard throw on the first later wake in which the socket is not ready, and makes
cancelBefore() skip draining the pending packet, so cancellation logs
"Connection to ... terminated (NETWORK_ERROR)". The synchronous path has no
epoll timer and is unaffected.

Timer readiness observed in a single wake only means a receive timeout happened
when the socket was not ready in that same wake, so it must not be stored as
connection state. Make the observation a function-local in both places and keep
a member that records only the verdict of the conjunction, set exclusively in
the branch that already declares the timeout. PacketReceiver::setTimeout()
clears that verdict, because re-arming the timer starts a new receive interval;
the two consumers that need the verdict to persist across calls
(HedgedConnections::resumePacketReceiver and cancelBefore(), which uses it to
skip a drain that would otherwise block for a full receive_timeout) keep
working. ConnectionEstablisherAsync::checkTimeout, the third and only other
AsyncTaskExecutor, already uses a function-local for the identical loop and is
left unchanged as the reference.

Found through intermittent failures of 02805_distributed_queries_timeouts,
which is the regression test for the per-packet timeout property the latch was
disabling. That test is not modified. Verified by instrumented builds showing
that 11 of 12 thrown timeouts on unfixed master arose from a single wake that
genuinely observed an idle socket, while with the fix every thrown timeout is
backed by such a wake, and by two unit tests covering both carriers and both
directions, with each production hunk reverted individually to confirm the
corresponding assertion fails.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Both SimultaneousReadinessLeavesNoTimeoutResidue tests armed a 10 ms timer and
then slept for a fixed 200 ms without ever asserting that the timer descriptor
had become readable. In those tests the socket is deliberately readable, so a
sleep that returns early leaves a wake carrying only the socket, and in such a
wake the unfixed code satisfies every assertion too: the flag is only set when
the timer descriptor appears. The one case that carries the discriminating
scenario could therefore degenerate into "a readable socket means no timeout"
and stop discriminating, silently. Each case now waits for the timer descriptor
with a bounded poll loop and fails if it never becomes readable. With that wait
deliberately shortened to a zero budget and no retry, all seven cases fail on
that assertion, so it detects the state it exists to detect; with the assertion
kept but made unable to fail, the mutants that revert the production hunks still
fail exactly the tests they failed before, so it is not what makes them fail.

CancelAfterDeclaredTimeoutDoesNotWaitForPendingPacket was the only case calling
cancelBefore(), and it covered only the branch that skips the drain after a
genuine timeout. An implementation whose guard always skipped the drain passed
the whole suite, yet skipping the drain for a connection that never timed out is
the mechanism behind the reported "Error occurs on cancellation" NETWORK_ERROR.
CancelWithoutDeclaredTimeoutDrainsPendingPacket pins that direction: after a
simultaneous-readiness wake, with no timeout declared, cancelBefore() must enter
its drain loop, which is observable because the loop's blocking checkTimeout()
then throws SOCKET_TIMEOUT out of cancelBefore(). Hardwiring the guard to skip
makes it return without throwing and fails only this case. Reverting the async
carrier to the latched member fails this case as well, which demonstrates rather
than argues the causal link the description draws to the NETWORK_ERROR.

Its wall-clock expectation is also replaced by the structural one: entering the
drain loop is what throws, so the absence of a throw already carries the signal,
while an elapsed-time bound only measures the re-armed timer expiry.

No production file changes. The five production files are byte-identical to the
previous commit, and rebuilding after deleting every changed object reproduces
the same binary bit-for-bit.

CI reports for the failures this fixes, each labelled with the statement of
02805_distributed_queries_timeouts that failed:

  line 4, hedged path:
  https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112083&sha=67a6ecc5b2e584b344f5208cddeee29b4895f14a&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20WasmEdge%2C%20parallel%2C%202%2F2%29
  line 4, hedged path:
  https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110215&sha=f34341a1daeac43163f56f8712e96181bcf4f7ac&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20azure%2C%20parallel%29
  line 5, async path, ClickHouse#109490:
  https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109490&sha=0ad689784288cc72d7976732460395359de7171b&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%29

The previous commit also cited a master failure on commit
862617d. That one failed on line 6, the
synchronous statement, and carries the "peer: ..., local: ..., 7000 ms" message
that only ReadBufferFromPocoSocket emits from a per-recv Poco timeout, not the
"(socket description, receive timeout N ms)" message both changed carriers
produce. It is not fixed here and is no longer cited as such.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (2 rounds, 15 findings adjudicated, 13 AGREE / 2 DISAGREE)

Every change in this pull request was reviewed by a second model independently of the one that
wrote it, in two rounds. Round 1 bounced the change back with one blocker and three majors;
round 2 found no source defect and the second round of the independent gate returned zero
findings. The fix itself was never questioned in either round.

Round 1

❌ Blocker: the description cited a CI failure this change cannot fix. The first report
listed, and the only one on master, failed on the fourth statement of
02805_distributed_queries_timeouts, which runs with async_socket_for_remote = 0 and
use_hedged_requests = 0. That is the synchronous path, which has no epoll timer at all. Two
independent proofs: the statement's own settings, and the message form, since
peer: ..., local: ..., N ms is emitted only by ReadBufferFromPocoSocket from a
Poco::TimeoutException on a single recv, while both changed carriers emit
(<socket description>, receive timeout N ms). Round 2 re-derived this from the artifacts
rather than accepting the correction: the master row is (query 4, line 6), and the three
remaining reports are (query 2, line 4) twice on the hedged carrier and (query 3, line 5) on
the async carrier. The description now cites exactly those three, names the synchronous failure
as one this change does not address, and the "one failure on master, therefore a trunk bug"
reasoning is withdrawn: the conclusion rests on three failures on three unrelated pull requests
plus the instrumented measurement.

❌ Major: the discriminating test could pass vacuously. Both simultaneous-readiness cases
armed a 10 ms timer and then slept a fixed 200 ms without ever asserting the timer descriptor had
become readable. In those cases the socket is deliberately readable, so a sleep returning early
leaves a socket-only wake, and in such a wake the unfixed code satisfies every assertion too.
Each case now waits for the descriptor with a bounded poll loop and fails if it never becomes
readable. Shortening that wait to a zero budget with no retry fails all seven cases on exactly
that assertion, so it detects the state it exists to detect; keeping the wait but making the
assertion unable to fail leaves the mutants failing exactly the cases they failed before, so it
is not what makes them fail.

❌ Major: the cancellation contract was pinned in one direction only. The single case calling
cancelBefore() covered only the branch that skips draining the pending packet after a genuine
timeout. An implementation hardwired to always skip passed the whole suite, yet skipping the
drain for a connection that never timed out is the mechanism behind the reported
Error occurs on cancellation NETWORK_ERROR. A new case pins the other direction, and it is
observable structurally: entering the drain loop calls the blocking timeout check, which throws
SOCKET_TIMEOUT out of cancelBefore(). Hardwiring the guard to skip fails only that case.
Reverting the async carrier to the latched member fails it as well, which demonstrates rather
than argues the link the description draws between the latch and the cancellation error.

❌ Two majors in the description itself, both fixed: it claimed every stateless test naming
receive_timeout, use_hedged_requests or async_socket_for_remote had been run, when 46 match
and 7 were run; and it did not disclose that cancelBefore()'s predicate narrowed in meaning,
not just in name, so a connection that saw a simultaneous-readiness wake and is later cancelled
now has its pending packet drained where previously it did not.

Round 2

⚠️ Major: the corrected sentence still stated a predicate that does not hold. Its
replacement selects 19 tests, not the 7 that ran, and two further candidate predicates measured
16 and 19. The description now enumerates the seven test names and says plainly that they are a
hand-picked selection, disclosing both the 46 matches and the 19 that also perform a distributed
or remote read. A stated rule for a measured set is a claim, and none of the available rules was
true.

⚠️ Major: an undisclosed non-green job. Because both unit tests reach internals through a
friend declaration added to the production headers, Bugfix validation (unit tests) cannot
build its merge-base "before" binary with only the test files overlaid, and reports that as
inconclusive rather than as a reproduction. It is non-blocking by construction, but it is now
stated in the description together with the evidence that replaces it, namely reverting each
production hunk individually on the current tree.

💡 Three further nits corrected in the description: one latched flag has three reads at the
merge-base rather than two; two of the six hunks break two assertions each rather than one; and
the Error occurs on cancellation log does appear on the async failure, which is the one path
where the latch reaches cancelBefore(), so omitting that understated the corroboration.

✅ DISAGREE, with evidence. The bounded wait helper is byte-identical in both test files, but
they live in different directories and neither has a shared test header, so removing the
duplication means adding a header for two nineteen-line helpers; the pre-existing socket-pair
helper in the same two files is duplicated for the same reason. And the second round of the
independent gate returned zero findings over the full seven-file change, with the reviewed
content hash equal to the published description.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, of the defect. The end-to-end failure needs a scheduling coincidence (3 failures in ~314k runs), so the reproduction target is the latch itself, which is deterministic: build/src/unit_tests_dbms --gtest_filter='PacketReceiverTimeoutLatch.*:RemoteReadContextTimeoutLatch.*' forces the wake in which the timer fd and the socket fd are both ready, against a real connected socket pair with no server and no query. Stable across 50 repeats, and every case fails if the receive timer never became readable, so no case can pass on a wake that did not carry the timer. Reachability in the real query path is measured, not assumed: on instrumented unfixed master 11 of 12 thrown timeouts had no wake that genuinely observed an idle socket.
b Root cause explained? Yes. Both checkTimeout() implementations set a member flag (is_timeout_expired, is_timer_alarmed) as soon as the timer descriptor appears in an epoll wake, before it is combined with socket readiness on the next line, and nothing ever clears it (exactly one write and no assignment to false; clearAsyncEvent() and AsyncTaskExecutor::restart() do not reset it). A wake with both descriptors ready delivers its packet correctly and leaves the connection permanently flagged as timed out: the hedged path then cannot re-enter the packet-ready branch and throws SOCKET_TIMEOUT (also making the per-packet setTimeout() re-arm unreachable), and the async path throws on the first later wake without socket readiness and skips cancelBefore()'s drain, which is where the NETWORK_ERROR on cancellation comes from.
c Fix matches root cause? Yes. The per-wake observation becomes a function-local, i.e. state is narrowed to its actual lifetime; only the conjunction's verdict persists, set exclusively in the branch that already declares the timeout, and cleared by setTimeout() because re-arming starts a new receive interval. No widened bound, no no-random-* tag, no reduced dataset, no new setting or constant, and no defensive check at the throw site. The change is net negative in mutable state and is what makes the existing per-packet re-arm reachable again.
d Test intent preserved / new tests added? Yes. 02805_distributed_queries_timeouts is untouched: its sleep(8) / receive_timeout=7 margin, its empty reference and its tags all stand, so the regression guard for "receive_timeout is a per-packet idle timeout" is strengthened rather than relaxed (that test had already been widened once and removed once, #66563, for this flakiness). Two new unit tests add seven cases covering both carriers and both directions, including the direction the changelog entry promises: cancelling a connection that never declared a timeout still drains its pending packet. Because those tests reach internals through a friend declaration in the production headers, Bugfix validation (unit tests) cannot build its merge-base before-binary with only the test files overlaid and reports that as inconclusive; the equivalent evidence is the per-hunk mutation run in (e).
e Both directions demonstrated? Yes. With the fix: 7/7 pass. Each of the six production hunks was then reverted individually, each on a distinct build, and the corresponding assertion fails while the others still pass: latching the timer observation back into the member breaks SimultaneousReadinessLeavesNoTimeoutResidue on the respective carrier (and, on the async carrier, also the drain assertion, which is the causal link to the reported NETWORK_ERROR); not recording the verdict breaks the persistence and the skip-the-drain assertions; hardwiring the cancel guard to always skip breaks only the enter-the-drain assertion; not clearing on setTimeout() breaks the re-arm assertion. Two further probes show the new timer-readiness assertion is itself load-bearing (a deliberately too-short wait fails all seven cases) without being what makes the mutants fail (with that assertion made unable to fail, the mutants still fail exactly the same tests).
f Fix is general across code paths? Yes. The carrier population is closed and enumerated: exactly three AsyncTaskExecutor subclasses and three checkTimeout() implementations. Both defective ones are fixed; ConnectionEstablisherAsync::checkTimeout already uses a function-local for the identical loop and is deliberately left as the reference. Other TimerDescriptor users were checked and are not carriers: HedgedConnections' change_replica_timeout has different semantics (its expiry is intentionally terminal and starts a new replica), and PollingQueue's timer is for signalling with no readiness conjunction. The synchronous read path has no epoll timer (Poco applies the timeout per recv) and is correct by construction, which is why only two of the test's three statements have ever failed. Fixed at the source, not guarded at the throw site.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. This is a state-machine defect with no data-type surface: no columns, no types, no Nullable/LowCardinality/Array/Map wrappers are involved. The relevant input space is the readiness combinations of {timer, socket} plus the cancel path, and the tests cover both ready, timer-only, neither ready, cancel after a declared timeout, and cancel without one, i.e. both branches of the cancel guard. Both platform variants were checked: the non-Linux #else stub of RemoteQueryExecutorReadContext declares no such flag, and each test carries the same #if guard as its subject.
h Backward compatible? (maintainer-approved exception only) Yes, fully. No setting is touched (neither changed file references Settings), so no SettingsChangesHistory.cpp entry is needed; no on-disk format, no wire format, no protocol and no public API change. Both flags are private members; the one accessor read from outside the class keeps its name and its meaning for callers.
i Invariants and contracts preserved? Yes, and the two contracts that require the fact to persist are preserved by design rather than by accident: HedgedConnections::resumePacketReceiver reads isTimeoutExpired() between resumes, and cancelBefore() uses the declared-timeout fact to skip a drain that would otherwise block for a full receive_timeout on a connection that already timed out. Both are pinned by dedicated assertions, and the mutant that drops the second one makes the call block, which is exactly the mirror-image regression this guards against. Error paths are unchanged: the throwing branch still drains or resets the timer before throwing, and the existing asymmetry between the two carriers (reset() calls drain() internally) was deliberately not harmonised. Concurrency is strictly reduced, since a shared member becomes per-call stack state; the member that remains keeps its std::atomic_bool type. No allocation and no logging is added to this per-wake hot path.

Session id: cron:clickhouse-impl-slot-7:20260728-043001

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @azat @yariks5s - could you review this? Both async remote-read checkTimeout() implementations set a member flag the moment the receive timer descriptor appears in an epoll wake, before it is combined with socket readiness one line later, and nothing ever clears it, so a wake carrying both a packet and the timer expiry delivers the packet and then leaves the connection permanently flagged as timed out: the hedged path can no longer reach the packet-ready branch (which is also where the per-packet setTimeout() re-arm lives) and the async path throws on the next wake without socket readiness. The observation becomes a function-local and only the conjunction's verdict persists.

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

clickhouse-gh Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e5af8d3]

Summary: ❌

job_name test_name status info comment
Bugfix validation (unit tests) ERROR
Compile before-binary (ninja unit_tests_dbms, without the fix) ERROR

AI Review

Summary

This PR fixes a real timeout-state bug in the async remote-read and hedged-read paths by keeping only the declared timeout verdict as persistent state and leaving one-epoll-wake timer readiness local to checkTimeout. I traced the changed state machines through HedgedConnections, RemoteQueryExecutor, cancellation, and the unchanged ConnectionEstablisherAsync sibling, and I did not find a correctness, concurrency, or compatibility issue in the current head. The focused gtests cover both carriers and both cancellation branches, and the current Praktika report for commit e5af8d3d0806e892fd23d211f0cae46d80988913 is green.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 28, 2026
groeneai and others added 2 commits July 28, 2026 09:40
Build (arm_tidy) failed on this PR with two
readability-make-member-function-const errors (warnings-as-errors) in the
new gtest fixture:

  src/Client/tests/gtest_packet_receiver_timeout_latch.cpp:51:10:
      method 'checkTimeout' can be made const
  src/Client/tests/gtest_packet_receiver_timeout_latch.cpp:54:10:
      method 'setTimeout' can be made const

Both accessors reach the receiver through a std::unique_ptr member, so
mutating the pointee from a const method is well-formed and the check is
right: const-qualifying them is behaviour-preserving. The two neighbouring
accessors are already const, so this also makes the fixture consistent.

The sibling gtest is unaffected because it holds its subject by value, where
const would forbid the mutation.

Verified with clang-tidy-21 (the version CI uses) against the build's
compile_commands.json: both new translation units are clean with this change,
and reverting either const reproduces exactly the two CI errors. All 7 tests
in the two new suites still pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Trim the historical preambles and the step-by-step restatements of the
assertions, keeping the parts that are not clear from the code itself: why the
timer readiness is awaited rather than slept on, why the bytes have to be
consumed (epoll is level-triggered), and why the presence or absence of a throw
is the oracle for the drain loop. Also drop the "()" from method names in the
retained comments.

No behaviour change: both files still produce the same 7 passing tests, and
clang-tidy-21 is clean on both translation units.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

arm_tidy fix pushed: 3fc1bf99b9f7f9 -> e5af8d3d0806e8

Build (arm_tidy) failed on the previous head with two readability-make-member-function-const errors (the tidy build runs -warnings-as-errors), both in this PR's own new test fixture:

src/Client/tests/gtest_packet_receiver_timeout_latch.cpp:51:10: method 'checkTimeout' can be made const
src/Client/tests/gtest_packet_receiver_timeout_latch.cpp:54:10: method 'setTimeout'   can be made const

Both accessors reach their subject through a std::unique_ptr member, so mutating the pointee from a const method is well-formed and the check is correct. Const-qualifying them is behaviour-preserving, and the two neighbouring accessors were already const. The sibling gtest is unaffected because it holds its subject by value, where const would forbid the mutation - which is why only these two lines were flagged.

Verified with clang-tidy-21 (the version the tidy build uses) against compile_commands.json: both new translation units are clean with the change, and reverting either const reproduces exactly the two errors above. All 7 tests in the two new suites still pass.

While here I also condensed the comments in both new gtests - the historical preambles and the step-by-step restatements of the assertions are gone, and what remains is the part that is not evident from the code: why timer readiness is awaited rather than slept on, why the bytes must be consumed (epoll is level-triggered), and why the presence or absence of a throw is the oracle for the drain loop. The changelog entry is now in the present tense, per docs/changelog_entry_guidelines.md.

No functional change to the fix itself: the five production hunks are untouched.

@clickhouse-gh

clickhouse-gh Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 80.60% 86.30% +5.70%
Functions 91.50% 92.10% +0.60%
Branches 72.60% 78.40% +5.80%

Changed lines: Changed C/C++ lines covered: 197/210 (93.81%) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - e5af8d3

Every failure below has an owner. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Bugfix validation (unit tests) Bugfix validation inconclusive: the before-binary failed to COMPILE the overlaid test - the two new gtests reach privates through friend struct ::PacketReceiverTestAccess / ::RemoteReadContextTestAccess, which are declared in the production headers this pull request adds, so the merge-base "before" binary cannot compile them by design in this pull request (disclosed in the description); the job is allow_failure and does not block merge

Nothing else failed: 173 of 174 checks are green, Finish Workflow is green, and the
Build (arm_tidy) red from the previous head is fixed on this one.

On the one non-green job: it reports ERROR, not FAIL, and ERROR is excluded from the
Ready-for-merge FAIL list and from new_tests_check.py's refutation check, so the
new-test gate still passes. Making the job compile would mean deleting the tests' only
access path, and gtest-over-functional-test was the deliberate choice for a race that
needs deterministic thread interleaving.

Session id: cron:our-pr-ci-monitor:20260728-163000

@PedroTadim

Copy link
Copy Markdown
Member

@alexey-milovidov we need this PR to fix CI

@azat azat self-assigned this Nov 10, 2026

This branch has not been deployed

No deployments
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 comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants