Skip to content

Commit 5913a0f

Browse files
committed
Add a little more explanation
1 parent 610a792 commit 5913a0f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/DocumentSubsetBitsetCache.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ public void onClose(IndexReader.CacheKey indexKey) {
151151
private void onCacheEviction(RemovalNotification<BitsetCacheKey, BitSet> notification) {
152152
final BitsetCacheKey cacheKey = notification.getKey();
153153
final IndexReader.CacheKey indexKey = cacheKey.indexKey;
154-
// key is no longer in the cache, make sure it is no longer in the lookup map either.
154+
// the key is *probably* no longer in the cache, so make sure it is no longer in the lookup map.
155+
// note: rather than locking (which destroys our throughput), we're erring on the side of tidying the keysByIndex
156+
// structure even if some other racing thread has already added a new bitset into the cache for this same key.
157+
// the keysByIndex structure is used in onClose (our notification from lucene that a segment has become inaccessible),
158+
// so we might end up failing to *eagerly* invalidate a bitset -- the consequence of that would be temporarily higher
159+
// memory use (the bitset will not be accessed, and it will still be invalidated eventually for size or ttl reasons).
155160
keysByIndex.computeIfPresent(indexKey, (ignored, keys) -> {
156161
keys.remove(cacheKey);
157162
return keys.isEmpty() ? null : keys;

0 commit comments

Comments
 (0)