Skip to content

Commit 4c2dcf2

Browse files
chungeun-choidavinc71998sean-k1
authored
fix - Bug/increase history list length (#431)
Overview issue number #430 When using the pymysqlreplication package, there was a recurring issue with the history list length value under the following circumstances: MySQL version 8.x or higher. Continuous execution of DML (Data Manipulation Language) statements. This problem led to a gradual slowing down of SELECT queries. For detailed information, you can refer to the following reference: https://minervadb.xyz/troubleshooting-innodb-history-length-with-hung-mysql-transaction/ As a result, I investigated the problem area and made necessary modifications. After making the changes, you were able to compare the performance before and after the fix, using monitoring tools such as Prometheus and MySQL Exporter. --------- Co-authored-by: davinc71998 <[email protected]> Co-authored-by: sean <[email protected]>
1 parent 07ad978 commit 4c2dcf2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: pymysqlreplication/binlogstream.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ def __connect_to_ctl(self):
256256
self._ctl_connection_settings = dict(self.__connection_settings)
257257
self._ctl_connection_settings["db"] = "information_schema"
258258
self._ctl_connection_settings["cursorclass"] = DictCursor
259+
self._ctl_connection_settings["autocommit"] = True
259260
self._ctl_connection = self.pymysql_wrapper(**self._ctl_connection_settings)
260261
self._ctl_connection._get_table_information = self.__get_table_information
261262
self.__connected_ctl = True
@@ -653,8 +654,10 @@ def __get_table_information(self, schema, table):
653654
table_schema = %s AND table_name = %s
654655
ORDER BY ORDINAL_POSITION
655656
""", (schema, table))
657+
result = cur.fetchall()
658+
cur.close()
656659

657-
return cur.fetchall()
660+
return result
658661
except pymysql.OperationalError as error:
659662
code, message = error.args
660663
if code in MYSQL_EXPECTED_ERROR_CODES:

0 commit comments

Comments
 (0)