Using django orm to work with MySQL database, there are several mysqlds unoccupied. How to close them?

enter image description here

I am typing htop

then I got this. So we can see the TIME + tab, there are some mysqlds whose time is 00:00:00, this is what I want to close because it takes a lot of memories. My application has many tasks to work with mysql dababase, if mysqld is not closed in a timely manner, mysql will have an error: OperationalError: (1135, "Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug")

How do I reinstall it? My django version is 1.6.5.

now in my mysql client, I type show processlist;

, I got this ratio: (there are many mysql processes - this is hibernation. Is it because I am using django orm so orm does not close the database connection in time? And how to close it in time ? enter image description here

0


source to share


1 answer


https://docs.djangoproject.com/en/1.6/ref/databases/#connection-management



There is a variable CONN_MAX_AGE

that you can set to 0 to close the db connection immediately upon request. But that should be the default behavior. Can you check what's yours CONN_MAX_AGE

? ./manage.py diffsettings | grep CONN_MAX_AGE

will do the trick.

0


source







All Articles