shashank created CAMEL-26865:
--------------------------------
Summary: camel-cluster - ClusteredRoutePolicy: a route that fails
to start when the node takes the leadership is never started again
Key: CAMEL-26865
URL: https://issues.apache.org/jira/browse/CAMEL-26865
Project: Camel
Issue Type: Bug
Components: camel-core
Reporter: shashank
Assignee: shashank
When the node takes the leadership, {{ClusteredRoutePolicy}} starts its routes
in a loop inside one try block, after it has set its leader flag:
* a route whose start fails (for example an endpoint that cannot connect yet at
takeover) is only logged, and nothing tries again: the leadership is already
taken, so only a later leadership change would start it. The node holds the
leadership and does not run the route, and no other node runs it either;
* the routes after it in the loop are not started at all.
The stop on a leadership loss has the same single try block: a route that fails
to stop keeps the routes after it running on a node that is no longer the
leader, and stays recorded as started, so it is not started again when the node
takes the leadership again.
{{MasterRoutePolicy}} (CAMEL-26540) and the camel-zookeeper-master consumer
(CAMEL-25315) retry a failed start while the node is the leader. A supervising
route controller does not help here: it skips the routes that the policy has
set to {{autoStartup=false}}.
Expected: each route is started and stopped on its own; a route that fails to
start is tried again while the node is the leader.
Suggested fix: start and stop each route in its own try block; keep a route
that failed to start with the stopped routes and start the stopped routes again
after a delay while the node is the leader; record a route that is no longer
running after a failed stop as stopped.
Found with Specula (TLA+ model checked against traces of the real code) and
confirmed with tests on the real classes.
_Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)