sgup432 commented on code in PR #16212:
URL: https://github.com/apache/lucene/pull/16212#discussion_r3382810614


##########
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java:
##########
@@ -1059,6 +1059,35 @@ void remove(QueryCacheKey queryCacheKey) {
       remove(queryCacheKey, -1);
     }
 
+    /**
+     * Remove all cache entries whose segment cache key is in {@code 
keysToRemove} or whose query is
+     * in {@code queriesToRemove}. Runs under the partition write lock so that 
iteration of the
+     * underlying {@code HashMap} does not race with concurrent mutation.
+     *
+     * <p>Note: {@link #remove(QueryCacheKey, long)} re-acquires the write 
lock, which is safe
+     * because {@link 
java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock} is reentrant.
+     * This matches the pattern used by {@link #evictIfNecessary()}.
+     */
+    void removeMatching(Set<IndexReader.CacheKey> keysToRemove, Set<Query> 
queriesToRemove) {
+      writeLock.lock();

Review Comment:
   Yeah I meant lock per partition. `evictIfNecessary()` does not traverse the 
whole key set, it only traverses it till condition cache size >= limit is true. 
I don't think we should go with this PR approach, it is unnecessary and 
expensive(in terms of performance) with the reasons already mentioned above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to