From aa7136c27649fed0b5505faa382155050b327b7c Mon Sep 17 00:00:00 2001 From: kssenii Date: Fri, 11 Aug 2023 18:05:03 +0200 Subject: [PATCH] Add a comment --- src/Interpreters/Cache/Metadata.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Interpreters/Cache/Metadata.cpp b/src/Interpreters/Cache/Metadata.cpp index 194081e7926..1b0e02e87ce 100644 --- a/src/Interpreters/Cache/Metadata.cpp +++ b/src/Interpreters/Cache/Metadata.cpp @@ -355,6 +355,11 @@ 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 aquires state REMOVING and we submit key for removal only if it has ACITVE 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) {