Waiting for 1 connection to finish

For a few days now since a major update on my rails app on the
production server, I am getting the following error message when
restarting the application:

Waiting for 1 connection(s) to finish, can take up to 30 sec, CTRL+C to stop now

I am using Rails 2.3.3, Thin 1.2.2 and pg 0.8.0 (postgresql gem).

Has anyone encountered such problem? I’m in deep trouble.

Damn it was a former zombie Thin process that was still causing trouble!

With kill -9 and restarting all new Thin instances to take advantage of
the updated gem seems to have resolved the problem. I’ll still keep an
eye on it, and provide feedback.

This morning all my Thin process are stuck again :-(, something seems to
happen during the night or at least during a long period of time so that
all processes end up blocked.

Have you done any sand-box (i.e. staging server) testing prior to
migrating
your production application
from 2.3.2 to 2.3.3?
Everything works fine on my dev machine, and everything works fine (for
a limited time though) on the production server. This problem appeared
prior to upgrading Rails to version 2.3.3.

I am totally clueless where to look for. Googling “waiting connection
finish” returns only my own posts…

On Wed, Jul 22, 2009 at 2:04 AM, Fernando P. <
[email protected]> wrote:

This morning all my Thin process are stuck again :-(, something seems to
happen during the night or at least during a long period of time so that
all processes end up blocked.

Have you done any sand-box (i.e. staging server) testing prior to
migrating
your production application
from 2.3.2 to 2.3.3?

-Conrad

Cool my processes are blocking and here is what $ netstat -anp is giving
me:

Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name
[…]
tcp 1239 0 10.0.0.2:3100 10.0.0.1:36186
CLOSE_WAIT -
tcp 1 0 10.0.0.2:3100 10.0.0.1:48261
CLOSE_WAIT -
tcp 1107 0 10.0.0.2:3100 10.0.0.1:48286
CLOSE_WAIT -
tcp 1239 0 10.0.0.2:3100 10.0.0.1:36192
CLOSE_WAIT -
tcp 1152 0 10.0.0.2:3100 10.0.0.1:36189
CLOSE_WAIT -
tcp 1152 0 10.0.0.2:3100 10.0.0.1:36195
CLOSE_WAIT
[…]

Here is my setup, which I admit might be a bit overkill:

10.0.0.1 is a Virtual Machine that runs Nginx which proxy_passes
requests to 10.0.0.2 which is another Virtual Machine where my Rails app
is running. For some reason connection between these two is crapping out
on me. Any idea why that would happen?

I reinstalled my web app on a new VM, and merged Nginx and Rails on the
same VM, and I still got the conneciton close problem, but now it
happens between the Postgresl VM and my rails app one.

So there is definitely a problem between Rails and Postgresql.

Taken from


The postgres gem is written in C and is supported by ActiveRecord. The
last release was 0.7.9 (2008-01-24). Development has been discontinued
in favor of the pg gem.

The pg gem is the successor of the postgres gem and is also written in
C. It is currently NOT supported by ActiveRecord. There seems to be a
patch available here: http://dev.rubyonrails.org/ticket/10948 (I did not
test it). The last release is 0.8 (2009-03-29), which seems to be a sign
of active development.

I was suing pg gem, so I guess that could be the problem? Basically it
is not possible to make Rails and Postgresql work properly together?