Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid race between multi-message ack and publish #635

Merged
merged 1 commit into from
Sep 11, 2022

Conversation

romuloceccon
Copy link
Contributor

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'

PR ruby-amqp#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 michaelklishin merged commit 52a953b into ruby-amqp:main Sep 11, 2022
@michaelklishin
Copy link
Member

Thank you!

@michaelklishin michaelklishin added this to the 2.20 milestone Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants