diff --git a/src/Interpreters/Cache/LRUFileCachePriority.cpp b/src/Interpreters/Cache/LRUFileCachePriority.cpp index 644d8a43cb3..0f164f25293 100644 --- a/src/Interpreters/Cache/LRUFileCachePriority.cpp +++ b/src/Interpreters/Cache/LRUFileCachePriority.cpp @@ -113,6 +113,9 @@ LRUFileCachePriority::LRUQueue::iterator LRUFileCachePriority::remove(LRUQueue:: void LRUFileCachePriority::updateSize(int64_t size) { + chassert(size != 0); + chassert(size > 0 || state->current_size >= size_t(-size)); + state->current_size += size; CurrentMetrics::add(CurrentMetrics::FilesystemCacheSize, size); } @@ -390,6 +393,7 @@ void LRUFileCachePriority::LRUIterator::incrementSize(size_t size, const CacheGu "Increment size with {} in LRU queue for key: {}, offset: {}, previous size: {}", size, entry->key, entry->offset, entry->size); + chassert(size); cache_priority->updateSize(size); entry->size += size; } @@ -404,6 +408,9 @@ void LRUFileCachePriority::LRUIterator::decrementSize(size_t size) "Decrement size with {} in LRU queue for key: {}, offset: {}, previous size: {}", size, entry->key, entry->offset, entry->size); + chassert(size); + chassert(entry->size >= size); + cache_priority->updateSize(-size); entry->size -= size; }