fix: mysqlor.enter() 先 commit 结束旧事务,防止连接池复用读脏数据
aiomysql 默认 autocommit=False。连接池复用连接时, 读操作(SELECT)后不调 commit(),导致未结束的事务+REPEATABLE READ 快照残留。之后其他实例 DELETE 了记录,这个连接复用后 仍看到旧快照,出现"读到刚删除记录"的问题。 在 enter() 开头 commit() 结束上一个使用留下的任何事务。
This commit is contained in:
parent
ab3ff00753
commit
fab420c9d9
@ -159,6 +159,7 @@ WHERE
|
|||||||
await self.conn.close()
|
await self.conn.close()
|
||||||
|
|
||||||
async def enter(self):
|
async def enter(self):
|
||||||
|
await self.conn.commit()
|
||||||
self.cur = await self.conn.cursor()
|
self.cur = await self.conn.cursor()
|
||||||
|
|
||||||
async def exit(self):
|
async def exit(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user