[GLASSFISH-19416] the value of monitor becomes negative value Created: 07/Dec/12  Updated: 13/Dec/13

Status: Open
Project: glassfish
Component/s: monitoring
Affects Version/s: 3.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: jifeng Assignee: Byron Nevins
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File JdbcConnPoolSatasProvider.patch     PNG File numConnFree.PNG    

 Description   

I execute under two commands:
1.set resources.jdbc-connection-pool.oracle_pool.pooling=false
2.enable-monitoring --modules jdbc-connection-pool=HIGH

then I get three jdbc connections from oracle_pool by my application.
at this time I find the value of "numconnfree-current" which become negative value



 Comments   
Comment by jifeng [ 07/Dec/12 ]

I think the code which is marked as "★" has problem
because there is no connection in the pool when the state of pool is unpooling

ConnectionPool.java

public String internalGetResource()
{   
    ........
    if (result != null) {
     if (maxConnectionUsage_ > 0) {
           result.incrementUsageCount();
     }
     if (poolLifeCycleListener != null) {
           poolLifeCycleListener.connectionUsed(result.getId());
          //Decrement numConnFree
          poolLifeCycleListener.decrementNumConnFree(); "★" 
     }
    }
}
Comment by jifeng [ 07/Dec/12 ]

I create a patch and it works fine, cloud you please confirm it.

Comment by jifeng [ 07/Dec/12 ]

I modify this method : JdbcConnPoolSatasProvider#decrementNumConnFreeEvent

Comment by jifeng [ 01/Aug/13 ]

Hi:

Byron Nevins

I find This phenomenon also occurs in glassfish v4 .

I added one line of code which is marked as "★" , and it works fine.

com.sun.enterprise.resource.pool.monitor.JdbcConnPoolStatsProvider.java
@ProbeListener(JDBC_PROBE_LISTENER + "decrementNumConnFreeEvent")
    public void decrementNumConnFreeEvent(
        @ProbeParam("poolName") String poolName,
        @ProbeParam("appName") String appName,
        @ProbeParam("moduleName") String moduleName
     ) {
     ......
        synchronized(numConnFree) {
            long numConnFreeToSet = (numConnFree.getCurrent() - 1 >= 0) ? numConnFree.getCurrent() - 1 : 0;★
            numConnFree.setCurrent(numConnFreeToSet);
        }
     }
    }

could you please confirm it and give me some suggestions?

Comment by boernd [ 13/Dec/13 ]

Hi,

we also got this phenomenon of negative values (gf 3.1.2.2) with the numConnUsed count. I changed the decrementConnectionUsedEvent method the same way:

            //Decrement numConnUsed counter
            synchronized(numConnUsed) {
                long numConnUsedToSet = (numConnUsed.getCurrent() - 1 >= 0) ? numConnUsed.getCurrent() - 1 : 0;                
                numConnUsed.setCurrent(numConnUsedToSet);
            }
Generated at Tue Mar 31 07:38:57 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.