Commit c00318de authored by Tristan Cavelier's avatar Tristan Cavelier

Add counter to manage_debug_thread SQL queries

- This counter shows the number of the SQL request since
  the beginning of the transaction
parent 7733f1cf
......@@ -69,7 +69,8 @@ def dump_threads():
while f is not None:
code = f.f_code
if code is DB._query.func_code:
mysql_info = "\nMySQL query:\n%s\n" % f.f_locals['query']
mysql_info = "\nMySQL query #%s:\n%s\n" % (f.f_locals['self']._count,
f.f_locals['query'])
break
f = f.f_back
except ImportError:
......
......@@ -319,6 +319,7 @@ class DB(TM):
because they are bound to the connection. This check can be
overridden by passing force_reconnect with True value.
"""
self._count += 1
try:
self.db.query(query)
except OperationalError, m:
......@@ -332,6 +333,7 @@ class DB(TM):
raise
# Hm. maybe the db is hosed. Let's restart it.
self._forceReconnection()
self._count += 1
self.db.query(query)
except ProgrammingError, exception:
LOG('ZMySQLDA', ERROR, 'query failed: %s' % (query,))
......@@ -399,6 +401,7 @@ class DB(TM):
def _begin(self, *ignored):
"""Begin a transaction (when TM is enabled)."""
self._count = 0
try:
self._transaction_begun = True
# Ping the database to reconnect if connection was closed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment