fix bug for local cache

This commit is contained in:
KinderRiven 2022-04-20 19:43:07 +08:00
parent a1e54c3918
commit b91f18033c
2 changed files with 9 additions and 1 deletions

View File

@ -646,6 +646,13 @@ void FileSegment::assertNotDetached() const
throw Exception(ErrorCodes::LOGICAL_ERROR, "Operation not allowed, file segment is detached");
}
void FileSegment::assertDetachedStatus() const
{
assert(
(download_state == State::EMPTY) || (download_state == State::PARTIALLY_DOWNLOADED)
|| (download_state == State::PARTIALLY_DOWNLOADED_NO_CONTINUATION) || (downloaded_stated == State::SKIP_CACHE));
}
FileSegmentPtr FileSegment::getSnapshot(const FileSegmentPtr & file_segment, std::lock_guard<std::mutex> & /* cache_lock */)
{
auto snapshot = std::make_shared<FileSegment>(
@ -683,7 +690,7 @@ FileSegmentsHolder::~FileSegmentsHolder()
{
/// This file segment is not owned by cache, so it will be destructed
/// at this point, therefore no completion required.
assert(file_segment->state() == FileSegment::State::EMPTY);
file_segment->assertDetachedStatus();
file_segment_it = file_segments.erase(current_file_segment_it);
continue;
}

View File

@ -151,6 +151,7 @@ private:
String getInfoForLogImpl(std::lock_guard<std::mutex> & segment_lock) const;
void assertCorrectnessImpl(std::lock_guard<std::mutex> & segment_lock) const;
void assertNotDetached() const;
void assertDetachedStatus() const;
void setDownloaded(std::lock_guard<std::mutex> & segment_lock);
void setDownloadFailed(std::lock_guard<std::mutex> & segment_lock);