Particular / NServiceBus.Azure

Transports and storage for Windows Azure
https://docs.particular.net/nservicebus/azure/
Other
10 stars 15 forks source link

Hotfix-6.0.8 CircularBuffer throws exception #273

Closed SeanFeldman closed 8 years ago

SeanFeldman commented 8 years ago

Who's affected

Anyone who's using Azure Service Bus transports and using Bus.Send() or Bus.Publish() in a very tight loop with multiple threads.

Symptoms

Due to a calculation error that can happen with concurrent access an IndexOutOfRangeException exception can be thrown


Reported in GG: https://groups.google.com/forum/#!topic/particularsoftware/a1GigfXhI94

CircularBuffer.Get() is not thread safe and may throw exception when used in concurrent mode

Repro:

Parallel.ForEach(hugeArray, new ParallelOptions() { MaxDegreeOfParallelism = 5 }, item =>
{
    Bus.Send(new SomethingCommand
    {
        Item = item
    });
});

Connects to Particular/NServiceBus.AzureServiceBus#59