Skip to content

"PG::Error: connection is closed" when enqueuing a job in a connection shared with ActiveRecord #141

Description

@raul

We're using QC 2.1.3 in a Rails 3.2.13 app, with the version 0.14.1 of the pg gem. Sometimes we get a PG::Error: connection is closed error when enqueuing jobs. Unfortunately I haven't been able to reproduce the problem in a controlled environment.

Enqueuing code:

module Approvable

  extend ActiveSupport::Concern

  included do
    # ...
    after_save :queue_approval_notification
  end

  # ...

  def queue_approval_notification
    send_email = approvable? && (just_approved? || just_unapproved?)
    QC.enqueue("#{self.class}.email_approval_notification", self.id, approved?, current_user.email) if send_email
  end

Error stacktrace:

2013-04-06T00:11:24+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/queue_classic-2.1.3/lib/queue_classic/conn.rb:81:in `finish'
2013-04-06T00:11:24+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/queue_classic-2.1.3/lib/queue_classic/conn.rb:81:in `disconnect'
2013-04-06T00:11:24+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/queue_classic-2.1.3/lib/queue_classic/conn.rb:19:in `rescue in block in execute'
2013-04-06T00:11:24+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/queue_classic-2.1.3/lib/queue_classic/conn.rb:11:in `block in execute'
2013-04-06T00:11:24+00:00 app[web.1]: <internal:prelude>:10:in `synchronize'
2013-04-06T00:11:24+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/queue_classic-2.1.3/lib/queue_classic/conn.rb:9:in `execute'
2013-04-06T00:11:24+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/queue_classic-2.1.3/lib/queue_classic/queries.rb:8:in `block in insert'
2013-04-06T00:11:24+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/queue_classic-2.1.3/lib/queue_classic.rb:78:in `log_yield'
2013-04-06T00:11:24+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/queue_classic-2.1.3/lib/queue_classic/queries.rb:6:in `insert'
2013-04-06T00:11:24+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/queue_classic-2.1.3/lib/queue_classic/queue.rb:11:in `enqueue'
2013-04-06T00:11:24+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/queue_classic-2.1.3/lib/queue_classic.rb:61:in `method_missing'
2013-04-06T00:11:24+00:00 app[web.1]: /app/app/models/approvable.rb:131:in `queue_approval_notification'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions