Commit 76e15bb2 authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Eteri

ZMySQLDA: Allow BEGIN xor LOCK to reconnect

Saves one round-trip to server.
parent 848331e2
...@@ -403,12 +403,10 @@ class DB(TM): ...@@ -403,12 +403,10 @@ class DB(TM):
"""Begin a transaction (when TM is enabled).""" """Begin a transaction (when TM is enabled)."""
try: try:
self._transaction_begun = True self._transaction_begun = True
# Ping the database to reconnect if connection was closed.
self._query("SELECT 1", allow_reconnect=True)
if self._transactions: if self._transactions:
self._query("BEGIN") self._query("BEGIN", allow_reconnect=True)
if self._mysql_lock: if self._mysql_lock:
self._query("SELECT GET_LOCK('%s',0)" % self._mysql_lock) self._query("SELECT GET_LOCK('%s',0)" % self._mysql_lock, allow_reconnect=not self._transactions)
except: except:
LOG('ZMySQLDA', ERROR, "exception during _begin", LOG('ZMySQLDA', ERROR, "exception during _begin",
error=sys.exc_info()) error=sys.exc_info())
......
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