Azure / azure-service-bus

☁️ Azure Service Bus service issue tracking and samples
https://azure.microsoft.com/services/service-bus
MIT License
585 stars 781 forks source link

Service Bus Scheduled Message Count Is Negative #254

Closed rcreynolds53 closed 5 years ago

rcreynolds53 commented 5 years ago

Description

When cancelling scheduled messages without knowing the sequence number, I used the following code using the ServiceBus Message Receiver Class to peek at all messages and then cancel the scheduled messages async. Instead of stopping at zero, when there were no more messages to cancel, the service bus kept deleting messages from the scheduled queue and ended up with a negative number

CODE var messages = await messageReceiver.PeekAsync(250);
do { Console.WriteLine(messages.Count); await Task.WhenAll(messages.Select(m => { Console.WriteLine(m.SystemProperties.SequenceNumber); return queueClient.CancelScheduledMessageAsync(m.SystemProperties.SequenceNumber); })); messages = await messageReceiver.PeekAsync(250);
} while (messages.Count > 0);

Here is a picture of the message count: image

Actual Behavior

  1. Service bus is displaying a negative number for the scheduled messages

Expected Behavior

  1. When deleting the scheduled messages the service bus count should not be able to go negative.
axisc commented 5 years ago

Thanks for reporting this. we're tracking this internally.

calvaradocl commented 5 years ago

This is happening to me too, but I'm deleting the scheduled messages by their Sequence Number. Same negative information on both ServiceBusExplorer and Azure Portal.

axisc commented 5 years ago

we're currently working to fix this. I'll update and close this issue when we have sorted this out.

SeanFeldman commented 5 years ago

@axisc the label backlog is not exactly going along with your comment. Perhaps you meant to apply in-progress label?

aresowj commented 5 years ago

Hi @rcreynolds53 & @calvaradocl , just want to confirm for debugging purpose, was there any activities (scheduling / send / receive messages) while the cancellation was going on?

Also, is the piece of code running as a single instance? I.e., are there multiple instances of this code running in parallel maybe with cancelling faster in mind?

Thank you.

aresowj commented 5 years ago

Update: we have checked in the fix for both standard and premium messaging, the fix is expected to be included in the next major deployment.

JSCProjects commented 1 year ago

This is still happening within our subscriptions. Our sagas depend on scheduled messages and our ops team is complaining that they can't rely on this number.

jrgcubano commented 8 months ago

Same here. Still happening on our side.