Giter VIP home page Giter VIP logo

Comments (4)

avalanche123 avatar avalanche123 commented on August 18, 2024

Ione version is 1.2 (using cassandra-driver 1.0.0)
Ruby versions are 1.9.3, 2.0 and 2.1
Linux version 3.13.0-24-generic (buildd@batsu) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1))

from ione.

iconara avatar iconara commented on August 18, 2024

Yes, it looks like there is a possibility that a socket can be closed between the #closed? check in the reactor and the IO.select. It's very curious that it doesn't happen on OS X. It also doesn't seem to happen in JRuby (on OS X at least, but it feels like it should be the same in Linux).

I have two solutions to this, but first a workaround: schedule a timer and close sockets in the callback.

reactor.schedule_timer(0).on_complete do
  session.close
end

The handler is always called from the reactor thread so this ensures that the socket is properly closed without any racing.

The simplest fix to the underlying issue is to remove line 32 of lib/ione/io/base_connection.rb (https://github.com/iconara/ione/blob/master/lib/ione/io/base_connection.rb#L32). This will cause IO.select to raise an IOError in the situation where it could now raise TypeError because of the nil IO. That is something that the reactor expects (because there's always the possibility that a socket will be closed).

Could you try that out and see if it helps? If it does I can make a bug fix release.

A better solution is to rewrite socket operations so that they are always performed from the reactor thread. This is basically what happens when connecting or writing; the action is buffered and only performed when the socket is ready. #close should probably just set a flag that is acted on just before the select call. This will probably have to wait a bit, but it feels like a more robust solution. There's been a few issues with socket closing, and trying to make it work with concurrent modifications will just make it more complicated without adding any benefits.

from ione.

avalanche123 avatar avalanche123 commented on August 18, 2024

I've introduced your suggestion here datastax/ruby-driver@8c45eee, this should resolve issues that we faced in the ruby-driver.

I do think that the simples quickfix is to not set @io to nil and let the regular error handling mechanism take care of cleaning up closed sockets, but we don't need it with the fix I mentioned above.

Thanks for your help!

from ione.

iconara avatar iconara commented on August 18, 2024

I'll re-open this to use as a reminder to fix the underlying issue. The workaround should be applicable to all users of Ione in the meantime, if someone stumbles on this issue,

from ione.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.