Skip to content
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

CacheClosedException with parallel Cache.close() / shutdown and async requests in flight #175

cruftex opened this issue Oct 25, 2021 · 1 comment


Copy link

cruftex commented Oct 25, 2021

Tests run through perfectly but sporadically print an error caused by an overlap of
request completion and shutdown.

What should we do on shutdown when requests are still in flight?

We don't want to hold up shutdown when there are requests in flight.
Throwing a CacheCloseException upon async completion would put the burden on
the caller to handle that problem. What needs to happen is, that we ignore the
async completion call, if the cache is closed.

[INFO] Running org.cache2k.addon.CoalescingBulkLoaderStressTest
Exception in thread "ForkJoinPool.commonPool-worker-3" org.cache2k.core.CacheClosedException: '_org.cache2k.addon.CoalescingBulkLoaderStressTest.test-43-5x'
	at org.cache2k.core.Hash2.lookup(
	at org.cache2k.core.HeapCache.lookupEntryNoHitRecord(
	at org.cache2k.core.HeapCache.lookupOrNewEntryNoHitRecord(
	at org.cache2k.core.EntryAction.lockForNoHit(
	at org.cache2k.core.EntryAction.wantMutation(
	at org.cache2k.core.operation.Operations$2.examine(
	at org.cache2k.core.EntryAction.examine(
	at org.cache2k.core.EntryAction.skipHeapAccessEntryPresent(
	at org.cache2k.core.EntryAction.wantData(
	at org.cache2k.core.operation.Semantic$MightUpdate.start(
	at org.cache2k.core.EntryAction.start(
	at org.cache2k.core.BulkAction.tryStartAllAndProcessPendingIo(
	at org.cache2k.core.BulkAction.startRemaining(
	at org.cache2k.core.BulkAction.entryActionCompleted(
	at org.cache2k.core.EntryAction.completeProcessCallbacks(
	at org.cache2k.core.EntryAction.mutationDone(
	at org.cache2k.core.EntryAction.mutationReleaseLockAndStartTimer(
	at org.cache2k.core.EntryAction.callListeners(
	at org.cache2k.core.EntryAction.skipStore(
	at org.cache2k.core.EntryAction.mutationMayStore(
	at org.cache2k.core.EntryAction.checkKeepOrRemove(
	at org.cache2k.core.EntryAction.expiryCalculated(
	at org.cache2k.core.EntryAction.mutationCalculateExpiry(
	at org.cache2k.core.EntryAction.loadCompleted(
	at org.cache2k.core.EntryAction.onLoadSuccessIntern(
	at org.cache2k.core.EntryAction.onLoadSuccess(
	at org.cache2k.addon.CoalescingBulkLoader$1.onLoadSuccess(
	at org.cache2k.addon.CoalescingBulkLoader$1.onLoadSuccess(
	at org.cache2k.addon.CoalescingBulkLoaderTest$IdentBulkLoader.loadAll(
	at org.cache2k.addon.CoalescingBulkLoaderStressTest.lambda$test$0(
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(
	at java.base/java.util.concurrent.ForkJoinTask.doExec(
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(
	at java.base/java.util.concurrent.ForkJoinPool.scan(
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(
	at java.base/
@cruftex cruftex added this to the v2.x milestone Oct 25, 2021
@cruftex cruftex added the bug label Oct 25, 2021
Copy link
Member Author

cruftex commented Oct 26, 2021

CacheClosedExceptions will be suppressed on callback, other exceptions from the cache (not client related) will be logged consistently and rethrown.

I did not find a way to construct a easy test case to get test coverage on the success path.

@cruftex cruftex closed this as completed Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

1 participant