Commit 3c06c8dc authored by Vincent Pelletier's avatar Vincent Pelletier

ZMySQLDA: Capture hosed connection errors during transction abort

Do log it, but do not let it propagate.
parent fbeff3f4
...@@ -432,12 +432,25 @@ class DB(TM): ...@@ -432,12 +432,25 @@ class DB(TM):
if not self._transaction_begun: if not self._transaction_begun:
return return
self._transaction_begun = False self._transaction_begun = False
if self._mysql_lock: # Hide hosed connection exceptions:
self._query("SELECT RELEASE_LOCK('%s')" % self._mysql_lock) # - if the disconnection caused the abort, we would then hide the
if self._transactions: # original error traceback
self._query("ROLLBACK") # - if the disconnection happened during abort, then we cannot recover
else: # anyway as the transaction is bound to its connection anyway
LOG('ZMySQLDA', ERROR, "aborting when non-transactional") # Note: in any case, we expect server to notice the disconnection and
# trigger an abort on its side.
try:
if self._mysql_lock:
self._query("SELECT RELEASE_LOCK('%s')" % self._mysql_lock)
if self._transactions:
self._query("ROLLBACK")
else:
LOG('ZMySQLDA', ERROR, "aborting when non-transactional")
except OperationalError, m:
LOG('ZMySQLDA', ERROR, "exception during _abort",
error=sys.exc_info())
if m[0] not in hosed_connection:
raise
@contextmanager @contextmanager
def lock(self): def lock(self):
......
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