[Mongrel] Sharing a mongrel cluster in a multi-url environment

David Vrensk david at vrensk.com
Wed Jan 28 17:45:23 EST 2009


I don't think this is mongrel's fault, but it's interesting nonetheless.

Could you have apache log the incoming cookie value to shed some more light
on what happens?  I believe that the cookie you see is not the cookie that
the client sends, but a new cookie that Rails generates when it cannot find
the cookie from the request in its current db.

My theory (aka wild guess) is that Rails picks up the cookie before you
change/set the database connection.  Like this:

User1 requests the login page.
Rails connects to db1 and renders the page.
User1 logs in and is given a cookie, and session data is stored in db1.
User1 does something and all is good.
User2 requests the login page.
Rails connects to db2 and renders.
User1 requests a new page.
Rails is connected to db2 and fails to find the cookie.
Rails connects to db1 and redirects user.

Now, this isn't exactly what's happening in your logs, but add the fact that
the different requests are being handled by different mongrels, each with
their Rails stacks and db connections, and you have a fine mess.

Could you try running just one mongrel for a short while to minimise the
number of moving parts?

HTH,

/David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/mongrel-users/attachments/20090128/59dd4921/attachment.html>


More information about the Mongrel-users mailing list