defunkt/resque — Issue #433: Re-Entrant Jobs Fail with PG error....
Author: tpletcher
Created: 2011-10-19 17:25:19+00:00
State: open

Ok, I have a Resque job that takes an uploaded video file and sends it off to panda to initiate the encoding process. after a server restart the first video sent for encoding works fine, but the next one sent fails with the following output:

PandaEncoding
Arguments

22

Exception
ActiveRecord::StatementInvalid
Error
PGError: ERROR: prepared statement "a3" already exists : SELECT COUNT(*) FROM pg_tables WHERE tablename = $1 AND schemaname = ANY (current_schemas(false))

/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:1009:in `prepare'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:1009:in `exec_cache'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `block in exec_query'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activesupport-3.1.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:590:in `exec_query'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:720:in `table_exists?'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/attribute_methods/primary_key.rb:41:in `get_primary_key'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/attribute_methods/primary_key.rb:25:in `reset_primary_key'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/attribute_methods/primary_key.rb:16:in `primary_key'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/base.rb:954:in `instantiate'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/base.rb:470:in `block in find_by_sql'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/base.rb:470:in `collect!'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/base.rb:470:in `find_by_sql'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/relation.rb:111:in `to_a'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/relation/finder_methods.rb:376:in `find_first'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/relation/finder_methods.rb:122:in `first'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/relation/finder_methods.rb:263:in `find_by_attributes'
/Users/tpletcher/.rvm/gems/ruby-1.9.2-p290@barz/gems/activerecord-3.1.1/lib/active_record/base.rb:1063:in `method_missing'
/Users/tpletcher/barzmedia31/app/workers/panda_encoding.rb:5:in `perform'

Since the job runs properly the first time, i'm thinking its not the job itself. note that I am using the branched version of the repo to deal with the dead worker pruning on heroku...