yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: "Lin Jen-Shin (godfat)" <godfat@godfat.org>
Cc: yahns-public@yhbt.net, wildjcrt@gmail.com
Subject: Re: What would happen if a worker thread died?
Date: Fri, 8 May 2015 17:03:11 +0000	[thread overview]
Message-ID: <20150508170311.GA1260@dcvr.yhbt.net> (raw)
In-Reply-To: <CAA2_N1umJO12XH9r+JHnA6r=z=Mwp_PqOrdnW65oqW2K2-iAoQ@mail.gmail.com>

"Lin Jen-Shin (godfat)" <godfat@godfat.org> wrote:
> During the experiments, we found that whenever a worker
> thread died due to LoadError raised from the application,
> which is not a StandardError therefore was not rescued at all,
> crashing the worker thread (assumed, not verified).

Ugh, I guess since it happened in a thread, the error message got
swallowed unless you were running in $DEBUG.

Loading code after the server is ready and serving requests is a bad
idea.  It leads to really nasty thread-safety problems as well as
invalidating the method/constant caches.

> When this happened, the client just hanged forever with yahns.
> Is there something we can do about this? Would yahns respawn
> a new worker thread? Can we close the socket when this happen?

It's unfortunately difficult to detect thread death from ruby (no
SIGCHLD handler unlike for processes) besides polling Thread#join

We had this issue in ruby-core a few years back, but apparently
it was forgotten/ignored by matz.  Care to chime in?
https://bugs.ruby-lang.org/issues/6647

> I am aware that yahns is *extremely sensitive to fatal bugs in the
> applications it hosts*, so I am just curious.
> 
> For reference, Puma would immediately close the socket without
> sending anything, and Unicorn would log the error backtrace and
> kill the worker (If I read it correctly).
> 
> In this case, Unicorn helped me figure out what's happened.

yahns can probably rescue Exception (or Object(!) like puma)
and then log + abort the entire process.

  reply	other threads:[~2015-05-08 17:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 12:20 Lin Jen-Shin (godfat)
2015-05-08 17:03 ` Eric Wong [this message]
2015-05-08 17:36   ` Lin Jen-Shin (godfat)
2015-05-09  1:03     ` Eric Wong
2015-05-09  7:26       ` Lin Jen-Shin (godfat)
2015-05-09  8:47         ` Eric Wong
2015-05-09  9:03           ` [PATCH] worker threads log LoadError and SyntaxError, too Eric Wong
2015-05-09  9:06           ` What would happen if a worker thread died? Lin Jen-Shin (godfat)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://yhbt.net/yahns/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150508170311.GA1260@dcvr.yhbt.net \
    --to=e@80x24.org \
    --cc=godfat@godfat.org \
    --cc=wildjcrt@gmail.com \
    --cc=yahns-public@yhbt.net \
    --subject='Re: What would happen if a worker thread died?' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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

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