-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Library name and version
Azure.Messaging.ServiceBus 7.18.4
Describe the bug
When using ServiceBusSessionProcessor to process messages from sessions and in the event of SessionLockLost due to ConnectionReset during processing a message M1,we are observing
a new connection is being created immediately and the M1 getting redelivered and processed by a separate invocation of ProcessMessageHandler.
The initial invocation of ProcessMessageHandler processing M1 is unaware of a ConnectionReset event.
Neither SessionLockProcessSessionMessageEventArgs.CancellationToken is getting canceled nor SessionLockLostAsync event is being raised.
This is leading to a situation where there is no way handle an occurence of event like this in our code and
2 instances of M1 are being concurrently processed.
Expected behavior
SessionLock lost due to ConnectionReset should be captured by either SessionLockProcessSessionMessageEventArgs.CancellationToken
or SessionLockLostAsync event and allow us handle this event appropriately in code.
Actual behavior
Neither SessionLockProcessSessionMessageEventArgs.CancellationToken is getting canceled nor SessionLockLostAsync event is being raised
when session-lock is lost due to ConnectionReset.
Any subsequent operation on the message (either settle the message, release session etc.) results in SessionLockLostException due to ConnectionReset.
Reproduction Steps
Attaching a simple project to repro the issue but defining the high level steps here:
- Create a queue with sessions enabled and following settings
MaxDeliveryCount = 10
DefaultMessageTimeToLive = TimeSpan.FromMinutes(60)
LockDuration = TimeSpan.FromSeconds(60)
RequiresSession = true
- Queue a message M1 with session S1
- Create a ServiceBusSessionProcessor with following settings
ReceiveMode = ServiceBusReceiveMode.PeekLock
MaxConcurrentSessions = 5
MaxConcurrentCallsPerSession = 1
MaxAutoLockRenewalDuration = Timeout.InfiniteTimeSpan
AutoCompleteMessages = false
- Setup ProcessMessageHandler to honor cancellationToken and listen to SessionLockLostAsync events
- Recieve M1
- Force close connection using SysInternals-TcpView
- Observation: M1 gets redelivered immediately and neither is cancellationToken being canceled nor SessionLockLostAsync being invoked.
SessionLockLostConnectionReset.zip
Environment
.NET SDK:
Version: 8.0.407
Commit: cac65f27eb
Workload version: 8.0.400-manifests.011c56c6
MSBuild version: 17.11.26+2b19be476
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.407\
Host:
Version: 9.0.3
Architecture: x64
Commit: 831d23e561
.NET SDKs installed:
6.0.427 [C:\Program Files\dotnet\sdk]
8.0.407 [C:\Program Files\dotnet\sdk]
9.0.201 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Visual Studio : Version 17.13.4
Metadata
Metadata
Assignees
Labels
Type
Projects
Status