We are working on a performance issue in our application and we observed the following behavior in the thread dump.
There is a thread which owns the montior lock but still in blocked state.
INT:legacon:41:76" prio=10 tid=0x0000000055df0800 nid=0x2e39 waiting for monitor entry [0x00002aaacb4d4000]
java.lang.Thread.State: BLOCKED (on object monitor)
at com.leg.common.connections.fg.FgConnection.send(FgConnection.java:342)
- locked <0x00000007345b78c0> (a java.io.BufferedOutputStream)
at com.leg.mg.core.po.storage.ReplicationConnection.send(ReplicationConnection.java:190)
at com.leg.mg.core.po.storage.ClusterStorageManager.replicate(ClusterStorageManager.java:620)
at com.leg.mg.core.po.poEngine.store(poEngine.java:1117)
at com.leg.mg.core.po.poWorker.storeMessage(poWorker.java:1024)
at com.leg.mg.proto.RWorker$DocumentMessageSender.run(RouterWorker.java:1976)
at com.leg.common.threadpool.VirtualThreadGroup$VirtualThreadGroupRunnable.run(VirtualThreadGroup.java:147)
at com.leg.common.threadpool.ThreadControl.run(ThreadControl.java:201)
at com.leg.common.threadpool.ThreadPool$PoolThread.run(ThreadPool.java:742)
The corresponding code block is
line 250 out = new BufferedOutputStream(socket.getOutputStream(), BUFFER_LENGTH);
line 331 public void send(Object obj, boolean flush) throws ConnectionException {
.
.
line 342 synchronized(out) {
. if(!isOpen()) {
. throw new ConnectionException("Connection closed", url);
. }
.
. header.reset();
. header.write(B_SEND_EX);
. header.write((byte)'\r');
. header.write((byte)'\n');
. int len = splitInt(val.length);
. while (len-- > 0) {
. header.write(splitBuffer[len]);
. }
. header.write((byte)'\r');
. header.write((byte)'\n');
. header.writeTo(out);
. out.write(val);
. if (flush) {
. out.flush();
. }
. }
line 364}
As per the above stack trace, it owns the montior lock on "out" at line 342. But it is still in BLOCKED state. Aslo, it says waiting for monitor entry [0x00002aaacb4d4000]. We could not indentify which is that 0x00002aaacb4d4000 and who is owning the lock on it, because there is no other occurrence for 0x00002aaacb4d4000 except this place in the whole thread dump.
How the thread will be in blocking state even after owning monitor lock?
How to identify what is 0x00002aaacb4d4000 ? Will it be any internal java object ?
Java version: jdk1.6.0_32
It will be really great if you can help us to understand this case.