Skip to content

Commit

Permalink
Fix abort in temporary data in cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kssenii committed Apr 25, 2024
1 parent f85d967 commit acd7292
Showing 1 changed file with 10 additions and 2 deletions.
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

0 comments on commit acd7292

Please sign in to comment.