[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    


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

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


public String internalGetResource()
    if (result != null) {
     if (maxConnectionUsage_ > 0) {
     if (poolLifeCycleListener != null) {
          //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 ]


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.

@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;★

could you please confirm it and give me some suggestions?

Comment by boernd [ 13/Dec/13 ]


we also got this phenomenon of negative values (gf 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;                
Generated at Tue Dec 01 22:55:42 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.