Hello, I stumbled upon a weird issue when upgrading a Rails app and trying to run in on Unicorn!: http://stackoverflow.com/questions/8262803/unicorn-and-postgresql/ The problem manifested itself via a few different error messages as if garbage/nil was returned from database instead of actual data and it only happened with more than one concurrent request (i.e under load test). This turned out to be an issue with COW-friendly GC that I had enabled (taken from the example unicorn.conf). Removing this from unicorn.conf made the app run smooth again. Is this something known or did I do something wrong? Best regards, Laas
On Wed, Nov 30, 2011 at 7:24 AM, Laas Toom <laas.toom at eenet.ee> wrote:> Hello, > > I stumbled upon a weird issue when upgrading a Rails app and trying to run in on Unicorn!: > http://stackoverflow.com/questions/8262803/unicorn-and-postgresql/ > > The problem manifested itself via a few different error messages as if garbage/nil was returned from database instead of actual data and it only happened with more than one concurrent request (i.e under load test). > > This turned out to be an issue with COW-friendly GC that I had enabled (taken from the example unicorn.conf). Removing this from unicorn.conf made the app run smooth again. > > Is this something known or did I do something wrong?If you didn''t disconnect the database connection before forking, that could be the cause of the problem, though you should have issues regardless of whether the GC is CoW or not. Did you just turn off CoW, or did you turn off preload_app as well? Looking at your config file, try adding a before_fork callback that disconnects the database connection and things may work fine. Jeremy
> If you didn''t disconnect the database connection before forking, that > could be the cause of the problem, though you should have issues > regardless of whether the GC is CoW or not. Did you just turn off > CoW, or did you turn off preload_app as well?Totally my mistake - I had copied the example config from web and because of mis-indenting (as seen in my conf) I misread it and interpreted it in my mind as: preload_app(true) do ... end Taking it for ''before loading app'' And that is why I ignored the preload_app and blamed the COW, which of course did not have anything to do with my problem. Plainly RTFM for me here!> Looking at your config file, try adding a before_fork callback that > disconnects the database connection and things may work fine.Adding before_fork and after_fork as shown in example conf, the problem dissapeared. Thank you and sorry for the disturbance. Best, Laas