mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #54985 from kssenii/add-assertion-in-desctructor
Add assertion
This commit is contained in:
commit
745673181e
@ -1059,6 +1059,9 @@ void FileCache::loadMetadataForKeys(const fs::path & keys_dir)
|
||||
FileCache::~FileCache()
|
||||
{
|
||||
deactivateBackgroundOperations();
|
||||
#ifdef ABORT_ON_LOGICAL_ERROR
|
||||
assertCacheCorrectness();
|
||||
#endif
|
||||
}
|
||||
|
||||
void FileCache::deactivateBackgroundOperations()
|
||||
@ -1143,14 +1146,15 @@ size_t FileCache::getFileSegmentsNum() const
|
||||
|
||||
void FileCache::assertCacheCorrectness()
|
||||
{
|
||||
auto lock = lockCache();
|
||||
main_priority->iterate([&](LockedKey &, const FileSegmentMetadataPtr & segment_metadata)
|
||||
metadata.iterate([&](LockedKey & locked_key)
|
||||
{
|
||||
const auto & file_segment = *segment_metadata->file_segment;
|
||||
UNUSED(file_segment);
|
||||
chassert(file_segment.assertCorrectness());
|
||||
return PriorityIterationResult::CONTINUE;
|
||||
}, lock);
|
||||
for (const auto & [_, file_segment_metadata] : locked_key)
|
||||
{
|
||||
const auto & file_segment = *file_segment_metadata->file_segment;
|
||||
UNUSED(file_segment);
|
||||
chassert(file_segment.assertCorrectness());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
FileCache::QueryContextHolder::QueryContextHolder(
|
||||
|
@ -362,12 +362,6 @@ public:
|
||||
return;
|
||||
inserted = keys.insert(key).second;
|
||||
}
|
||||
/// There is an invariant that key cannot be submitted for removal if it is already in removal queue.
|
||||
/// Because
|
||||
/// 1) when submit key to removal it acquires state REMOVING and we submit key for removal only if it has ACTIVE state.
|
||||
/// 2) if a key is added to cache and it was found in removal queue - it will be removed from the queue and get state ACTIVE.
|
||||
/// and both these actions are synchronized by the same KeyGuard.
|
||||
chassert(inserted);
|
||||
if (inserted)
|
||||
{
|
||||
CurrentMetrics::add(CurrentMetrics::FilesystemCacheDelayedCleanupElements);
|
||||
|
Loading…
Reference in New Issue
Block a user