Resolution: Won't Do
Affects Version/s: AMQ 7.8.0.GA
Fix Version/s: None
The OpenWireProtocolManager class uses HashMap for maintaining all active connections relating to clientId:
both "removeConnection" method and "addConnection" method are in synchronized block in order to provide thread-safe read/write to this HashMap.
In some cases, for instance, under heavy load + relatively poor system disk IO performance, it can cause significant performance issue. One thread might hold this lock while busy carrying out paging related operations and all other 40 or 50 threads were waiting for the lock in order to go ahead with OpenWireProtocolManager.removeConnection() or OpenWireProtocolManager.addConnection() API call. The reason is that the removeConnection() method needs to disconnect the old connection before removing it from this HashMap. It might cause a lot of unnecessary invocations in the synchronized block. As a result, the broker might appear to be "hanging" because the broker can not remove old connections or add new connections. Obviously, this is not a real broker "hung" condition, but it still causes significant performance issue. For more details, please see attached thread dumps.
It might be a good idea to use synchronized map instead of the HashMap. For instance:
Then we could get rid of the synchronized block on both "removeConnection" method and "addConnection" method to avoid such condition.