From fab420c9d9f4831796932187660ec73b3ab27dcd Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 1 Jul 2026 13:17:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mysqlor.enter()=20=E5=85=88=20commit=20?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=97=A7=E4=BA=8B=E5=8A=A1=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E8=BF=9E=E6=8E=A5=E6=B1=A0=E5=A4=8D=E7=94=A8=E8=AF=BB?= =?UTF-8?q?=E8=84=8F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit aiomysql 默认 autocommit=False。连接池复用连接时, 读操作(SELECT)后不调 commit(),导致未结束的事务+REPEATABLE READ 快照残留。之后其他实例 DELETE 了记录,这个连接复用后 仍看到旧快照,出现"读到刚删除记录"的问题。 在 enter() 开头 commit() 结束上一个使用留下的任何事务。 --- sqlor/mysqlor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sqlor/mysqlor.py b/sqlor/mysqlor.py index 57f4028..22b3260 100644 --- a/sqlor/mysqlor.py +++ b/sqlor/mysqlor.py @@ -159,6 +159,7 @@ WHERE await self.conn.close() async def enter(self): + await self.conn.commit() self.cur = await self.conn.cursor() async def exit(self):