Skip to content

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

@cruftex

Description

@cruftex

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions