From 64712601a4f966d98e2b3120e4a2e19f2fb428af Mon Sep 17 00:00:00 2001 From: kssenii Date: Thu, 14 Mar 2024 12:03:24 +0100 Subject: [PATCH] Add assertions --- src/Interpreters/Cache/LRUFileCachePriority.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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; }