jasonmk / datastax_rails

A Ruby-on-Rails interface to Datastax Enterprise. Replaces the majority of ActiveRecord functionality.
MIT License
23 stars 9 forks source link

No live threads left while saving #33

Open AdamMarkowski opened 9 years ago

AdamMarkowski commented 9 years ago

Hi guys! I have trouble when trying to save object:

2.1.5 :001 > user = User.new(bio: 'test')
 => #<User id: nil, first_name: nil, user_name: nil, bio: "test", birthdate: nil, active: nil, created_at: nil, updated_at: nil> 
2.1.5 :002 > user.save!
fatal: No live threads left. Deadlock?
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/bundler/gems/ione-45e1f52da02d/lib/ione/future.rb:667:in `pop'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/bundler/gems/ione-45e1f52da02d/lib/ione/future.rb:667:in `value'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/gems/cql-rb-2.0.4/lib/cql/client/client.rb:553:in `block in prepare'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/gems/cql-rb-2.0.4/lib/cql/client.rb:60:in `synchronous_backtrace'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/gems/cql-rb-2.0.4/lib/cql/client/client.rb:553:in `prepare'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/bundler/gems/datastax_rails-eec9c50dd18d/lib/datastax_rails/cql/base.rb:42:in `block in execute'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/notifications.rb:164:in `block in instrument'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/notifications.rb:164:in `instrument'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/bundler/gems/datastax_rails-eec9c50dd18d/lib/datastax_rails/cql/base.rb:29:in `execute'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/bundler/gems/datastax_rails-eec9c50dd18d/lib/datastax_rails/persistence.rb:154:in `write_with_cql'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/bundler/gems/datastax_rails-eec9c50dd18d/lib/datastax_rails/persistence.rb:83:in `block (2 levels) in write'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/notifications.rb:166:in `instrument'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/bundler/gems/datastax_rails-eec9c50dd18d/lib/datastax_rails/persistence.rb:77:in `block in write'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/bundler/gems/datastax_rails-eec9c50dd18d/lib/datastax_rails/persistence.rb:76:in `tap'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@activiter/bundler/gems/datastax_rails-eec9c50dd18d/lib/datastax_rails/persistence.rb:76:in `write'
... 22 levels...
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
    from /Users/adammarkowski/IdeaProjects/Activiter/bin/rails:8:in `<top (required)>'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/adammarkowski/.rvm/gems/ruby-2.1.5@global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
    from /Users/adammarkowski/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/adammarkowski/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from -e:1:in `<main>'2.1.5 :003 > 

This is my User model:

class User < DatastaxRails::Base
  uuid    :id
  string  :first_name
  string  :user_name
  text    :bio
  date    :birthdate
  boolean :active
  timestamps
end

I've set ione and datastax_rails to github repositories at Gemfile, but this didn't change anything at all.

jasonmk commented 9 years ago

I've definitely seen this before, but right now I'm having trouble replicating it, and I can't remember for certain what the issue was.

Is that your full User model? Are there possibly any callbacks that make other database mods (like recording an audit log or similar)?

davidkelley commented 9 years ago

I've only ever encountered this issue, when attempting to save, update, etc. before a connection has been made to Cassandra. This only happened though when I attempted to use the gem outside of the normal Rails context (with aws-flow-ruby to be specific).

Hope this helps.

On Tuesday, 30 December 2014, Jason M. Kusar notifications@github.com wrote:

I've definitely seen this before, but right now I'm having trouble replicating it, and I can't remember for certain what the issue was.

Is that your full User model? Are there possibly any callbacks that make other database mods (like recording an audit log or similar)?

— Reply to this email directly or view it on GitHub https://github.com/jasonmk/datastax_rails/issues/33#issuecomment-68358734 .

AdamMarkowski commented 9 years ago

Actually this is my entire User model, nothing more at the beginning of setting up the project and playing around. Could it be caused by the environment config? I'm starting cassandra in a search mode next to the rvm with ruby 2.1.5 and rails 4.2 on mac os yosemite.

AdamMarkowski commented 9 years ago

This also occur when changed ruby to 2.0.0 and rails to 4.0.0

AdamMarkowski commented 9 years ago

It seems that cql-rb works fine: ''' 2.1.5 :001 > client = Cql::Client.connect(hosts: ['localhost']) 2.1.5 :002 > client.use('activiter_development') => nil 2.1.5 :014 > client.execute("INSERT INTO users (id, bio, user_name) VALUES (uuid(), '2013-02-24T10:14:23+0000', 'Rang bell, ate food');") => #Cql::Client::VoidResult:0x007fc05b9a10f0 2.1.5 :015 > 2.1.5 :015 > client.execute("select * from users") => #<Cql::Client::QueryResult:0x007fc05b978e20 ................ '''

jasonmk commented 9 years ago

Ok, one of the guys finally reminded me where I saw that issue before, but I don't think it's going to apply here. It was if you tried to execute a CQL query while you were in a byebug session. Byebug seemed to be locking the thread up. I don't suppose there's any chance that's happening here is it? I tried replicating what you described above with several versions of Ruby and Rails and couldn't make it happen.

marktermaat commented 9 years ago

I had a similar problem (though with any query, including where queries). In my case the problem was Spring. Try it by starting rails without spring ('DISABLE_SPRING=true rails c').