I encountered the exception after restarting Jetty, which contains producer-consumer implementation via MapDB's Queue. I haven't call "DBMaker.transactionDisable()", but why did I still get the above exceptions?
Before I restarted Jetty, I found the consumer seems blocked. By jstack command, I got lots of following logs:
"qtp1730704097-270" #270 prio=5 os_prio=0 tid=0x00007f7b60006800 nid=0xb44f waiting on condition [0x00007f7986ae9000]
java.lang.Thread.State: TIMED_WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000054047c420> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078) at org.eclipse.jetty.util.BlockingArrayQueue.poll(BlockingArrayQueue.java:342) at org.eclipse.jetty.util.thread.QueuedThreadPool.idleJobPoll(QueuedThreadPool.java:526) at org.eclipse.jetty.util.thread.QueuedThreadPool.access$600(QueuedThreadPool.java:44) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572) at java.lang.Thread.run(Thread.java:745)Locked ownable synchronizers: - None
Here are some code fragment:
// Consumer code:
public void run() {
try {
while (!stopped) {
if (System.currentTimeMillis() - lastCheckTime > 60000) {
localDb.commit();
localDb.compact();
lastCheckTime = System.currentTimeMillis();
}
...
for (...) {
queue.poll();
}
...
localDb.commit();
}
localDb.commit();
localDb.compact();
} catch (InterruptedException ie) {
LOG.error("", ie);
}
}
// Others code:
...
DB localDb = DBMaker.newFileDB(new File(path)).closeOnJvmShutdown().make();
localDb.catPut(QUEUE_NAME + ".useLocks", false);
queue = localDb.getQueue(QUEUE_NAME);
...
public void interrupt() {
stopped = true;
localDb.close();
}
java -version: java version "1.8.0_11"
Thanks!