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

Closed
cruftex opened this issue Oct 25, 2021 · 1 comment
Labels
Milestone

Comments

@cruftex
Copy link
Member

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(Hash2.java:112)
	at org.cache2k.core.HeapCache.lookupEntryNoHitRecord(HeapCache.java:1229)
	at org.cache2k.core.HeapCache.lookupOrNewEntryNoHitRecord(HeapCache.java:1180)
	at org.cache2k.core.EntryAction.lockForNoHit(EntryAction.java:716)
	at org.cache2k.core.EntryAction.wantMutation(EntryAction.java:506)
	at org.cache2k.core.operation.Operations$2.examine(Operations.java:48)
	at org.cache2k.core.EntryAction.examine(EntryAction.java:486)
	at org.cache2k.core.EntryAction.skipHeapAccessEntryPresent(EntryAction.java:480)
	at org.cache2k.core.EntryAction.wantData(EntryAction.java:444)
	at org.cache2k.core.operation.Semantic$MightUpdate.start(Semantic.java:87)
	at org.cache2k.core.EntryAction.start(EntryAction.java:425)
	at org.cache2k.core.BulkAction.tryStartAllAndProcessPendingIo(BulkAction.java:129)
	at org.cache2k.core.BulkAction.startRemaining(BulkAction.java:102)
	at org.cache2k.core.BulkAction.entryActionCompleted(BulkAction.java:357)
	at org.cache2k.core.EntryAction.completeProcessCallbacks(EntryAction.java:1548)
	at org.cache2k.core.EntryAction.mutationDone(EntryAction.java:1498)
	at org.cache2k.core.EntryAction.mutationReleaseLockAndStartTimer(EntryAction.java:1397)
	at org.cache2k.core.EntryAction.callListeners(EntryAction.java:1268)
	at org.cache2k.core.EntryAction.skipStore(EntryAction.java:1214)
	at org.cache2k.core.EntryAction.mutationMayStore(EntryAction.java:1210)
	at org.cache2k.core.EntryAction.checkKeepOrRemove(EntryAction.java:1163)
	at org.cache2k.core.EntryAction.expiryCalculated(EntryAction.java:1029)
	at org.cache2k.core.EntryAction.mutationCalculateExpiry(EntryAction.java:969)
	at org.cache2k.core.EntryAction.loadCompleted(EntryAction.java:817)
	at org.cache2k.core.EntryAction.onLoadSuccessIntern(EntryAction.java:802)
	at org.cache2k.core.EntryAction.onLoadSuccess(EntryAction.java:765)
	at org.cache2k.io.AsyncBulkCacheLoader$1.onLoadSuccess(AsyncBulkCacheLoader.java:83)
	at org.cache2k.addon.CoalescingBulkLoader$1.onLoadSuccess(CoalescingBulkLoader.java:154)
	at org.cache2k.addon.CoalescingBulkLoader$1.onLoadSuccess(CoalescingBulkLoader.java:145)
	at org.cache2k.addon.CoalescingBulkLoaderTest$IdentBulkLoader.loadAll(CoalescingBulkLoaderTest.java:200)
	at org.cache2k.addon.CoalescingBulkLoaderStressTest.lambda$test$0(CoalescingBulkLoaderStressTest.java:32)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
@cruftex cruftex added this to the v2.x milestone Oct 25, 2021
@cruftex cruftex added the bug label Oct 25, 2021
@cruftex
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
Labels
Projects
None yet
Development

No branches or pull requests

1 participant