allthingssecurity opened a new pull request, #30817:
URL: https://github.com/apache/camel/pull/30817

   # Description
   
   [CAMEL-27503](https://issues.apache.org/jira/browse/CAMEL-27503)
   
   Each connection of the milo-client `SubscriptionManager` has its own Milo 
delivery queue. When a connection is torn down because a service call failed (a 
CreateMonitoredItems of a consumer that starts, a recreate, a delete), 
`handleConnectionFailure` queues its loss report behind the values it still has 
queued, and that queue keeps running. With a slow route on the old queue this 
order was possible:
   
   1. connection 1 still has a value V1 of the node queued;
   2. connection 1 is torn down, and its loss report L1 is queued behind V1;
   3. connection 2 connects and delivers the current value of the node;
   4. connection 2 loses its session, and its loss report L2 
(`Bad_NoCommunication`) is delivered;
   5. the queue of connection 1 goes on: V1 is delivered (Good), and L1 is 
dropped because connection 2 delivered a value.
   
   The consumer ended with a Good value while communication was lost, until the 
session or the server came back. The generation check added by CAMEL-25835 
guards the loss reports, not the values. When the connection is torn down by 
`onTransferFailed`, Milo discards the queued values, so that path was not 
affected.
   
   Change: the node keeps the generation of the newest connection whose loss 
report it delivered, and `deliver` drops a value of an older connection (DEBUG 
log). The loss report then stays the status of the node until the current 
connection delivers a value. An old value that arrives after the first value of 
the new connection, but before any newer loss report, is still delivered, as 
the component page already says ("a value received before Camel rebuilt the 
connection can arrive after the first value of the new connection"). That page 
now adds that such a value does not arrive after a loss report of the new 
connection (catalog copy updated). A refusal status of an old connection goes 
through the same check.
   
   Behaviour for users: only the late value in the order above is no longer 
delivered. No option or default changes, so no upgrade guide entry.
   
   Not changed here (found by the same analysis, both low):
   - an `Error` (not an `Exception`) thrown during a reconnect or a retry of 
refused nodes ends those attempts for good, because the task only catches 
`Exception` and nothing schedules the next attempt;
   - the discovery of the endpoints during a connect builds a `DiscoveryClient` 
whose own timeouts (60 s) apply, not `requestTimeout`, so one attempt against a 
server that stops answering after the handshake takes about a minute.
   
   I will file a ticket for each.
   
   Test: a new method in `CommunicationLossTest`, 
`valueOfAReplacedConnectionDoesNotEndTheLossReportOfItsReplacement` 
(package-private, real `SubscriptionManager`, the in-JVM Milo test server and 
the test's TCP relay, no sleep). The route of a second node on the same 
subscription blocks on a value, and a change of the first node is queued behind 
it on the delivery queue of connection 1. The relay goes silent, the 
CreateMonitoredItems of the next consumer times out, and the connection is 
rebuilt. Connection 2 delivers the value, then the relay stops and the node 
gets `Bad_NoCommunication`. The blocked route is released and the test waits 
until the queue of connection 1 is empty: the node must still end with 
`Bad_NoCommunication`. The test adds a second server item (`myitem2`) to the 
routes of the class.
   
   It fails on main (3 of 3 runs: the node ends with the Good value of 
connection 1). With the change the unit tests of camel-milo pass (134 run, 0 
failures, 1 skipped), the new test passes 20 of 20 runs, and the whole 
`CommunicationLossTest` class passes 3 of 3 runs.
   
   A TLA+ model of the delivery of values and loss reports of one node across 
connection generations found it: "a value of an older connection is never 
delivered after a loss report of a newer one" fails on main.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it): 
[CAMEL-27503](https://issues.apache.org/jira/browse/CAMEL-27503).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built camel-milo and the core modules with the formatter and 
import-sort plugins and ran the module's unit tests, offline. I did not run the 
full root build. The component page changed, and I copied it to the catalog by 
hand; no option or other generated file changed.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to