Fix abort in temporary data in cache

This commit is contained in:
kssenii 2024-04-25 20:00:40 +02:00
parent f85d967f11
commit acd7292be0

View File

@ -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();