From 37bdba98b122abdfaa68027309f2dce9ff812c89 Mon Sep 17 00:00:00 2001 From: kssenii Date: Fri, 9 Sep 2022 15:41:31 +0200 Subject: [PATCH] Fix --- src/Interpreters/Cache/FileSegment.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Interpreters/Cache/FileSegment.cpp b/src/Interpreters/Cache/FileSegment.cpp index 8a67dfc1dc6..02452ab2a6d 100644 --- a/src/Interpreters/Cache/FileSegment.cpp +++ b/src/Interpreters/Cache/FileSegment.cpp @@ -894,13 +894,15 @@ void FileSegmentRangeWriter::completeFileSegment(FileSegment & file_segment) /// and therefore cannot be concurrently accessed. Nevertheless, it can be /// accessed by cache system tables if someone read from them, /// therefore we need a mutex. - std::lock_guard segment_lock(file_segment.mutex); + std::unique_lock segment_lock(file_segment.mutex); assert(current_downloaded_size <= file_segment.range().size()); file_segment.segment_range = FileSegment::Range( file_segment.segment_range.left, file_segment.segment_range.left + current_downloaded_size - 1); file_segment.reserved_size = current_downloaded_size; + + file_segment.setDownloadedUnlocked(segment_lock); } file_segment.completeWithoutState();