jstorimer/delayed_paperclip — Issue #59: PGError in process_job (delayed_paperclip.rb)
Author: leonelgalan
Created: 2012-02-08 19:37:07+00:00
State: open

paperclip: 2.4.5
delayed_paperclip: 2.4.5.1

I'm hosted in Heroku and I'm uploading an image to S3 using Paperclip. The weird part is that the image gets uploaded sometimes and sometimes the job fails. I think this issue might be similar to #32, but that code is no longer relevant.

The failed job is:

```
Worker: 265c393b-5c64-4b94-b243-602683ffeccd:1 on PAPERCLIP at just now Retry or Remove
Class: DelayedPaperclip::Jobs::Resque
Arguments: "Tag", 321, "image"
Exception: ActiveRecord::StatementInvalid
Error: PGError: SSL error: decryption failed or bad record mac : SELECT tablename FROM pg_tables WHERE schemaname = ANY (current_schemas(false))

/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/connection_adapters/postgresql_adapter.rb:505:in `exec'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/connection_adapters/postgresql_adapter.rb:505:in `block in query'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/connection_adapters/abstract_adapter.rb:202:in `block in log'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.11/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/connection_adapters/abstract_adapter.rb:200:in `log'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/connection_adapters/postgresql_adapter.rb:501:in `query'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/connection_adapters/postgresql_adapter.rb:614:in `tables'
/app/vendor/bundle/ruby/1.9.1/gems/arel-2.0.10/lib/arel/table.rb:131:in `table_cache'
/app/vendor/bundle/ruby/1.9.1/gems/arel-2.0.10/lib/arel/table.rb:126:in `tables'
/app/vendor/bundle/ruby/1.9.1/gems/arel-2.0.10/lib/arel/table.rb:122:in `table_exists?'
/app/vendor/bundle/ruby/1.9.1/gems/arel-2.0.10/lib/arel/table.rb:101:in `[]'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/relation.rb:317:in `primary_key'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/relation/finder_methods.rb:301:in `find_one'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/relation/finder_methods.rb:291:in `find_with_ids'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/relation/finder_methods.rb:107:in `find'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/base.rb:444:in `find'
/app/vendor/bundle/ruby/1.9.1/gems/delayed_paperclip-2.4.5.1/lib/delayed_paperclip.rb:30:in `process_job'
/app/vendor/bundle/ruby/1.9.1/gems/delayed_paperclip-2.4.5.1/lib/delayed_paperclip/jobs/resque.rb:13:in `perform'
```
Relevant code:
Line 30 corresponds to `instance_klass.constantize.find(instance_id).` in `https://github.com/jstorimer/delayed_paperclip/blob/61eb0d2d0eacee70350a22460032fed024c54a0a/lib/delayed_paperclip.rb#L30`

```ruby
def process_job(instance_klass, instance_id, attachment_name)
instance_klass.constantize.find(instance_id).
send(attachment_name).
process_delayed!
end
```