Ben Johnson
2006-Aug-02 04:57 UTC
[Rails] 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. -- Posted via http://www.ruby-forum.com/.
Hasan Diwan
2006-Aug-02 06:39 UTC
[Rails] ActiveRecord does not close database connections?
On 01/08/06, Ben Johnson <bjohnson@mediamanifest.com> 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. -- Cheers, Hasan Diwan <hasan.diwan@gmail.com> 1. http://bugs.mysql.com/bug.php?id=8731 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060802/2e76870c/attachment-0001.html
Ben Johnson
2006-Aug-03 14:37 UTC
[Rails] Re: ActiveRecord does not close database connections?
Hasan Diwan wrote:> On 01/08/06, Ben Johnson <bjohnson@mediamanifest.com> 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? -- Posted via http://www.ruby-forum.com/.
Isak Hansen
2006-Aug-03 18:50 UTC
[Rails] ActiveRecord does not close database connections?
On 8/2/06, Ben Johnson <bjohnson@mediamanifest.com> 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 asthey finish up? Isak
Ben Johnson
2006-Aug-04 02:24 UTC
[Rails] Re: ActiveRecord does not close database connections?
Isak Hansen wrote:> On 8/2/06, Ben Johnson <bjohnson@mediamanifest.com> 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? > > > IsakWell 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? -- Posted via http://www.ruby-forum.com/.
Ben Johnson
2006-Aug-04 04:22 UTC
[Rails] Re: ActiveRecord does not close database connections?
Hasan Diwan wrote:> On 01/08/06, Ben Johnson <bjohnson@mediamanifest.com> 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? -- Posted via http://www.ruby-forum.com/.
zdennis
2006-Aug-04 05:37 UTC
[Rails] Re: ActiveRecord does not close database connections?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ben Johnson wrote:> Hasan Diwan wrote: >> On 01/08/06, Ben Johnson <bjohnson@mediamanifest.com> 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? >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-----
Ben Johnson
2006-Aug-04 07:09 UTC
[Rails] Re: Re: ActiveRecord does not close database connections?
zdennis wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Ben Johnson 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. -- Posted via http://www.ruby-forum.com/.