Fix for CONPY-246:

Rollback transaction if connection pool was created with
pool_reset_connection=False.
This commit is contained in:
Georg Richter
2023-02-03 08:07:41 +01:00
parent 7daab2feb5
commit a48eb1eff6
2 changed files with 30 additions and 3 deletions

View File

@ -19,9 +19,9 @@
import mariadb
import _thread
from mariadb.constants import STATUS
MAX_POOL_SIZE = 64
POOL_IDLE_TIMEOUT = 1800
class ConnectionPool(object):
@ -193,9 +193,12 @@ class ConnectionPool(object):
by connection object.
"""
if self._pool_args["reset_connection"]:
connection.reset()
elif connection.server_status & STATUS.IN_TRANS:
connection.rollback()
with self._lock_pool:
if self._pool_args["reset_connection"]:
connection.reset()
for i in range(0, len(self._connections_used)):
if self._connections_used[i] == connection: