#805: Return 503 (Service Unavailable) for OperationalError
--------------------+-------------------------
Reporter: fjorba | Type: enhancement
Status: new | Priority: minor
Milestone: | Component: *general*
Version: | Keywords:
--------------------+-------------------------
During database backups, I'm getting lots of MySQL OperationalError
errors, like this one, mainly caused by robots:
{{{
The following problem occurred on <http://traces.uab.cat>
>>> Registered exception
2011-09-02 05:28:19 -> OperationalError: (1040, 'Too many connections')
>>> User details
agent: Mozilla/5.0 (compatible; Yahoo! Slurp;
http://help.yahoo.com/help/us/ysearch/slurp)
apache_group: []
apache_user: None
email:
group: []
guest: 1
last_login: 1970-01-01 00:00:00
nickname:
referer: <>
remote_host:
remote_ip: 67.195.114.47
uid: 0
uri: </record/56964/reviews/add?ln=ca&action=DISPLAY&score=5>
>>> Traceback details
Forced traceback (most recent call last)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1128, in _execute_target
result = object(arg)
File "/home/traces/lib/python/invenio/webinterface_handler.py", line
298, in _profiler
return _handler(req)
Traceback (most recent call last):
File "/home/traces/lib/python/invenio/webinterface_handler.py", line
316, in _handler
return root._traverse(req, path)
File "/home/traces/lib/python/invenio/webinterface_handler.py", line
195, in _traverse
return obj._traverse(req, path)
File "/home/traces/lib/python/invenio/webinterface_handler.py", line
195, in _traverse
return obj._traverse(req, path)
File "/home/traces/lib/python/invenio/webinterface_handler.py", line
210, in _traverse
result = _check_result(req, obj(req, form))
File "/home/traces/lib/python/invenio/webcomment_webinterface.py", line
217, in add
(auth_code, auth_msg) = check_user_can_view_record(user_info,
self.recid)
File "/home/traces/lib/python/invenio/search_engine.py", line 213, in
check_user_can_view_record
record_primary_collection =
guess_primary_collection_of_a_record(recid)
File "/home/traces/lib/python/invenio/search_engine.py", line 2370, in
guess_primary_collection_of_a_record
dbcollids = get_fieldvalues(recID, "980__a")
File "/home/traces/lib/python/invenio/search_engine.py", line 2431, in
get_fieldvalues
res = run_sql(query)
File "/home/traces/lib/python/invenio/dbquery.py", line 231, in run_sql
db = _db_login(relogin = 1)
File "/home/traces/lib/python/invenio/dbquery.py", line 110, in
_db_login
use_unicode=False, charset='utf8')
File "/var/lib/python-support/python2.5/MySQLdb/__init__.py", line 74,
in Connect
return Connection(*args, **kwargs)
File "/var/lib/python-support/python2.5/MySQLdb/connections.py", line
170, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (1040, 'Too many connections')
}}}
I attach a patch that works for 0.99.1 (mod_python based) that returns an
Service Unavalilable, as recommended by Google and other robots:
*
http://www.google.com/support/forum/p/Webmasters/thread?tid=2caa38cb3d55bfa0&hl=en
* http://googlewebmastercentral.blogspot.com/2006/08/all-about-
googlebot.html
* http://www.bigmouthmedia.com/live/articles/visittime-robotstxt-
directive--use-503-instead.asp/6297/
I cannot provide a version for development branch, but you get the idea.
--
Ticket URL: <http://invenio-software.org/ticket/805>
Invenio <http://invenio-software.org>