Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix terminate with uncaught exception in temporary data in cache #62998

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Interpreters/Cache/WriteBufferToFileSegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,18 @@ WriteBufferToFileSegment::WriteBufferToFileSegment(FileSegmentsHolderPtr segment
void WriteBufferToFileSegment::nextImpl()
{
auto downloader [[maybe_unused]] = file_segment->getOrSetDownloader();
chassert(downloader == FileSegment::getCallerId());
if (downloader != FileSegment::getCallerId())
{
throw Exception(ErrorCodes::LOGICAL_ERROR,
"Failed to set a downloader (current downloader: {}, file segment info: {})",
downloader, file_segment->getInfoForLog());
}

SCOPE_EXIT({
file_segment->completePartAndResetDownloader();
if (file_segment->isDownloader())
file_segment->completePartAndResetDownloader();
else
chassert(false);
});

size_t bytes_to_write = offset();
Expand Down