rabbitmq / rabbitmq-stream-dotnet-client

RabbitMQ client for the stream protocol
https://rabbitmq.github.io/rabbitmq-stream-dotnet-client/stable/htmlsingle/index.html
Other
122 stars 41 forks source link

[edge case] Error during reconnect if the stream in the meantime is delete #335

Closed Gsantomaggio closed 10 months ago

Gsantomaggio commented 11 months ago

Describe the bug

This bug occurs when a stream is deleted while the Consumer is trying to re-connect. In most of case it works because the Metadata does the check.

but during the check and restart of the consumer, the stream could be deleted. [here the edge case]

Unhandled exception. RabbitMQ.Stream.Client.CreateConsumerException: consumer could not be created code: StreamDoesNotExist
   at RabbitMQ.Stream.Client.StreamSystem.CreateRawConsumer(RawConsumerConfig rawConsumerConfig, ILogger logger) in //rabbitmq-stream-dotnet-client/RabbitMQ.Stream.Client/StreamSystem.cs:line 441
   at RabbitMQ.Stream.Client.Reliable.ConsumerFactory.StandardConsumer(Boolean boot) in //rabbitmq-stream-dotnet-client/RabbitMQ.Stream.Client/Reliable/ConsumerFactory.cs:line 80
   at RabbitMQ.Stream.Client.Reliable.ConsumerFactory.CreateConsumer(Boolean boot) in //rabbitmq-stream-dotnet-client/RabbitMQ.Stream.Client/Reliable/ConsumerFactory.cs:line 33
   at RabbitMQ.Stream.Client.Reliable.Consumer.CreateNewEntity(Boolean boot) in //rabbitmq-stream-dotnet-client/RabbitMQ.Stream.Client/Reliable/Consumer.cs:line 186
   at RabbitMQ.Stream.Client.Reliable.ReliableBase.Init(Boolean boot, IReconnectStrategy reconnectStrategy) in //rabbitmq-stream-dotnet-client/RabbitMQ.Stream.Client/Reliable/ReliableBase.cs:line 89
   at RabbitMQ.Stream.Client.Reliable.ReliableBase.Init(IReconnectStrategy reconnectStrategy) in //rabbitmq-stream-dotnet-client/RabbitMQ.Stream.Client/Reliable/ReliableB

Reproduction steps

  1. Run multi consumers
  2. Delete the streams

Most of the time it works but it could happen that the stream is deleted just after the check streamExist

...

Expected behavior

Close the consumer. Need to check the error code: ConsumerFactory::StandardConsumer When it is not the first boot. If there is an error just close the consumer.

Same for Producer

Additional context

No response