jankotek / mapdb

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap-memory. It is a fast and easy to use embedded Java database engine.
https://mapdb.org
Apache License 2.0
4.9k stars 872 forks source link

Threads Rests Waiting #573

Closed jmveramaiquez closed 9 years ago

jmveramaiquez commented 9 years ago

Hi,

Since I've introduced timed entry expirations, when I run a group of threads using HTreeMap as a shared cache, the threads get WAITING forever in a few hours.

This is the stack-trace of one of these locked threads.

--- StackTrace Begins ---- "name: Prospector-thread-140, id: 182, elapsedTime: 237441, isAlive: true, state: WAITING, interrupted: false", "sun.misc.Unsafe.park(Native Method)", "java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)", "java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)", "java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870)", "java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1199)", "java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:943)", "org.mapdb.HTreeMap.expirePurge(HTreeMap.java:2036)", "org.mapdb.HTreeMap.get(HTreeMap.java:593)", "ms.stratage.kumo.repository.RepositoryStore.getRobots(RepositoryStore.java:386)", "ms.stratage.kumo.repository.Repository.getRobotsInfo(Repository.java:307)", "ms.stratage.kumo.prospector.ProspectionTask.isAllowedByRobots(ProspectionTask.java:196)", "ms.stratage.kumo.prospector.ProspectionTask.processAnchor(ProspectionTask.java:737)", "ms.stratage.kumo.prospector.ProspectionTask.run(ProspectionTask.java:325)", "java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)", "java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)", "java.lang.Thread.run(Thread.java:745)", --- StackTrace Ends ----

Thanks,

Josep Miquel Vera
jankotek commented 9 years ago

Those threads should exit if DB.close() is called. They are non-deamon so it prevents JVM from exiting. Is db closed before exit?

jmveramaiquez commented 9 years ago

Sorry, those are application threads that are trying to get an element from the HTreeMap, while this elements is inside the expirePurge method of the HTreeMap instance.