nuclearsandwich@gmail.com
2011-Jul-12 19:11 UTC
Error when accessing ActiveRecord 3.1.0.rc4 database from Resque worker
I am using ActiveRecord in a Sinatra application that uses Resque for background tasks. I wanted to try out the 3.1rc in order to play with serialization strategies. When switching to ActiveRecord 3.1rc4 my application''s unit and spec tests all pass but when running a Resque working in it''s own process I get the following stack trace: PGError: ERROR: prepared statement "a3" already exists : SELECT "channels".* FROM "channels" WHERE "channels"."id" = $1 LIMIT 1 /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/postgresql_adapter.rb:964:in `prepare'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/postgresql_adapter.rb:964:in `exec_cache'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/postgresql_adapter.rb:548:in `block in exec_query'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract_adapter.rb:222:in `block in log'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activesupport-3.1.0.rc4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract_adapter.rb:217:in `log'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/postgresql_adapter.rb:546:in `exec_query'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/postgresql_adapter.rb:1027:in `select'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/database_statements.rb:9:in `select_all'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/base.rb:473:in `find_by_sql'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/relation.rb:109:in `to_a'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/relation/finder_methods.rb:370:in `find_first'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/relation/finder_methods.rb:122:in `first'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/relation/finder_methods.rb:328:in `find_one'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/relation/finder_methods.rb:304:in `find_with_ids'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/relation/finder_methods.rb:107:in `find'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/activerecord-3.1.0.rc4/lib/active_record/base.rb:444:in `find'' /Users/steven/Code/ruby/aji/queues/populate_channel.rb:10:in `perform'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/resque-1.17.1/lib/resque/job.rb:127:in `perform'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/resque-1.17.1/lib/resque/worker.rb:163:in `perform'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/resque-1.17.1/lib/resque/worker.rb:130:in `block in work'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/resque-1.17.1/lib/resque/worker.rb:116:in `loop'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/resque-1.17.1/lib/resque/worker.rb:116:in `work'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@aji/gems/resque-1.17.1/lib/resque/tasks.rb:27:in `block (2 levels) in <top (required)>'' /Users/steven/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'' ... rest is just rake. The failing code is simply ``` class PopulateChannel def self.perform channel_id Channel.find(channel_id).populate end end ``` which runs fine in all cases using ActiveRecord 3.0.4. This is my first post to rails-core and first bug report to a mailing list. If there is any better or further information I can provide I will be more than happy to do so. Thanks, -- Steven! Ragnarök T 408 256 0278 steven@nuclearsandwich.com http://nuclearsandwich.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.