dcapwell commented on code in PR #2144:
URL: https://github.com/apache/cassandra/pull/2144#discussion_r1129756041
##########
src/java/org/apache/cassandra/service/accord/AccordStateCache.java:
##########
@@ -247,96 +260,115 @@ private void maybeEvict()
Node<?, ?> evict = current;
current = current.prev;
- // if there are any dangling write only groups, apply them and
- // move their futures into write futures so we don't evict
- applyAndRemoveWriteOnlyGroup(evict.value);
- if (!canEvict(evict.key()))
+ if (!canEvict(evict))
continue;
- logger.trace("Evicting {} {}",
evict.value.getClass().getSimpleName(), evict.key());
- unlink(evict);
- cache.remove(evict.key());
- bytesCached -= evict.estimatedSizeOnHeap();
+ evict(evict, true);
}
}
- private static <K, F extends Future<?>> F getFuture(NamedMap<Object, F>
futuresMap, K key)
+ private void evict(Node<?, ?> evict, boolean unlink)
{
- F r = futuresMap.get(key);
+ logger.trace("Evicting {} {} - {}", evict.state(), evict.key(),
evict.isLoaded() ? evict.value() : null);
+ if (unlink) unlink(evict);
Review Comment:
Blake added a patch to verify this assumption in the else block.
> since we could be linked and think we aren't,
This would be a bug, and not detecting that could cause a use-after-free
issue (which leads to a NPE later on). There was a similar issue earlier on
where the node was not in `cache` but it was in the linked list, this
eventually NPE.
--
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]