-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ISPN-9155 clear() should not send remove notifications #6036
Conversation
Do we want to add the complementary removeAll() that does keep these semantics ? |
We should mention this in the upgrading guide as well. https://github.com/infinispan/infinispan/blob/master/documentation/src/main/asciidoc/upgrading/upgrading.asciidoc |
==== Clearing the cache | ||
|
||
The fastest way to clear a cache is to call | ||
link:{javadocroot}/org/infinispan/Cache.html#clear--[clear] method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we recommend clear()
here? The javadoc still says "This should never be invoked in production"
IMPORTANT: Starting with version 9.3, calling `clear` does no longer emit remove notifications for each removed key. | ||
If relying on removed events being fired upon calling `clear`, it is recommended to call `cache.keySet().stream().forEach(Cache::remove)`. | ||
Removing all entries in this way is optimized so that with distributed caches, removes happen in parallel. | ||
Further optimization can be achieved by calling `disableRehashAware` on the stream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't say "optimized" here, since it's always going to be much slower than the old clear()
* | ||
* Starting with version 9.3, calling this method does not result if cache entry removed events being fired. | ||
* If you rely on cache entry removed events | ||
* , use {@link CacheStream#forEach(BiConsumer)} to individually remove each entry and get remove notifications. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should document this in the CacheEntryRemoved
javadoc as well, and check that we don't implicitly rely on the listeners being invoked internally (e.g. MigrationTask
, global state, L2, JCache/Spring adapters)
@galderz as I mentioned in JIRA, we already have At the very least we should make sure we never use clear+listeners internally, and add extra warnings where we add listeners internally and the user can call |
My guess is that the issue is that |
Speaking of |
My vote for this: -1. I've added my concerns in the jira comments. |
Just an idea: why not keep the current method "as is" to avoid breaking clients, and provide another one named |
truncate() would be my choice if we keep clear() as is |
f6ea1e9
to
d3f12c5
Compare
|
@danberindei usability/syntactic sugar? |
I'm not totally sure I understand why you all are so worried about changing the semantics of clear. We already changed the semantics before (in a minor release too) (ISPN-5370) and I don't recall such a palava (here and here). Sure, this PR has more impact on the users since it'd affect remove notifications, but it's |
It's about that I think implementing the proposed |
@galderz I'm not that worried about the user listeners, at some point they'll put a breakpoint in their listeners and see they're not invoked during clear. I'm more worried that maybe we use listeners internally for some other features (near cache?), and the connection between those features and |
|
Nor makes sense to add such flag. |
I'm postponing this for 9.4 as I'd like to get full agreement from everybody on the solution |
2dfd2c1
to
41365cb
Compare
https://issues.jboss.org/browse/ISPN-9155
Wait for CI to see what I've broken ;)