-
Notifications
You must be signed in to change notification settings - Fork 207
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
NameError: instance variable @cluster not defined #332
Comments
This is the method in question
I don't see how this could ever work. In MRI, no two threads can run at the same time, but a thread can still be preempted anywhere. Thus, if two threads wind up in this method at the same time they are likely to both wind up inside the ' |
This is a bit farther off topic, but the way we use this gem is in a ruby on rails application that runs sidekiq jobs. Each sidekiq job basically just writes things into Cassandra. The web requests read things from Cassandra. I've looked at the underlying architecture of the cassandra driver gem, and it appears to be a "better than naive" implementation. Other than the lock in this class, this gem basically is just a wrapper around that gem. The behavior in this method also explains other behavior I've seen, namely that the policies you can specify in the Cassandra driver seem to have little effect. Since this gem clears MRI isn't exactly known for being a great parallel processing platform, but what I discovered is that Sidekiq has a default of 25 threads. I was seeing the production system deadlock completely when upgrading to Cequel 2.0.x from 1.x. I dropped the thread count to 5 threads in Sidekiq. The deadlocks went away, the system throughput remained the same, and the time spent dropped significantly. This isn't really a problem, but is something to be aware of. Unless the memory footprint of your application is enormous you are probably better off running a large number of MRI instances each with a small number of application threads. |
@pezra @hydrogen18 does it possible to use connection pooling somehow to avoid this? AFAIK, pool was a config attribute in cequel v1. Should I manage pool by myself now with https://github.com/mperham/connection_pool or it's not possible with cequel v3? Problem is that I can't decrease concurrency of Sidekiq to 5 :-( |
@hydrogen18 I've found that underlying https://github.com/datastax/ruby-driver supports pooling since early 2016. Have you had a chance to test it with your setup? To manage pool, I can configure it like this:
But I'm curious if it plays well with cequel, since it should solve your problem, but you didn't mention this. |
Judging from the if statement, this must be the result of a race condition. We're running Cequel in sidekiq when this happens
Stack trace of the frames that are in the
cequel
gemThe text was updated successfully, but these errors were encountered: