This may not even be a Django problem, but I saw this on two of my dev sites today, both running the same code base, our version of django is from the trunk, and maybe a week or so old. One site was running the light weight server, the other site was running apache/mod_python. Both are connected to the same database. Here is the error:
Traceback (most recent call last):
File "/usr/local/python2.5/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent)
File "/usr/local/python2.5/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg)
File "/usr/local/python2.5/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg)
File "/usr/local/python2.5/lib/python2.5/site-packages/django/core/handlers/modpython.py", line 222, in handler\n return ModPythonHandler()(req)
File "/usr/local/python2.5/lib/python2.5/site-packages/django/core/handlers/modpython.py", line 199, in __call__\n response = middleware_method(request, response)
File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/middleware.py", line 33, in process_response
File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/backends/db.py", line 52, in save
File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/backends/base.py", line 152, in _get_session_key
File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/backends/base.py", line 144, in _get_new_session_key
File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/backends/db.py", line 25, in exists
File "/usr/local/lib/python2.5/site-packages/django/db/models/manager.py", line 93, in get
File "/usr/local/lib/python2.5/site-packages/django/db/models/query.py", line 298, in get
File "/usr/local/lib/python2.5/site-packages/django/db/models/query.py", line 154, in __len__
File "/usr/local/lib/python2.5/site-packages/django/db/models/query.py", line 269, in iterator
File "/usr/local/lib/python2.5/site-packages/django/db/models/sql/query.py", line 206, in results_iter
File "/usr/local/lib/python2.5/site-packages/django/db/models/sql/query.py", line 1699, in execute_sql
File "/usr/local/lib/python2.5/site-packages/django/db/backends/__init__.py", line 56, in cursor
File "/usr/local/lib/python2.5/site-packages/django/db/backends/mysql/base.py", line 262, in _cursor
File "/usr/local/python2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg/MySQLdb/__init__.py", line 74, in Connect
File "/usr/local/python2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg/MySQLdb/connections.py", line 170, in __init__\n super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (1040, 'Too many connections')
Obviously it’s django going through mysqldb, and
connection problem is in mysqldb, but I was wondering if anyone on this list
can shed some light on this. I did a bit of googling and noticed other people
using django were having similar problems. Does anyone know what causes this
and how I can fix it? These sites are both internal dev sites, therefore not
anywhere close to high traffic.
Thank you
Apaar
as you can see above, it's mysql problem. mysql server have some
default limitation on concurrent connections. you can increase
max_connections in my.cnf. depending on your linux distro my.cnf may
be located in different places. for me, or on ubuntu it's at
/etc/mysql/my.cnf, and you need to uncomment the line, and increase
the value.
by default mysql gets 100 concurrent connections. and the question is
why is dev site is getting that much connection?
--
Regards
Dulmandakh