unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* COW friendly GC and PostgreSQL
@ 2011-11-30 15:24 Laas Toom
  2011-11-30 20:54 ` Jeremy Evans
  2011-12-01 15:32 ` Laas Toom
  0 siblings, 2 replies; 3+ messages in thread
From: Laas Toom @ 2011-11-30 15:24 UTC (permalink / raw)
  To: mongrel-unicorn

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
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: COW friendly GC and PostgreSQL
  2011-11-30 15:24 COW friendly GC and PostgreSQL Laas Toom
@ 2011-11-30 20:54 ` Jeremy Evans
  2011-12-01 15:32 ` Laas Toom
  1 sibling, 0 replies; 3+ messages in thread
From: Jeremy Evans @ 2011-11-30 20:54 UTC (permalink / raw)
  To: unicorn list

On Wed, Nov 30, 2011 at 7:24 AM, Laas Toom <laas.toom@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
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: COW friendly GC and PostgreSQL
  2011-11-30 15:24 COW friendly GC and PostgreSQL Laas Toom
  2011-11-30 20:54 ` Jeremy Evans
@ 2011-12-01 15:32 ` Laas Toom
  1 sibling, 0 replies; 3+ messages in thread
From: Laas Toom @ 2011-12-01 15:32 UTC (permalink / raw)
  To: mongrel-unicorn

> 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
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-01 15:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-30 15:24 COW friendly GC and PostgreSQL Laas Toom
2011-11-30 20:54 ` Jeremy Evans
2011-12-01 15:32 ` Laas Toom

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).