unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* Re: Fwd: Zero-downtime deploys, signals, ruby-pg
       [not found] ` <CACfv+p+4FK5BSL4D0uMi-Zgtf7VtcpTVu7sG4WXv2YXWyRbeWA@mail.gmail.com>
@ 2013-11-20  9:47   ` Eric Wong
  2013-11-20 10:06     ` Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2013-11-20  9:47 UTC (permalink / raw)
  To: Joe Van Dyk; +Cc: mongrel-unicorn

Joe Van Dyk <joe@tanga.com> wrote:
> Just sent this via gmail. Any ideas why I got this error?

It contained an HTML portion which Mailman couldn't strip or handle.
Forwarding to the list for now[1]

> ---------- Forwarded message ----------
> From: Joe Van Dyk <joe@tanga.com>
> To: unicorn list <mongrel-unicorn@rubyforge.org>
> Cc:
> Date: Tue, 19 Nov 2013 15:29:27 -0800
> Subject: Zero-downtime deploys, signals, ruby-pg
> Hi folks,
> 
> I think the upgrade to ruby-pg 0.16 broke the zero-downtime deployments on
> unicorn.
> 
> See mailing list post here:
> https://groups.google.com/d/msg/ruby-pg/5_ylGmog1S4/uvQ3EDl7MUUJ
> 
> I think the problem is that unicorn sends a signal to the worker thread
> when it's about to be shutdown. ruby-pg receives that signal and
> immediately cancels any actively-running queries. Leading to exceptions
> like:
> 
> PG::QueryCanceled: ERROR: canceling statement due to user request : UPDATE
> "orders" SET...
> from deep inside Sequel or ActiveRecord.
> 
> Michael Granger said it's a unicorn problem (apparently).

Unfortunately, there's no easy solution in unicorn.

ruby-pg is correct in interrupting the running query since it doesn't
know if the interrupt signal is for graceful unicorn shutdown or if the
user is thinking: "must stop query now or all data is destroyed!"

So I suspect ruby-pg favors the panicking user who accidentally issued
an UPDATE or DELETE without a proper WHERE clause :)

As far as workarounds on the unicorn/rack-side go:

1) retry on PG::QueryCanceled queries, this is analogous to the
   EINTR retries Ruby does for most interrupted syscalls.
   However, this takes time and you need to be careful in case
   you forgot transactions and what not.

2) Avoid SIGQUIT on the unicorn master completely, just send SIGKILL
   to the master.  The workers will slowly realize the master is dead
   and die gracefully.  This could increase RAM usage.
_______________________________________________
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] 2+ messages in thread

* Re: Fwd: Zero-downtime deploys, signals, ruby-pg
  2013-11-20  9:47   ` Fwd: Zero-downtime deploys, signals, ruby-pg Eric Wong
@ 2013-11-20 10:06     ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2013-11-20 10:06 UTC (permalink / raw)
  To: mongrel-unicorn; +Cc: Joe Van Dyk

Eric Wong <normalperson@yhbt.net> wrote:
> Joe Van Dyk <joe@tanga.com> wrote:
> > Just sent this via gmail. Any ideas why I got this error?
> 
> It contained an HTML portion which Mailman couldn't strip or handle.
> Forwarding to the list for now[1]

[1] - I forgot the footnote from the earlier email:

      I've been working on replacing this mailing list with something
      like a mailing list (but not exactly)[2].  Hopefully it'll do a
      better job of stripping HTML as well as having public logging
      of message rejections/failures.

[2] - This is needed because Rubyforge might not be around much longer.
      Rubyforge has been down for days at a time with no explanation.
      Running a real mailing list myself is probably too much effort,
      and relying on hard-to-admin centralized systems isn't good
      anyways, so I'm coming up with something slacker BOFHs like
      me can deal with without ending up on spam blacklists.
_______________________________________________
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] 2+ messages in thread

end of thread, other threads:[~2013-11-20 10:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.0.1384904190.12484.mongrel-unicorn@rubyforge.org>
     [not found] ` <CACfv+p+4FK5BSL4D0uMi-Zgtf7VtcpTVu7sG4WXv2YXWyRbeWA@mail.gmail.com>
2013-11-20  9:47   ` Fwd: Zero-downtime deploys, signals, ruby-pg Eric Wong
2013-11-20 10:06     ` Eric Wong

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).