So, I'm currently having a producer - consumer system that use ArrayBlockingQueue
.
All iz well for a long time, but yesterday the system is halting, and when I do jstack
over the jvm, I found out that all threads that are supposed to "offer" is in Thread.State: WAITING
when offering to the ArrayBlockingQueue, and all threads that are supposed to "poll" is also in Thread.State: WAITING
condition when polling from ArrayblockingQueue
.
I'm still new in analyzing jstack result, but from my understanding the log produced by jstack is a snapshot of all thread state in jvm. If so, I'm guessing this is a deadlock?
I've tried googling the cause, but can't seem to find anyone talking about deadlock in ArrayBlockingQueue. I also unable to reproduce the problem. Are there any known issue for this particular problem?
this is some log generated by jstack:
offer:
ClientHandlerISO_404" prio=10 tid=0x8be5c800 nid=0x5299 waiting on condition [0x8b28c000..0x8b28ce30]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x95515440> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:778)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1971)
at java.util.concurrent.ArrayBlockingQueue.offer(ArrayBlockingQueue.java:287)
at id.co.vsi.common.database.DB.insertToTableAsynchronously(DB.java:177)
poll:
DBQueryFileWriter_210" prio=10 tid=0x09528c00 nid=0x4eab waiting on condition [0x8cea1000..0x8cea1db0]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x95515440> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:778)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1971)
at java.util.concurrent.ArrayBlockingQueue.poll(ArrayBlockingQueue.java:342)
at id.co.vsi.common.database.DBQueryFileWriter.run(DBQueryFileWriter.java:164)
Thank you for the help