Skip to content

Backport #112573 to 26.6: Fix async bounded read buffer readbigat race - #114618

Merged
clickhouse-gh[bot] merged 3 commits into
26.6from
backport/26.6/112573
Aug 17, 2026
Merged

clickhouse-gh[bot] merged 3 commits into
26.6from
backport/26.6/112573

Conversation

@robot-ch-test-poll

@robot-ch-test-poll robot-ch-test-poll commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #112573

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.6.3.51

@robot-ch-test-poll robot-ch-test-poll added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default labels Aug 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [25d672b]

Summary: ✅

kssenii and others added 2 commits August 17, 2026 21:49
Both sides appended new tests to the end of `src/Interpreters/tests/gtest_filecache.cpp`.
Resolved by keeping both: the two `readBigAt` tests from this backport and the two
`FileCacheQueryLimit` tests that `26.6` gained from the #107028 backport.

Co-Authored-By: Claude Opus 5 <[email protected]>
The backported gtests use scaffolding that only exists on newer branches.

In `src/Interpreters/tests/gtest_filecache.cpp`, add the four helpers the two new
tests need (`FakeRemoteReadBuffer`, `TestQueryScope`, `writeSourceFile`,
`makeSourceData`), taken from `master`, plus the `IO/BoundedReadBuffer.h` include.

In `src/Disks/tests/gtest_asynchronous_bounded_read_buffer.cpp`, `const auto`
deduces `Counter` because `ProfileEvents::Counters::operator[]` returns a
reference to a `std::atomic`, whose copy constructor is deleted. Name the type
`ProfileEvents::Count` instead, which also compiles on newer branches.

Co-Authored-By: Claude Opus 5 <[email protected]>
@kssenii

kssenii commented Aug 17, 2026

Copy link
Copy Markdown
Member

Fixed the unit-test build break and resolved the merge conflict with 26.6.

Build failures

Three build jobs (amd_debug, amd_asan_ubsan, amd_tsan) failed to compile two unit-test translation units. Both failures are branch-specific: the backported tests were written against master, which has scaffolding that 26.6 does not.

src/Interpreters/tests/gtest_filecache.cpp

error: unknown type name 'TestQueryScope'; did you mean 'QueryScope'?
error: use of undeclared identifier 'makeSourceData'
error: use of undeclared identifier 'writeSourceFile'
error: use of undeclared identifier 'FakeRemoteReadBuffer'

(each of the four, once per new test)

The two new tests use four test helpers that live in an anonymous namespace on master, added there by later work that was never backported to 26.6. Fixed by adding those four helpers, taken from master, plus the missing #include <IO/BoundedReadBuffer.h>:

  • FakeRemoteReadBuffer — a BoundedReadBuffer that also overrides getRemoteFileMetadata, so getRemoteReadBuffer treats it as a remote reader and uses it without wrapping.
  • TestQueryScope — a ThreadStatus plus a query context bound to the current thread via QueryScope::create, which reading through the cache requires.
  • writeSourceFile, makeSourceData — write the source file the tests read.

master's helper block also contains FailingReadBuffer and setupCacheSettings; those are used only by tests that are not part of this backport, so they were left out.

src/Disks/tests/gtest_asynchronous_bounded_read_buffer.cpp

error: call to implicitly-deleted copy constructor of 'const Counter'

at both sites of

const auto prefetched_reads_before = ProfileEvents::global_counters[ProfileEvents::RemoteFSPrefetchedReads];

ProfileEvents::Counters::operator[] returns a reference to a Counter, which is a std::atomic, so const auto deduces const Counter and copy-initializes an atomic — deleted. Fixed by naming the value type instead:

const ProfileEvents::Count prefetched_reads_before = ProfileEvents::global_counters[ProfileEvents::RemoteFSPrefetchedReads];

ProfileEvents::Count is size_t and this form compiles on master too. The two derived expressions a few lines below already worked (atomic - size_t converts implicitly), so they were left alone.

Neither fix touches the tests' logic or assertions.

Merge conflict

git merge-tree reported exactly one conflicting file, src/Interpreters/tests/gtest_filecache.cpp, and the conflict is a pure append collision at the end of the file:

  • this backport appends CachedReadBufferConcurrentReadBigAtWithPrefetch and CachedReadBufferConcurrentReadBigAtUnknownFileSize;
  • 26.6 meanwhile gained QueryLimitContextRevivedDuringRelease and QueryLimitConcurrentReleaseNoLeak from the backport of Fix data race on FileCacheQueryLimit::query_map causing LOGICAL_ERROR #107028 (de8532cc3a9), which also added #include <Interpreters/FileCache/QueryLimit.h>.

Resolved by keeping all four tests and both include sets; nothing was dropped or duplicated. The QueryLimit.h include and the two AsynchronousBoundedReadBuffer/ThreadPoolRemoteFSReader includes auto-merged in the header block, so the only manual work was the tail of the file. git merge-tree origin/26.6 HEAD now reports no conflict and there are no conflict markers anywhere.

The production diff against 26.6 (AsynchronousBoundedReadBuffer.{h,cpp}, CachedOnDiskReadBufferFromFile.{h,cpp}) is unchanged from the original backport commit — only the two test files were edited.

What is not verified yet

The change was not built locally, so compilation is confirmed only by reasoning: every symbol the added helpers use was checked to exist on this branch (ProfileEvents::Count, BoundedReadBuffer, the virtual ReadBufferFromFileBase::getRemoteFileMetadata and RemoteFileMetadata, QueryScope::create with a default-constructible move-assignable QueryScope, getMutableContext, ServerUUID::setRandomForUnitTests, WriteBufferFromFile, DBMS_DEFAULT_BUFFER_SIZE, all referenced FileCacheSetting entries, LocalFSReadSettings::method), as were the constructor signatures the tests call (CachedOnDiskReadBufferFromFile, the seven-argument AsynchronousBoundedReadBuffer, ThreadPoolRemoteFSReader, readBigAt). CI compilation and the actual pass/fail of the four tests still have to confirm it.

@clickhouse-gh
clickhouse-gh Bot merged commit b0875d1 into 26.6 Aug 17, 2026
38 of 39 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the backport/26.6/112573 branch August 17, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants