[jboss-jira] [JBoss JIRA] Created: (JBAS-6874) TimerImpl should set ACTIVE state before scheduling to avoid race condition

Galder Zamarreño (JIRA) jira-events at lists.jboss.org
Wed May 6 11:59:58 EDT 2009


TimerImpl should set ACTIVE state before scheduling to avoid race condition
---------------------------------------------------------------------------

                 Key: JBAS-6874
                 URL: https://jira.jboss.org/jira/browse/JBAS-6874
             Project: JBoss Application Server
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: Scheduling/Timers
    Affects Versions: JBossAS-5.1.0.CR1, JBossAS-5.1.0.Beta1, JBossAS-5.0.1.GA, JBossAS-5.0.0.GA, JBossAS-4.2.3.GA, JBossAS-4.2.2.GA, JBossAS-4.2.1.GA, JBossAS-4.2.0.GA, JBossAS-4.0.5.GA
            Reporter: Galder Zamarreño
            Assignee: Galder Zamarreño
             Fix For: JBossAS-5.1.0.GA, JBossAS-6.0.0.Alpha1
         Attachments: server.log

TimerImpl sets ACTIVE state after it's scheduled the timer task which means that you can have a race 
condition leading to something like this:

2009-04-28 18:55:03,370 45084 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (ScannerThread:) setTimerState: created
2009-04-28 18:55:03,372 45086 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-2[target=jboss.j2ee:service=EJB3,jar=acme-ejb3.jar,name=ProblematicTimerManagerProxyBean]:) run: [id=2,target=[target=jboss.j2ee:service=EJB3,jar=acme-ejb3.jar,name=ProblematicTimerManagerProxyBean],remaining=-438372,periode=0,created]
2009-04-28 18:55:03,372 45086 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-2[target=jboss.j2ee:service=EJB3,jar=acme-ejb3.jar,name=ProblematicTimerManagerProxyBean]:) setTimerState: in_timeout
2009-04-28 18:55:03,372 45086 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (ScannerThread:) setTimerState: active 

Sometimes, the timer can kick off even before it's timer state has been set to active, which means that active state will be set after in_timeout. 
What's the effect of this? After the timer has executed, this means that the finally clause in TimerTaskImpl.run() won't be executed and hence, 
the timer won't be deleted from the database. This leads to multiple timer executions.

Please find attached a thread dump where you can see EJB-Timer-1 being executed correctly, including removal from database, but EJB-Timer-2 is not.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       




More information about the jboss-jira mailing list