From e9ea2a7f67d0781dcc7eb6790a64e94a0c70e538 Mon Sep 17 00:00:00 2001 From: "cucuridas@gamil.com" <3310223@naver.com> Date: Tue, 22 Aug 2023 22:35:49 +0900 Subject: [PATCH 1/5] fix: Add 'commit' after execute a query to check table information --- pymysqlreplication/binlogstream.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pymysqlreplication/binlogstream.py b/pymysqlreplication/binlogstream.py index 9c324a06..e4077418 100644 --- a/pymysqlreplication/binlogstream.py +++ b/pymysqlreplication/binlogstream.py @@ -653,6 +653,7 @@ def __get_table_information(self, schema, table): table_schema = %s AND table_name = %s ORDER BY ORDINAL_POSITION """, (schema, table)) + cur.execute("COMMIT") return cur.fetchall() except pymysql.OperationalError as error: From abff2a3a22870c7b564e4b33561b14f5720f4b49 Mon Sep 17 00:00:00 2001 From: "cucuridas@gamil.com" <3310223@naver.com> Date: Tue, 22 Aug 2023 22:44:35 +0900 Subject: [PATCH 2/5] fix: Define query results in variables --- pymysqlreplication/binlogstream.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pymysqlreplication/binlogstream.py b/pymysqlreplication/binlogstream.py index e4077418..2a94435f 100644 --- a/pymysqlreplication/binlogstream.py +++ b/pymysqlreplication/binlogstream.py @@ -653,9 +653,10 @@ def __get_table_information(self, schema, table): table_schema = %s AND table_name = %s ORDER BY ORDINAL_POSITION """, (schema, table)) + result = cur.fetchall() cur.execute("COMMIT") - return cur.fetchall() + return result except pymysql.OperationalError as error: code, message = error.args if code in MYSQL_EXPECTED_ERROR_CODES: From 9ea62541d2a757258e3f86696a49ee3f16cb4919 Mon Sep 17 00:00:00 2001 From: davinc71998 Date: Tue, 22 Aug 2023 22:53:31 +0900 Subject: [PATCH 3/5] fix: add cursor closing --- pymysqlreplication/binlogstream.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pymysqlreplication/binlogstream.py b/pymysqlreplication/binlogstream.py index 2a94435f..035ff400 100644 --- a/pymysqlreplication/binlogstream.py +++ b/pymysqlreplication/binlogstream.py @@ -655,6 +655,7 @@ def __get_table_information(self, schema, table): """, (schema, table)) result = cur.fetchall() cur.execute("COMMIT") + cur.close() return result except pymysql.OperationalError as error: From c18661baf892f1baa37a7dfacc6dfffa65aba674 Mon Sep 17 00:00:00 2001 From: sean Date: Wed, 23 Aug 2023 15:21:31 +0900 Subject: [PATCH 4/5] autocommit true --- pymysqlreplication/binlogstream.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pymysqlreplication/binlogstream.py b/pymysqlreplication/binlogstream.py index 035ff400..b81fe170 100644 --- a/pymysqlreplication/binlogstream.py +++ b/pymysqlreplication/binlogstream.py @@ -256,6 +256,7 @@ def __connect_to_ctl(self): self._ctl_connection_settings = dict(self.__connection_settings) self._ctl_connection_settings["db"] = "information_schema" self._ctl_connection_settings["cursorclass"] = DictCursor + self._ctl_connection_settings["autocommit"] = True self._ctl_connection = self.pymysql_wrapper(**self._ctl_connection_settings) self._ctl_connection._get_table_information = self.__get_table_information self.__connected_ctl = True From 8805c30e971e99a652ee0a3bc10bca3ed820f3ab Mon Sep 17 00:00:00 2001 From: sean Date: Wed, 23 Aug 2023 18:32:30 +0900 Subject: [PATCH 5/5] feat: commit delete --- pymysqlreplication/binlogstream.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pymysqlreplication/binlogstream.py b/pymysqlreplication/binlogstream.py index b81fe170..942aa712 100644 --- a/pymysqlreplication/binlogstream.py +++ b/pymysqlreplication/binlogstream.py @@ -655,7 +655,6 @@ def __get_table_information(self, schema, table): ORDER BY ORDINAL_POSITION """, (schema, table)) result = cur.fetchall() - cur.execute("COMMIT") cur.close() return result