We’re running Smack 4.2.4 and we recently enabled Stream Management. We observed a deadlock between the XMPPTCPConnection Reader and Writer. The reader is blocked trying to send an SM acknowledgement:
"Smack Reader (0)" #19 daemon prio=5 os_prio=0 tid=0x00007f513400a800 nid=0x4af6 waiting on condition [0x00007f516d6ef000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x000000070041b100> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at org.jivesoftware.smack.util.ArrayBlockingQueueWithShutdown.put(ArrayBlockingQueueWithShutdown.java:251)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.sendStreamElement(XMPPTCPConnection.java:1343)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.sendSmAcknowledgementInternal(XMPPTCPConnection.java:1695)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$2900(XMPPTCPConnection.java:151)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1200)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:1000)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1016)
at java.lang.Thread.run(Thread.java:748)
The writer is blocked trying to add to the unacknowledged stanzas list:
"Smack Writer (0)" #18 daemon prio=5 os_prio=0 tid=0x00007f5134009800 nid=0x4af5 waiting on condition [0x00007f516ddfc000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000007004cad70> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.ArrayBlockingQueue.put(ArrayBlockingQueue.java:353)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.maybeAddToUnacknowledgedStanzas(XMPPTCPConnection.java:1546)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.writePackets(XMPPTCPConnection.java:1446)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.access$3300(XMPPTCPConnection.java:1264)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter$1.run(XMPPTCPConnection.java:1312)
at java.lang.Thread.run(Thread.java:748)
I have a heapdump if I can consult if you need details, though I can’t share it as it’s from a machine serving users. Both the writer’s packet queue and the unacknowledged stanzas queue are full.
This commit seems to address a similar issue, but maybeAddToUnacknowledgedStanzas
in master still performs a blocking put()
.
Regards,
Boris