Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit e5d48d6

Browse files
Merge pull request #298 from zhanghaofei/begin_transaction_reconnect_by_lost
If mysql begin a transaction and lost connection, reconnect
2 parents 8aaeafe + 5dd2702 commit e5d48d6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

orator/connections/mysql_connection.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,16 @@ def get_schema_manager(self):
3838
return MySQLSchemaManager(self)
3939

4040
def begin_transaction(self):
41-
self._connection.autocommit(False)
41+
self._reconnect_if_missing_connection()
42+
43+
try:
44+
self._connection.autocommit(False)
45+
except Exception as e:
46+
if self._caused_by_lost_connection(e):
47+
self.reconnect()
48+
self._connection.autocommit(False)
49+
else:
50+
raise
4251

4352
super(MySQLConnection, self).begin_transaction()
4453

0 commit comments

Comments
 (0)