Details
Description
We having a productive setup where we are reuse sessions and create, start, stop ThreadedSocketAcceptor as we need them. We do not reuse them.
In Prod we saw the following problem: We were running out of file descriptors on ore 32 CPU Linux box with a max open file desriptor settings of 4096 after several days running around 20 quickfixj sessions within one JVM.
Issue:
After debugging the quickfixj and the apache mina code we found out, quickfixj is only unbinding the internal used IoAcceptors in its protected method AbstractSocketAcceptor#stopAcceptingConnections(), but not disposing them which is releasing the NIO Selectors used by Apache Mina. As a result the ExecutorServices created by Mina are not shouting down and their run() method is waiting on an internal inter thread communication lock forever.
Solution:
Just do a ioAcceptor.dispose(true); in ioAcceptor.unbind(); in quickfix.mina.acceptor.AbstractSocketAcceptor#stopAcceptingConnections() after line 248
protected void stopAcceptingConnections() throws ConfigError { Iterator<IoAcceptor> ioIt = ioAcceptors.values().iterator(); while (ioIt.hasNext()) { IoAcceptor ioAcceptor = ioIt.next(); SocketAddress localAddress = ioAcceptor.getLocalAddress(); ioAcceptor.unbind(); ioAcceptor.dispose(true); log.info("No longer accepting connections on " + localAddress); ioIt.remove(); } }