Search code examples
ruby-on-railspostgresqlherokubackgroundworkerresque

Resque/Rails/Heroku: PG::Error: result has been cleared


I'm trying to make resque work with heroku. It works with my other application but I don't understand this error in the worker logs:

PG::Error: result has been cleared: SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1

So whenever I add a job to the queue, a worker takes the job and throws the error above.

Here is the worker class:

class Companies
  @queue = :companies

  def self.perform(current_user_id, model)
    @current_user = User.find(current_user_id)

    ... do things with @current_user and model...
  end
end

And I call the perform action using: Resque.enqueue(Companies, current_user.id, 'quotes')


Solution

  • This error message indicates an internal error in the PG gem that is being used to interface with the Postgres database. It indicates a Garbage Collection/memory allocation error where the result of the executed postgres query has been cleared from memory on access.

    Someone as heroku will have to debug this, it appears to be a platform level issue.