No active Transaction was found for ID
See original GitHub issueDescribe the bug
When performing transactional processing (using TransactionScope
and send-via feature) of messages concurrently, using multiple message senders, the System.InvalidOperationException
exception is thrown.
Exception or Stack Trace
System.InvalidOperationException: No active Transaction was found for ID 'txn:9e879b829a0e446d97d6ac7625862833:9_G5'. The Transaction may have timed out or attempted to span multiple top-level entities such as Queue or Topic. The server Transaction timeout is: 00:02:00. Reference:fbcf536a-d67a-4a0f-8fb7-7532b8360f78, TrackingId:44c4b18d00000014000024ca5c5832b5_G5_B7, SystemTracker:SOMSYSTEMNAME:Queue:SOMEQUEUENAME, Timestamp:2019-02-04T12:40:21
at Microsoft.Azure.ServiceBus.Core.MessageSender.OnSendAsync(IList`1 messageList)
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)
at Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync(IList`1 messageList)
at NServiceBus.TransportReceiveToPhysicalMessageProcessingConnector.Invoke(ITransportReceiveContext context, Func`2 next)
at NServiceBus.MainPipelineExecutor.Invoke(MessageContext messageContext)
at NServiceBus.Transport.AzureServiceBus.MessagePump.ProcessMessage(Task`1 receiveTask)
To Reproduce
Repro code is located in https://github.com/SeanFeldman/TransactionIssueRepro, TransactionIssueRepro.sln
Sender
project is seeding the receiver’s queue with messagesReceiver
project is logging message processing.- For each processed message, ten outgoing messages are emitted
Code Snippet
See the previous section
Expected behavior
There should be no exceptions.
Screenshots
N/A
Setup (please complete the following information):
- OS: Windows 10 Pro 1903
- IDE : VS 2019 16.1.3
- Azure Service Bus 3.4.0 / netcoreapp2.2
Additional context
When concurrency is set to one and a single outgoing MessageSender
is used, this exception is not thrown. Whenever concurrency is higher than one, the exception is thrown.
Originally reported by NServiceBus customers using Azure Service Bus transport here. My investigation led to the native repro w/o NServiceBus code in it.
All NServiceBus customers on ASB transport with transactions enabled are affected 🐼
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:18 (16 by maintainers)
Top GitHub Comments
@jfggdl I’ve re-run a test and it looks like the fix is in place 🎉 Thank you and the team on my and my customers’ behalf.
@SeanFeldman , the bug is being worked on. The repro code is doing its job just fine! (y)