Clear vs. RemoveAll and application in tests

classic Classic list List threaded Threaded
2 messages Options
Mitchell Rathbun (BLOOMBERG/ 731 LEX) Mitchell Rathbun (BLOOMBERG/ 731 LEX)
Reply | Threaded
Open this post in threaded view

Clear vs. RemoveAll and application in tests

We have a bunch of tests that are run for our caching layer. In between each test, we want to clear all of the data in the cache. As part of some of the tests, there are background writes that occur to the cache. We have some sleeps to account for this, but that is error prone and doesn't always work. When we use clear() for all of the IgniteCache objects in between tests, some tests will fail due to writes occurring during current test from the previous test or from data not being cleared from cache, not exactly sure. If removeAll is instead used, then we never seem to have this problem. However, occasionally the code will hang if removeAll is used. We use IgniteDataStreamer to write to the cache, so I have a couple of questions:

1. The difference between clear and removeAll seems to be that removeAll waits for various listeners. Does this explain why removeAll always works for us (besides when it hangs)? I don't believe we have a write through cache and we don't explicitly register CacheEntryRemovedListeners.

2. What could be the cause of removeAll hanging? Is it possible for there to be a timeout that is configured for this call?
akurbanov akurbanov
Reply | Threaded
Open this post in threaded view

Re: Clear vs. RemoveAll and application in tests

Hello Michael,

Is that possible to identify what is the source of entries that are left in
the cache after clear()?

I would suggest to use full cache restart cycle between the tests
(destroy/getOrCreate), clearing without existing load should not leave any
entries in the cache.

How do you use removeAll, is it for keySet or no arg call? Is it possible to
get a thread dump for hanging removeAll?

Best regards,

Sent from: