[jboss-user] [Remoting] - Race condition in ConnectionValidator

thammoud do-not-reply at jboss.com
Fri Feb 27 18:04:50 EST 2009


Hello,

I think we have stumbled upon a bug in the ConnectionValidator.

Scenario
pingPeriod is set to 10 seconds and pingTimeout is set to 70 seconds, client leasetime is 70 seconds. Using 2.2 SP11 on JDK 1.6 (Linux)

Ctrl-z the server for more than 20 seconds but less than 70 seconds. When the server is brought back to the foreground, the client's connection is closed even though the pingTimeout has not been exceeded. 

Given that the task took more than 10 seconds to complete (Server in the BG), the java Timer will immediately call the run method again with a very small window in which the WaitOnConnectionCheckTimerTask is still running (Waiting on a lock). By the time WaitOnConnectionCheckTimerTask breaks out of its wait, it reads an isValid that is set to false by the run method causing the connection to close.

I have a fix (Not sure if it optimal) that does the following:

- Make the tt (WaitOnConnectionCheckTimerTask) a class member (Must be volatile).

- Add  while(tt != null) {}
    tt = new WaitOnConnectionCheckTimerTask();
to the run method.

Clear tt at the when WaitOnConnectionCheckTimerTask is done.

I can reproduce this on my machine every time. Thanks.



View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4213894#4213894

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4213894



More information about the jboss-user mailing list