unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: Confused classes
Date: Sat, 6 Feb 2010 18:01:19 -0800	[thread overview]
Message-ID: <20100207020118.GA14392@dcvr.yhbt.net> (raw)
In-Reply-To: <201002061406.04172.ibc@aliax.net>

Iñaki Baz Castillo <ibc@aliax.net> wrote:
> El Sábado, 6 de Febrero de 2010, Warren Konkel escribió:
> > Could it be that class attributes are somehow being co-mingled when
> > unicorn is starting up under high concurrency?  Perhaps a mutex is
> > missing somewhere?
> 
> IMHO all your Unicorn workers are sharing the same DB connection (the same 
> ActiveRecord instances) so the problem arises.
> 
> Take a look to the configuration here:
>   http://unicorn.bogomips.org/examples/unicorn.conf.rb
> You can see there how the ActiveRecord is disconnected at the beggining and 
> started for each worker later.

Yes, you have to reconnect any connected TCP sockets since they have no
defined atomicity semantics when they're shared across processes/threads.

Ruby Mutexes aren't useful at all here, they're only useful with threads
in the same process.  If you need to protect TCP client sockets from
multiple processes, you'll need SysV/POSIX semaphores or file locks
(flock/fcntl), but you're really better off using multiple TCP client
sockets in the first place.

-- 
Eric Wong
_______________________________________________
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


      reply	other threads:[~2010-02-07  2:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-06 12:33 Confused classes Warren Konkel
2010-02-06 13:06 ` Iñaki Baz Castillo
2010-02-07  2:01   ` Eric Wong [this message]

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: https://yhbt.net/unicorn/

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

  git send-email \
    --in-reply-to=20100207020118.GA14392@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=mongrel-unicorn@rubyforge.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).