Uploaded image for project: 'Errai'
  1. Errai
  2. ERRAI-986

Memory leak in ServerMessageBusImpl on remoteSubscriptions

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.0.1.Final, 4.0.0.Beta3, 3.2.4.Final
    • Fix Version/s: 4.0.0.Beta4
    • Component/s: None
    • Labels:
      None
    • Environment:

      jboss as 7.1, errai configured with longpolling

    • Steps to Reproduce:
      Hide

      1. start server in debug mode.
      2. connect a client (phase=connection), watch the RemoteServices list.
      3. after connection, enable a breakpoint in the server in the StandardAsyncServlet or other used receiver (for example first line in doPost()) - the idea is to fail the client heartbeat so that the server will expire the session
      4. send some rpc messages from the client before session expires
      5. wait for the server to expire the session
      6. continue from the breakpoint / disconnect debug, etc... so that the server will continue
      7. watch the client sending the re-init (phase-connection) with the RemoteServices list.

      Show
      1. start server in debug mode. 2. connect a client (phase=connection), watch the RemoteServices list. 3. after connection, enable a breakpoint in the server in the StandardAsyncServlet or other used receiver (for example first line in doPost()) - the idea is to fail the client heartbeat so that the server will expire the session 4. send some rpc messages from the client before session expires 5. wait for the server to expire the session 6. continue from the breakpoint / disconnect debug, etc... so that the server will continue 7. watch the client sending the re-init (phase-connection) with the RemoteServices list.
    • Workaround Description:
      Hide

      set
      errai.bus.long_poll_timeout
      and
      errai.bus.message_queue_timeout_secs
      so that the latest is bigger enough than the first, reducing the SessionExpire frequency

      Show
      set errai.bus.long_poll_timeout and errai.bus.message_queue_timeout_secs so that the latest is bigger enough than the first, reducing the SessionExpire frequency

      Description

      When ClientMessageBusImpl does re-init in case of SessionExpired by server, the getAdvertisableSubjects() method returns strange subjects.
      For example many pairs of:
      com.example.Service:RPC.unsubscribe:java.lang.String:java.lang.String::71:RespondTo:RPC
      and
      com.example.Service:RPC.unsubscribe:java.lang.String:java.lang.String::71:Errors:RPC
      or
      com.example.Service:RPC.subscribe:java.lang.String:com.example.Message::72:RespondTo:RPC
      and
      com.example.Service:RPC.subscribe:java.lang.String:com.example.Message::72:Errors:RPC

      As a consequence, the connection phase request will contain in the RemoteServices field all these subjects so they will end up on the server side in the remoteSubscriptions map which will increase indefinitely because of the auto-increment 71, 72 above.

      Basically, the client puts in the RemoteServices list all "messages" which remained unanswered because of SessionExpire by the server.

      Example of re-init connection phase RemoteServices list:

      "ClientBusErrors,ClientBus,cdi.event:ClientDispatcher,DTReceiver,BroadcastStopReceiver,CommandServiceReceiver,MessagingTopicReceiver,ServerControlReceiver,com.example.service.ChService,com.example.MessagingService:RPC.unsubscribe:java.lang.String:java.lang.String::71:RespondTo:RPC,com.example.MessagingService:RPC.unsubscribe:java.lang.String:java.lang.String::71:Errors:RPC,com.example.MessagingService:RPC.subscribe:java.lang.String:com.example.shared.MessageSelector::72:RespondTo:RPC,com.example.MessagingService:RPC.subscribe:java.lang.String:com.example.shared.MessageSelector::72:Errors:RPC,com.example.MessagingService:RPC.unsubscribe:java.lang.String:java.lang.String::73:RespondTo:RPC,com.example.MessagingService:RPC.unsubscribe:java.lang.String:java.lang.String::73:Errors:RPC,com.example.MessagingService:RPC.subscribe:java.lang.String:com.example.shared.MessageSelector::74:RespondTo:RPC,com.example.MessagingService:RPC.subscribe:java.lang.String:com.example.shared.MessageSelector::74:Errors:RPC,com.example.CommandService:RPC.serviceRequestAsync:com.example.command.CommandRequest::87:RespondTo:RPC,com.example.CommandService:RPC.serviceRequestAsync:com.example.command.CommandRequest::87:Errors:RPC,com.example.CommandService:RPC.serviceRequestAsync:com.example.command.CommandRequest::88:RespondTo:RPC,com.example.CommandService:RPC.serviceRequestAsync:com.example.command.CommandRequest::88:Errors:RPC,SSEAgent"

      Moreover, the subscriptions map on the client side will also grow indefinitely in such case.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mbarkley Max Barkley
                Reporter:
                ggaborg Gab And
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: