unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: "Iñaki Baz Castillo" <ibc@aliax.net>
To: mongrel-unicorn@rubyforge.org
Subject: Re: Strange Thread related errors
Date: Thu, 7 Jan 2010 20:08:38 +0100	[thread overview]
Message-ID: <201001072008.39047.ibc@aliax.net> (raw)
In-Reply-To: <944a03771001071049j520f6580i26c3a3ae8b850a48@mail.gmail.com>

El Jueves, 7 de Enero de 2010, Michael Guterl escribió:
> We currently disconnect from both databases in before_fork and
> re-establish the connection in after_fork.
> 
> Here's our unicorn config: http://gist.github.com/271449

Unfortunately I don't know very well ho ActiveRecords works but you could get 
into the same probem even if you disconnect the db in the case you are sharing 
the same ActiveRecord instance in all the workers.
This issue also ocurred to me using Sequel: I generated the DB instances in 
master process and stored them in an Array that later used in each worker so 
the fact is that I was sharing the same DB object in all the workers, so when 
they reconcet they are in fact using a single connection (or a single 
connection pool) for all the workers.

But I think that ActiveRecords works in a different way as you don't create a 
DB instance but instead use directly a class ("class MyModel < 
ActiveRecords").

 
> Maybe I should disable connection pooling?
 
This should not be the real cause of your problem (if the above is not 
happening to you). Unicorn workers are single thread which means you can use 
threads into them safely (except if those threads are, accidentally, shared by 
other processes).

I suggest the following: Tun the server and ensure you do enough requests so 
all the worker perform at least a DB query. And them check the current DB 
connection in your DB. If you dissable coonectino pooling you should see just 
N connections /being N the number of Unicorn workers).

-- 
Iñaki Baz Castillo <ibc@aliax.net>
_______________________________________________
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-01-07 19:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-07 16:05 Strange Thread related errors Michael Guterl
2010-01-07 16:31 ` Iñaki Baz Castillo
2010-01-07 18:10   ` Jeremy Evans
2010-01-07 18:33     ` Iñaki Baz Castillo
2010-01-07 18:49   ` Michael Guterl
2010-01-07 19:08     ` Iñaki Baz Castillo [this message]
2010-01-07 20:08     ` Jeremy Evans
2010-01-07 20:13 ` Eric Wong
2010-01-07 21:32   ` Michael Guterl

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=201001072008.39047.ibc@aliax.net \
    --to=ibc@aliax.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).