RubyRedGrapefruit
RubyRedGrapefruit

Reputation: 12214

"pg" Ruby gem is throwing a "prepared statement already exists" error from Resque

Apparently the pg gem uses prepared statements for Postgres. I have seen fixes for Unicorn to ensure that each process uses it's own db connection like so:

after_fork do |server, worker|
  ActiveRecord::Base.establish_connection
end

But I have no idea how to make this work with Resque.

Upvotes: 1

Views: 1442

Answers (1)

RubyRedGrapefruit
RubyRedGrapefruit

Reputation: 12214

I found the answer. Please look at Christian Fazzini's answer here:

Rails Resque workers fail with PGError: server closed the connection unexpectedly

The error is different, but Christian's solution is the same, and it works.

Upvotes: 3

Related Questions