ruby-amqp / bunny

Bunny is a popular, easy to use, mature Ruby client for RabbitMQ
Other
1.39k stars 303 forks source link

Avoid race between multi-message ack and publish #635

Closed romuloceccon closed 2 years ago

romuloceccon commented 2 years ago

PR #617 introduced an optimization for multi-message acks but failed to protect @unconfirmed_set. In edge cases #basic_publish would attempt to modify it during iteration with Enumerable#min:

<ruby>/lib/ruby/3.1.0/set.rb:522:in `add': can't add a new key into hash during iteration (RuntimeError)
from <bunny>/lib/bunny/channel.rb:555:in `block in basic_publish'
from <bunny>/lib/bunny/channel.rb:554:in `synchronize'
from <bunny>/lib/bunny/channel.rb:554:in `basic_publish'
from <bunny>/lib/bunny/exchange.rb:141:in `publish'
michaelklishin commented 2 years ago

Thank you!