CASSANDRA-21474: NoSpamLogger uses unbounded cache that could lead to memory exhaustion - #4993
Open
viktoriiakotovets wants to merge 2 commits into
Open
CASSANDRA-21474: NoSpamLogger uses unbounded cache that could lead to memory exhaustion#4993viktoriiakotovets wants to merge 2 commits into
viktoriiakotovets wants to merge 2 commits into
Conversation
…port from CNDB-17505) ### What is the issue NoSpamLogger uses unbounded cache that could lead to memory exhaustion ### What does this PR fix and why was it fixed This PR replaces the previous `NonBlockingHashMap` based caching implementation in `NoSpamLogger` with Caffeine cache to prevent unbounded memory growth and improve cache management
ben-manes
reviewed
Aug 5, 2026
Comment on lines
+274
to
+295
| .expireAfter(new Expiry<String, NoSpamLogStatement>() | ||
| { | ||
| @Override | ||
| public long expireAfterCreate(String key, NoSpamLogStatement value, long currentTime) | ||
| { | ||
| return value.expiry(); | ||
| } | ||
|
|
||
| @Override | ||
| public long expireAfterUpdate(String key, NoSpamLogStatement value, | ||
| long currentTime, long currentDuration) | ||
| { | ||
| return value.expiry(); | ||
| } | ||
|
|
||
| @Override | ||
| public long expireAfterRead(String key, NoSpamLogStatement value, | ||
| long currentTime, long currentDuration) | ||
| { | ||
| return currentDuration; | ||
| } | ||
| }) |
Contributor
There was a problem hiding this comment.
fwiw, you might prefer
expireAfter(Expiry.writing((String key, NoSpamLogStatement value) -> Duration.ofNanos(value.expiry()))
Author
There was a problem hiding this comment.
sure, but that might need upgrade to 3.2.2 first
viktoriiakotovets
marked this pull request as ready for review
August 5, 2026 21:44
viktoriiakotovets
marked this pull request as draft
August 7, 2026 15:01
viktoriiakotovets
marked this pull request as ready for review
August 7, 2026 15:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/CASSANDRA-21474): NoSpamLogger uses unbounded cache that could lead to memory exhaustion
What is the issue
NoSpamLogger uses unbounded cache that could lead to memory exhaustionWhat does this PR fix and why was it fixed
This PR replaces the previous NonBlockingHashMap based caching implementation in NoSpamLogger with Caffeine cache to prevent unbounded memory growth and improve cache management