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

后端 未结 5 1160
抹茶落季
抹茶落季 2020-12-07 23:42

I have site running rails application and resque workers running in production mode, on Ubuntu 9.10, Rails 2.3.4, ruby-ee 2010.01, PostgreSQL 8.4.2

Workers constantl

5条回答
  •  星月不相逢
    2020-12-08 00:09

    You cannot pass a libpq reference across a fork() (or to a new thread), unless your application takes very close care of not using it in conflicting ways. (Like, a mutex around every single attempt to use it, and you must never close it). This is the same for both direct connections and using pgbouncer. If it worked in pgbouncer, that was pure luck in missing a race condition for some reason, and will eventually break.

    If your program uses forking, you must create the connection after the fork.

提交回复
热议问题