Comments (4)
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.
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.
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.
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)
- ione as dependency for cql-rb generate error in fluentd HOT 8
- Ione::Future.all([]) broken
- Performance problems when many timers are scheduled HOT 3
- Sockets disconnects are not discovered when the connection is cut by a middleman (VPN, NAT or other device) HOT 10
- Schedule work on next tick
- Future.after can lead to stack overflow errors with completed futures
- Support SSL connections HOT 12
- Make the reactor restartable HOT 1
- EAGAIN / EWOULDBLOCK Error HOT 3
- Issue with cassandra ruby driver, timecop and ione HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ione.