Claus Ibsen created CAMEL-26313:
-----------------------------------

             Summary: camel-core - ThrottlingExceptionRoutePolicy: raising 
halfOpenAfter while the circuit is open leaves the route suspended for good
                 Key: CAMEL-26313
                 URL: https://issues.apache.org/jira/browse/CAMEL-26313
             Project: Camel
          Issue Type: Bug
          Components: camel-core
            Reporter: Claus Ibsen
             Fix For: 4.24.0


While the circuit is open, the route's consumer is suspended, and only the 
half-open timer calls {{calculateState(route)}} again. The timer is scheduled 
with the value of {{halfOpenAfter}} at the time the circuit opened 
({{addHalfOpenTimer}}, {{timer.schedule(new HalfOpenTask(route, timer), 
halfOpenAfter)}}).

{{halfOpenAfter}} can be changed at runtime through {{setHalfOpenAfter}}, which 
JMX exposes ({{ManagedThrottlingExceptionRoutePolicy.setHalfOpenAfter}}). If it 
is raised while the circuit is open, the timer fires after the old value and 
{{calculateState}} goes into the STATE_OPEN branch:

{code:java}
long elapsedTimeSinceOpened = TimeSource.currentTimeMillis() - openedAt;
if (halfOpenAfter <= elapsedTimeSinceOpened) {
    ...
} else {
    LOG.debug("Keeping circuit open (time not elapsed)...");
}
{code}

The "time not elapsed" branch schedules no new timer. The consumer is 
suspended, so no exchange arrives to call {{calculateState}} again, and the 
route stays suspended until it is restarted.

h4. Example
# {{halfOpenAfter=10000}}, the circuit opens at t=0, and the timer is due at 
t=10s.
# At t=5s, an operator sets {{HalfOpenAfter}} to 60000 over JMX.
# At t=10s, the timer fires: elapsed 10000 < 60000, nothing is scheduled, and 
the circuit stays open for good.

h4. Proposed change
In the "time not elapsed" branch, schedule the timer again for the time that is 
left ({{halfOpenAfter - elapsedTimeSinceOpened}}), or call 
{{addHalfOpenTimer(route)}} as the keepOpen branch does. A test can open the 
circuit, raise {{halfOpenAfter}}, and assert that the route half-opens after 
the new delay.

Related: CAMEL-26104 (half-open timer through the ExecutorServiceManager) and 
CAMEL-26291 (failure window counting) touch the same class, but neither fixes 
this.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to