MagicStack / MagicStack/asyncpg

connection.close is throwing protocol error

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

还没有人认领这个 Issue。

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

描述

asyncpg version: 0.18.1
PostgreSQL version: 9.5.10
Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: using google cloud sql pg instance
Python version: 3.6.5
Platform: Ubuntu
Do you use pgbouncer?: No
Did you install asyncpg with pip?: Yes
If you built asyncpg locally, which version of Cython did you use?:
Can the issue be reproduced under both asyncio and
uvloop?: No

I have been facing this error for quite sometime intermittently asyncpg.exceptions._base.InternalClientError: got result for unknown protocol state 0

The entire stack trace:

 File "/repo/server/schema_db.py", line 345, in read
    await connection.close()

  File "/usr/local/lib/python3.6/dist-packages/asyncpg/connection.py", line 1082, in close
    await self._protocol.close(timeout)

  File "asyncpg/protocol/protocol.pyx", line 560, in close

  File "asyncpg/protocol/protocol.pyx", line 814, in asyncpg.protocol.protocol.BaseProtocol._dispatch_result

asyncpg.exceptions._base.InternalClientError: got result for unknown protocol state 0

Can someone explain when this exception is thrown and for what reason?
If i know the reason this exception is thrown, i can figure out the issue myself.
I'm not able to reproduce locally or in my stage environment.

贡献指南

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

从这里开始

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

调研方向

从 schema_db.py:345 处失败的 await connection.close() 开始,然后检查 asyncpg/protocol/protocol.pyx 中的 close 和 BaseProtocol._dispatch_result,并结合报告中的堆栈跟踪和版本详细信息。确定在 Google Cloud SQL PostgreSQL 实例上产生未知协议状态的间歇性条件;当原因以及可靠的复现或验证路径确定后,该 issue 即完成。

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

评估

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

把新 issue 发到你的邮箱

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