Closed paulbatum closed 2 years ago
Seems like the underlying issue here is that the retry logic here doesn't fully respect the CancellationToken passed in. In the loop it should check for cancellation before beginning a new attempt, and it should also pass the token in on the Task.Delay. If all of this is done, when the caller requests cancellation (e.g. due to a lost lease) retries will stop.
Fixed in track2: https://github.com/Azure/azure-sdk-for-net/pull/27340
When using a retry policy with an eventhub trigger, the retry loop should be cancelled if the lease is lost. If the retry loop is not cancelled, this will lead to duplicate message processing or potentially broken message ordering, where one machine is waiting to retry a message while another machine has already acquired the lease and started processing.
@alrod notes: