Uploaded image for project: 'JBoss Remoting'
  1. JBoss Remoting
  2. JBREM-1305

Maximum number of client sockets in MicroSocketClientInvoker increases after timeout waiting for a free socket

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2.2.4, 2.5.4.SP3
    • Fix Version/s: 2.2.4.SP1, 2.5.4.SP4
    • Component/s: transport
    • Labels:
      None
    • Environment:

      all

    • Steps to Reproduce:
      Hide

      1. Set clientMaxPoolSize=1 for DefaultEjb3Connector (ejb3.deployer/META-INF/jboss-service.xml)
      <mbean code="org.jboss.remoting.transport.Connector"
      name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3">
      <depends>jboss.aop:service=AspectDeployer</depends>
      <!-- Setting invokerDestructionDelay can help to preserve connections for reuse. -->
      <attribute name="InvokerLocator">socket://${jboss.bind.url.address}:3873/?clientMaxPoolSize=1</attribute>
      <attribute name="Configuration">
      <handlers>
      <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
      </handlers>
      </attribute>
      </mbean>

      2. Implement a stateless session bean method that will only wait for a while before return (e.g. Thread.sleep(2000))

      3. Make some remote calls to that session bean method in parallel by using multiple threads (e.g. 100 concurrent calls)

      4. The number of concurrent client sockets will increase after 30 seconds (incremented by one per every single timeout)

      Show
      1. Set clientMaxPoolSize=1 for DefaultEjb3Connector (ejb3.deployer/META-INF/jboss-service.xml) <mbean code="org.jboss.remoting.transport.Connector" name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3"> <depends>jboss.aop:service=AspectDeployer</depends> <!-- Setting invokerDestructionDelay can help to preserve connections for reuse. --> <attribute name="InvokerLocator">socket://${jboss.bind.url.address}:3873/?clientMaxPoolSize=1</attribute> <attribute name="Configuration"> <handlers> <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler> </handlers> </attribute> </mbean> 2. Implement a stateless session bean method that will only wait for a while before return (e.g. Thread.sleep(2000)) 3. Make some remote calls to that session bean method in parallel by using multiple threads (e.g. 100 concurrent calls) 4. The number of concurrent client sockets will increase after 30 seconds (incremented by one per every single timeout)

      Description

      Maximum number of client sockets in MicroSocketClientInvoker increases after timeout waiting for a free socket. This happens because of an illegal call of semaphore.release() in MicroSocketClientInvoker.transport(...) after semaphore.attempt(timeToWait) returned with false (no lock aquired) in MicroSocketClientInvoker.getConnection(...).

      public class MicroSocketClientInvoker extends RemoteClientInvoker
      {
      ...
      protected Object transport(String sessionID, Object invocation, Map metadata,
      Marshaller marshaller, UnMarshaller unmarshaller)
      throws IOException, ConnectionFailedException, ClassNotFoundException
      {
      ...
      try

      { socketWrapper = getConnection(marshaller, unmarshaller, timeLeft); }

      ...
      catch (Exception e)

      { // if (bailOut) // return null; semaphore.release(); ... }

      ...
      }

      protected SocketWrapper getConnection(Marshaller marshaller,
      UnMarshaller unmarshaller,
      int timeAllowed)
      throws Exception
      {
      long start = System.currentTimeMillis();
      long timeToWait = (timeAllowed > 0) ? timeAllowed : 30000;
      boolean timedout = !semaphore.attempt(timeToWait);
      if (trace) log.trace(this + " obtained semaphore: " + semaphore.permits());

      if (timedout)

      { throw new IllegalStateException("Timeout waiting for a free socket"); }

      ...
      }
      ...
      }

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                ron_sigal Ronald Sigal
                Reporter:
                torsten-neise Torsten Neise
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: