MagicStack / MagicStack/asyncpg

insufficient data in buffer

未关闭
#1,147 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

* **asyncpg version**: 0.29.0
* **PostgreSQL version**: 15.6
* **Python version**: 3.11.4
* **Platform**: debian
* **Do you use pgbouncer?**: no
* **Did you install asyncpg with pip?**: yes
* **Can the issue be reproduced under both asyncio and
[uvloop](https://github.com/magicstack/uvloop)?**: not sure

```bash
AssertionError: insufficient data in buffer: requested 8 remaining 4
File "sqlalchemy/ext/asyncio/engine.py", line 659, in execute
result = await greenlet_spawn(
File "sqlalchemy/util/_concurrency_py3k.py", line 200, in greenlet_spawn
result = context.throw(*sys.exc_info())
File "sqlalchemy/engine/base.py", line 1416, in execute
return meth(
File "sqlalchemy/sql/elements.py", line 517, in _execute_on_connection
return connection._execute_clauseelement(
File "sqlalchemy/engine/base.py", line 1639, in _execute_clauseelement
ret = self._execute_context(
File "sqlalchemy/engine/base.py", line 1848, in _execute_context
return self._exec_single_context(
File "sqlalchemy/engine/base.py", line 1988, in _exec_single_context
self._handle_dbapi_exception(
File "sqlalchemy/engine/base.py", line 2347, in _handle_dbapi_exception
raise exc_info[1].with_traceback(exc_info[2])
File "sqlalchemy/engine/base.py", line 1969, in _exec_single_context
self.dialect.do_execute(
File "sqlalchemy/engine/default.py", line 922, in do_execute
cursor.execute(statement, parameters)
File "sqlalchemy/dialects/postgresql/asyncpg.py", line 580, in execute
self._adapt_connection.await_(
File "sqlalchemy/util/_concurrency_py3k.py", line 130, in await_only
return current.driver.switch(awaitable) # type: ignore[no-any-return]
File "sqlalchemy/util/_concurrency_py3k.py", line 195, in greenlet_spawn
value = await result
File "sqlalchemy/dialects/postgresql/asyncpg.py", line 558, in _prepare_and_execute
self._handle_exception(error)
File "sqlalchemy/dialects/postgresql/asyncpg.py", line 509, in _handle_exception
self._adapt_connection._handle_exception(error)
File "sqlalchemy/dialects/postgresql/asyncpg.py", line 799, in _handle_exception
raise error
File "sqlalchemy/dialects/postgresql/asyncpg.py", line 546, in _prepare_and_execute
self._rows = await prepared_stmt.fetch(*parameters)
File "asyncpg/prepared_stmt.py", line 176, in fetch
data = await self.__bind_execute(args, 0, timeout)
File "asyncpg/prepared_stmt.py", line 241, in __bind_execute
data, status, _ = await self.__do_execute(
File "asyncpg/prepared_stmt.py", line 230, in __do_execute
return await executor(protocol)
File "asyncpg/protocol/protocol.pyx", line 207, in bind_execute
File "asyncpg/protocol/coreproto.pyx", line 70, in asyncpg.protocol.protocol.CoreProtocol._read_server_messages
File "asyncpg/protocol/coreproto.pyx", line 225, in asyncpg.protocol.protocol.CoreProtocol._process__bind_execute
File "asyncpg/protocol/coreproto.pyx", line 518, in asyncpg.protocol.protocol.CoreProtocol._parse_data_msgs
File "asyncpg/protocol/protocol.pyx", line 839, in asyncpg.protocol.protocol.BaseProtocol._decode_row
File "asyncpg/protocol/prepared_stmt.pyx", line 328, in asyncpg.protocol.protocol.PreparedStatementState._decode_row
File "asyncpg/protocol/codecs/base.pyx", line 330, in asyncpg.protocol.protocol.Codec.decode
File "asyncpg/protocol/codecs/base.pyx", line 230, in asyncpg.protocol.protocol.Codec.decode_scalar
File "asyncpg/pgproto/./codecs/float.pyx", line 33, in asyncpg.pgproto.pgproto.float8_decode
File "asyncpg/pgproto/./frb.pxd", line 27, in asyncpg.pgproto.pgproto.frb_read
File "asyncpg/pgproto/./frb.pyx", line 10, in asyncpg.pgproto.pgproto.frb_check
```

is it a network issue or somewhere I need to look into?

贡献指南

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

从这里开始

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

调研方向

先从 asyncpg/protocol/coreproto.pyx、asyncpg/protocol/codecs/float.pyx 和 asyncpg/protocol/frb.pyx 中的 traceback 条目开始,然后检查所示的 SQLAlchemy 异步执行路径。使用报告中的 Python、PostgreSQL 和 asyncpg 版本重现该故障,并确定是否可以隔离被截断的缓冲区。有了已确认的原因以及回归测试或清晰记录的复现过程,即视为完成。

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

评估

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

把新 issue 发到你的邮箱

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