MagicStack / MagicStack/asyncpg

cannot switch to state 15; another operation (2) is in progress

未关闭
#784 2 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
8.1k
派生
468
PR 合并指标
30 天内没有已合并 PR

描述

* **asyncpg version**: 0.23.0
* **PostgreSQL version**: Aurora PostgreSQL 10.14
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?**: RDS Aurora (and hard to repro)
* **Python version**: 3.9
* **Platform**: Linux
* **Do you use pgbouncer?**: no
* **Did you install asyncpg with pip?**: pip3.9 install --user
* **If you built asyncpg locally, which version of Cython did you use?**:
* **Can the issue be reproduced under both asyncio and [uvloop](https://github.com/magicstack/uvloop)?**: repro'd with uvloop

```
File "/root/.local/lib/python3.9/site-packages/asyncpg/pool.py", line 792, in __aexit__
await self.pool.release(con)
File "/root/.local/lib/python3.9/site-packages/asyncpg/pool.py", line 666, in release
return await asyncio.shield(ch.release(timeout))
File "/usr/lib/python3.9/asyncio/futures.py", line 284, in __await__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.9/asyncio/tasks.py", line 328, in __wakeup
future.result()
File "/usr/lib/python3.9/asyncio/futures.py", line 201, in result
raise self._exception
File "/usr/lib/python3.9/asyncio/tasks.py", line 256, in __step
result = coro.send(None)
File "/root/.local/lib/python3.9/site-packages/asyncpg/pool.py", line 218, in release
raise ex
File "/root/.local/lib/python3.9/site-packages/asyncpg/pool.py", line 208, in release
await self._con.reset(timeout=budget)
File "/root/.local/lib/python3.9/site-packages/asyncpg/connection.py", line 1311, in reset
await self.execute(reset_query, timeout=timeout)
File "lib/common.py", line 164, in execute
return await self._with_logger(super(PSQLLoggerMixin, self).execute)(*args, **kwargs)
File "lib/common.py", line 119, in wrapper
ret_val = await func(*args, **kwargs)
File "/root/.local/lib/python3.9/site-packages/asyncpg/connection.py", line 297, in execute
return await self._protocol.query(query, timeout)
File "asyncpg/protocol/protocol.pyx", line 338, in query
File "/usr/lib/python3.9/asyncio/futures.py", line 287, in __await__
return self.result() # May raise too.
File "/usr/lib/python3.9/asyncio/futures.py", line 201, in result
raise self._exception
File "asyncpg/protocol/protocol.pyx", line 331, in asyncpg.protocol.protocol.BaseProtocol.query
File "asyncpg/protocol/coreproto.pyx", line 1061, in asyncpg.protocol.protocol.CoreProtocol._simple_query
File "asyncpg/protocol/coreproto.pyx", line 768, in asyncpg.protocol.protocol.CoreProtocol._set_state
asyncpg.exceptions._base.InternalClientError: cannot switch to state 15; another operation (2) is in progress
```

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 asyncpg/pool.py 中 release 附近、asyncpg/connection.py 中 reset 附近以及 asyncpg/protocol/coreproto.pyx 中 _set_state 附近开始。查看 traceback 并调查并发操作路径,注意该报告难以复现,并且是在使用 uvloop 和 Aurora PostgreSQL 时发现的。完成标准是能够复现或解释原因,并在不破坏连接释放的情况下修正状态切换失败。

由索引模型根据 Issue 内容生成。

评估

技术栈
postgresql, python
领域
databases
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。