glassfish
  1. glassfish
  2. GLASSFISH-16843

Negative value reported for "number of open connections"

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.0
    • Component/s: grizzly-kernel
    • Labels:
      None
    • Environment:

      Mac OS X 10.6, glassfish 3.1

      Description

      Turn monitoring to "HIGH" for WebContainer and HttpService. Executed the following CLI command :
      get -m server.http-service.__asadmin.request.countopenconnections-count

      Result :
      server.http-service.__asadmin.request.countopenconnections-count = -148

        Activity

        Hide
        Amy Roh added a comment -

        ConnectionMonitor monitors the number of open connections via onAcceptEvent and onCloseEvent methods. The onAcceptEvent method only invokes the connectionAcceptedEvent and therefore increasing the open connection count if the connection's peer address is not NULL. However, the onCloseEvent method invokes the connectionClosedEvent and decrease the count regardless of the connection's peer address. This is causing the count to be a negative number.

        @Override
        public void onAcceptEvent(final Connection connection) {
        final Object peerAddress = connection.getPeerAddress();

        if (peerAddress != null)

        { // if peerAddress is null - it's a server connection. we should skip. grizzlyMonitoring.getConnectionQueueProbeProvider().connectionAcceptedEvent( monitoringId, connection.hashCode(), peerAddress.toString()); }

        }

        @Override
        public void onCloseEvent(Connection connection)

        { grizzlyMonitoring.getConnectionQueueProbeProvider().connectionClosedEvent( monitoringId, connection.hashCode()); }

        It appears that ConnectionMonitor#onAcceptEvent(final Connection connection) is always called with peer address NULL and the open connection count never gets incremented.

        Assigning to Alexey to investigate why grizzly connection peer address is always NULL.

        Show
        Amy Roh added a comment - ConnectionMonitor monitors the number of open connections via onAcceptEvent and onCloseEvent methods. The onAcceptEvent method only invokes the connectionAcceptedEvent and therefore increasing the open connection count if the connection's peer address is not NULL. However, the onCloseEvent method invokes the connectionClosedEvent and decrease the count regardless of the connection's peer address. This is causing the count to be a negative number. @Override public void onAcceptEvent(final Connection connection) { final Object peerAddress = connection.getPeerAddress(); if (peerAddress != null) { // if peerAddress is null - it's a server connection. we should skip. grizzlyMonitoring.getConnectionQueueProbeProvider().connectionAcceptedEvent( monitoringId, connection.hashCode(), peerAddress.toString()); } } @Override public void onCloseEvent(Connection connection) { grizzlyMonitoring.getConnectionQueueProbeProvider().connectionClosedEvent( monitoringId, connection.hashCode()); } It appears that ConnectionMonitor#onAcceptEvent(final Connection connection) is always called with peer address NULL and the open connection count never gets incremented. Assigning to Alexey to investigate why grizzly connection peer address is always NULL.
        Hide
        oleksiys added a comment -

        just to make sure, it's Glassfish 3.2 related?

        Show
        oleksiys added a comment - just to make sure, it's Glassfish 3.2 related?
        Hide
        oleksiys added a comment -

        ping

        Show
        oleksiys added a comment - ping
        Hide
        Jennifer Chou added a comment -

        Forum user is also having an issue seeing negative activesessionscurrent.
        http://forums.java.net/node/844876

        Show
        Jennifer Chou added a comment - Forum user is also having an issue seeing negative activesessionscurrent. http://forums.java.net/node/844876
        Hide
        Amy Roh added a comment -

        I see that the part of the condition that was causing the discrepancy has been removed in 48946.

        bash-3.2$ svn diff -r48076:48946 ConnectionMonitor.java
        Index: ConnectionMonitor.java
        ===================================================================
        — ConnectionMonitor.java (revision 48076)
        +++ ConnectionMonitor.java (revision 48946)
        @@ -61,15 +61,13 @@
        }

        @Override

        • public void onAcceptEvent(final Connection connection) {
        • final Object peerAddress = connection.getPeerAddress();
          + public void onAcceptEvent(final Connection serverConnection,
          + final Connection clientConnection) {
          + final Object peerAddress = clientConnection.getPeerAddress();
        • if (peerAddress != null) { // if peerAddress is null - it's a server connection. we should skip. - grizzlyMonitoring.getConnectionQueueProbeProvider().connectionAcceptedEvent( - monitoringId, connection.hashCode(), - peerAddress.toString()); - - }

          + grizzlyMonitoring.getConnectionQueueProbeProvider().connectionAcceptedEvent(
          + monitoringId, clientConnection.hashCode(),
          + peerAddress.toString());
          }

        Show
        Amy Roh added a comment - I see that the part of the condition that was causing the discrepancy has been removed in 48946. bash-3.2$ svn diff -r48076:48946 ConnectionMonitor.java Index: ConnectionMonitor.java =================================================================== — ConnectionMonitor.java (revision 48076) +++ ConnectionMonitor.java (revision 48946) @@ -61,15 +61,13 @@ } @Override public void onAcceptEvent(final Connection connection) { final Object peerAddress = connection.getPeerAddress(); + public void onAcceptEvent(final Connection serverConnection, + final Connection clientConnection) { + final Object peerAddress = clientConnection.getPeerAddress(); if (peerAddress != null) { // if peerAddress is null - it's a server connection. we should skip. - grizzlyMonitoring.getConnectionQueueProbeProvider().connectionAcceptedEvent( - monitoringId, connection.hashCode(), - peerAddress.toString()); - - } + grizzlyMonitoring.getConnectionQueueProbeProvider().connectionAcceptedEvent( + monitoringId, clientConnection.hashCode(), + peerAddress.toString()); }
        Hide
        oleksiys added a comment -

        fixed

        Show
        oleksiys added a comment - fixed

          People

          • Assignee:
            oleksiys
            Reporter:
            sirajg
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: