em-mongo icon indicating copy to clipboard operation
em-mongo copied to clipboard

undefined method `docs' for :disconnected:Symbol (NoMethodError)

Open wolframarnold opened this issue 11 years ago • 6 comments

Whenever EM::stop is run, the unbind handler seems to produce this stacktrace:

/Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-mongo-0.4.3/lib/em-mongo/collection.rb:739:in `block in safe_send': undefined method `docs' for :disconnected:Symbol (NoMethodError)
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-mongo-0.4.3/lib/em-mongo/connection.rb:186:in `call'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-mongo-0.4.3/lib/em-mongo/connection.rb:186:in `block in unbind'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-mongo-0.4.3/lib/em-mongo/connection.rb:186:in `each'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-mongo-0.4.3/lib/em-mongo/connection.rb:186:in `unbind'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/eventmachine-1.0.3/lib/eventmachine.rb:1440:in `event_callback'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/eventmachine-1.0.3/lib/eventmachine.rb:194:in `release_machine'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/eventmachine-1.0.3/lib/eventmachine.rb:194:in `run'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-synchrony-1.0.3/lib/em-synchrony.rb:38:in `synchrony'

Looking at the code of EMConnection#unbind#, it seems that it's the @responses array holds something other than callable objects:

    def unbind
      if @is_connected
        @responses.values.each { |resp| resp.call(:disconnected) }
        ...

What goes wrong here?

Update: I noticed that this only happens if an insert statement was run immediately prior to calling close on the connection/prior to EM::stop. If there are no pending writes, it unbinds cleanly.

wolframarnold avatar Aug 29 '13 00:08 wolframarnold

Not really sure. Im not actively maintaining this gem but if you have a PR to fix it I will merge!

bcg avatar Aug 29 '13 01:08 bcg

I can't say I understand the expected values in @responses enough to patch this. But as I wrote in my update just now I noticed this problem goes away if there aren't any writes immediately prior to EM::stop. Good enough for now for me. Thanks!

wolframarnold avatar Aug 29 '13 01:08 wolframarnold

@wolframarnold you can try my e-mongo fork (https://github.com/fl00r/em-mongo). I think I've pathced this bug time ago.

fl00r avatar Sep 04 '13 15:09 fl00r

@fl00r would you like collab access so you can push your changes here?

bcg avatar Sep 04 '13 20:09 bcg

@bcg thank you for offer, but I am not sure if I could maintain em-mongo because we use monga gem in production. Hello to Charlottesville and to Blue Moon anyway! ;)

fl00r avatar Sep 04 '13 20:09 fl00r

Thank you.

Much appreciated.

Wolf

On Wed, Sep 4, 2013 at 8:43 AM, Peter Yanovich [email protected]:

@wolframarnold https://github.com/wolframarnold you can try my e-mongo fork (https://github.com/fl00r/em-mongo). I think I've pathced this bug time ago.

— Reply to this email directly or view it on GitHubhttps://github.com/bcg/em-mongo/issues/48#issuecomment-23799883 .

www.RubyFocus.biz --- San Francisco --- direct: 650-576-9048

wolframarnold avatar Sep 05 '13 02:09 wolframarnold