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

   # Description
   
   [CAMEL-26969](https://issues.apache.org/jira/browse/CAMEL-26969)
   
   Follow-up of CAMEL-23937 and CAMEL-25701 (the Camel lock renewer). Found by 
the Service Bus DST world of CAMEL-26956 (branch 
`camel-azure-servicebus-dst-world-v2`, opened in the same batch): its default 
set accepts this case, and `-Ddst.servicebus.strictRenew=true` fails 27 of 1000 
seeds. Reproduced here with a plain unit test, outside the DST harness.
   
   The lock renewer of `ServiceBusConsumer` (peek-lock, 
`maxAutoLockRenewDuration` > 0) renews a lock that expires within its next two 
runs. When `renewalClient.renewMessageLock(message)` failed, the error callback 
removed the exchange from the renewer, whatever the error: the lock was never 
renewed again. In azure-messaging-servicebus 7.17 that call makes one request 
(javap of 7.17.16: no retry policy around `renewMessageLock`), so one transient 
error, such as a busy server or a connection being recovered, ended the 
renewal. The lock then expired while the exchange was still running, Service 
Bus delivered the message again, and the settlement of the first exchange 
failed with a lost lock.
   
   `ServiceBusException#isTransient` marks an error that can be retried. The 
processor of the Service Bus .NET SDK keeps renewing a lock after a transient 
renewal error and stops on any other (`ReceiverManager.RenewMessageLockAsync`: 
"if the error was not transient, break out of the loop"). The Camel renewer 
runs again 10 seconds later, while the lock still has time left.
   
   Change, in the lock renewer of `ServiceBusConsumer`: on a transient 
`ServiceBusException` the entry is kept (logged at WARN), so the next run 
renews the lock again; any other error removes it as before. The renewal still 
ends at `maxAutoLockRenewDuration`, when the exchange completes, or at a lost 
lock (`MESSAGE_LOCK_LOST` is not transient). No new state or thread: the error 
callback only leaves the entry where it is.
   
   Tests, in `ServiceBusConsumerTest`:
   - `lockRenewerRenewsAgainAfterATransientError`: the lock expires in 15 
seconds, the first renewal fails with a transient `ServiceBusException` 
(SERVER_BUSY), the next run renews again and succeeds, and the run after that 
leaves the renewed lock alone;
   - `lockRenewerStopsAfterTheLockIsLost`: a `MESSAGE_LOCK_LOST` error ends the 
renewal (a control, passes on main too).
   
   Without the change the first test fails (one renewal call, not two); with it 
the camel-azure-servicebus unit tests pass (77 run, 0 failures). With the 
change merged locally into the world of CAMEL-26956, the default set passes 
1000 of 1000, and `-Ddst.servicebus.strictRenew=true` fails 10 of 1000 seeds 
instead of 27. The 10 left are locks whose last renewal before expiry failed: 
the renewer renews a lock when less than two of its runs remain and runs every 
10 seconds or a second later, so a failure in the last run before expiry is 
retried too late (seed 113: renewal fails at t=59000, the lock expires at 
t=68958, the next run is at t=70000). The strict flag excuses no lost lock 
after an injected transient failure. Retrying at once within the same run would 
narrow that gap, but for a throttled request (ServiceBusy) the Service Bus 
documentation describes a 10 second back-off before the client sends more 
requests, which is about what waiting for the next run does; this change keeps t
 hat. The ITs need a Service Bus emulator and were not run locally (CI runs 
them).
   
   No documentation or upgrade guide change.
   
   Backport: camel-4.18.x has the same lock renewer.
   
   # 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-26969](https://issues.apache.org/jira/browse/CAMEL-26969).
   
   # 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-azure-servicebus and the core modules with the formatter 
and import-sort plugins and ran the camel-azure-servicebus unit tests. I did 
not run the full root build.)
   
   # 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