# Waiting for 1 connection to finish

**URL:** <https://www.ruby-forum.com/t/waiting-for-1-connection-to-finish/172440>\
**Category:** Rails\
**Created:** [July 21, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/waiting-for-1-connection-to-finish/172440 "2009-07-21T16:27:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [July 21, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/waiting-for-1-connection-to-finish/172440/1 "2009-07-21T16:27:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [July 21, 2009, 4:35pm UTC](https://www.ruby-forum.com/t/waiting-for-1-connection-to-finish/172440/2 "2009-07-21T16:35:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [July 22, 2009, 11:04am UTC](https://www.ruby-forum.com/t/waiting-for-1-connection-to-finish/172440/3 "2009-07-22T11:04:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [July 22, 2009, 11:42am UTC](https://www.ruby-forum.com/t/waiting-for-1-connection-to-finish/172440/4 "2009-07-22T11:42:59Z")

</div>

> 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…

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [July 22, 2009, 11:22am UTC](https://www.ruby-forum.com/t/waiting-for-1-connection-to-finish/172440/5 "2009-07-22T11:22:30Z")

</div>

On Wed, Jul 22, 2009 at 2:04 AM, Fernando P. \<  
removed\_email\_address@domain.invalid\> 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

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [July 22, 2009, 11:55am UTC](https://www.ruby-forum.com/t/waiting-for-1-connection-to-finish/172440/6 "2009-07-22T11:55:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [July 23, 2009, 5:17pm UTC](https://www.ruby-forum.com/t/waiting-for-1-connection-to-finish/172440/7 "2009-07-23T17:17:22Z")

</div>

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](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?
