ActiveRecord does not close database connections?

I have an application that creates quite a few threads. I keep getting
the “mysql too many connections” error.

ActiveRecord does not close the connection once a thread had died out.

To make things worse mysql has a wait_timeout variable that would
basically kill off these connections for me, but there is a bug and I
can not change the value of it. I have tried at least 10 different ways
to change the variable and it simply won’t change. It’s defaulted to 8
hours, and I wanted to change it to 4 minutes.

So is there a way to close a threads database connection from the
outside?

Thanks for your help.

On 01/08/06, Ben J. [email protected] wrote:

To make things worse mysql has a wait_timeout variable that would
basically kill off these connections for me, but there is a bug and I
can not change the value of it. I have tried at least 10 different ways
to change the variable and it simply won’t change. It’s defaulted to 8
hours, and I wanted to change it to 4 minutes.

The bug is listed as closed [1]. Kindly upgrade mysql to 5.0.15 or
higher
5.0.x. Alternatively, mysql 4.1.16 also has the fix applied.

Hasan D. wrote:

On 01/08/06, Ben J. [email protected] wrote:

To make things worse mysql has a wait_timeout variable that would
basically kill off these connections for me, but there is a bug and I
can not change the value of it. I have tried at least 10 different ways
to change the variable and it simply won’t change. It’s defaulted to 8
hours, and I wanted to change it to 4 minutes.

The bug is listed as closed [1]. Kindly upgrade mysql to 5.0.15 or
higher
5.0.x. Alternatively, mysql 4.1.16 also has the fix applied.

Thanks for the help. I currently have MySQL 4.1.20 installed. If the fix
was applied on version 4.1.16 shouldn’t 4.1.20 have the fix as well?

On 8/2/06, Ben J. [email protected] wrote:

I have an application that creates quite a few threads. I keep getting
the “mysql too many connections” error.

ActiveRecord does not close the connection once a thread had died out.

snip

So is there a way to close a threads database connection from the
outside?

Thanks for your help.

From the outside? Why not have the threads close their connections as
they finish up?

Isak

Isak H. wrote:

On 8/2/06, Ben J. [email protected] wrote:

I have an application that creates quite a few threads. I keep getting
the “mysql too many connections” error.

ActiveRecord does not close the connection once a thread had died out.

snip

So is there a way to close a threads database connection from the
outside?

Thanks for your help.

From the outside? Why not have the threads close their connections as
they finish up?

Isak

Well because threads can be killed in the middle of their work, and some
of my threads contain loops that are based on conditions. Therefore,
these loops could run for minutes, months, or years if they wanted. So
I’d like to clean up the thread where I end them. From the outside. Is
this possible?

Hasan D. wrote:

On 01/08/06, Ben J. [email protected] wrote:

To make things worse mysql has a wait_timeout variable that would
basically kill off these connections for me, but there is a bug and I
can not change the value of it. I have tried at least 10 different ways
to change the variable and it simply won’t change. It’s defaulted to 8
hours, and I wanted to change it to 4 minutes.

The bug is listed as closed [1]. Kindly upgrade mysql to 5.0.15 or
higher
5.0.x. Alternatively, mysql 4.1.16 also has the fix applied.

I just upgraded to 5.0.22 and still can’t change the wait_timeout. I can
change max_connections, but not the wait timeout. Any ideas?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ben J. wrote:

5.0.x. Alternatively, mysql 4.1.16 also has the fix applied.

I just upgraded to 5.0.22 and still can’t change the wait_timeout. I can
change max_connections, but not the wait timeout. Any ideas?

Maybe too simple of a question, but what exactly are you doing to reset
the wait_timeout?

Zach
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE0t09Myx0fW1d8G0RAkpLAJ9WUavGsyplTpiexN68PQnP7GqLfgCfcC1+
oBrGlPi7vD9esBfPdyBu5NU=
=EE+f
-----END PGP SIGNATURE-----

zdennis wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ben J. wrote:

5.0.x. Alternatively, mysql 4.1.16 also has the fix applied.

I just upgraded to 5.0.22 and still can’t change the wait_timeout. I can
change max_connections, but not the wait timeout. Any ideas?

Maybe too simple of a question, but what exactly are you doing to reset
the wait_timeout?

Zach
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE0t09Myx0fW1d8G0RAkpLAJ9WUavGsyplTpiexN68PQnP7GqLfgCfcC1+
oBrGlPi7vD9esBfPdyBu5NU=
=EE+f
-----END PGP SIGNATURE-----

Hi Zach,

Thanks a lot for your help. I actually got this to work. The weirdest
thing. If I log into mysql by doing:

mysql -u root -p

and then typing

show variables;

I get the wrong wait_timeout value. Then if I do:

mysqladmin variables -u root -p

I get the right values. So I’m assuming the changes took effect. Thanks
for the help.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs