MagicStack / MagicStack/asyncpg

Infinite hang on leaving conn.transaction() block

Đang mở
#442 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
8.1k
Fork
469
Merge trung bình
18 phút
Pull request đã merge (30 ngày)
4

Mô tả

Hi, I am experiencing hangs at aexit of Transaction context manager, with traceback as follows:

...
  File "/usr/local/lib/python3.7/dist-packages/asyncpg/transaction.py", line 89, in __aexit__
    await self.__rollback()
  File "/usr/local/lib/python3.7/dist-packages/asyncpg/transaction.py", line 198, in __rollback
    await self._connection.execute(query)
  File "/code/callmeback/detail/log_helpers/postgre_conn.py", line 53, in execute
    return await super(LoggingConn, self).execute(query, *args, timeout=timeout)
  File "/usr/local/lib/python3.7/dist-packages/asyncpg/connection.py", line 273, in execute
    return await self._protocol.query(query, timeout)

Default command timeout is set for connection:

>>> conn = frame.f_locals['self']
>>> conn._config
ConnectionConfiguration(command_timeout=10.0, statement_cache_size=100, max_cached_statement_lifetime=300, max_cacheable_statement_size=15360)
>>> conn._protocol._get_timeout(None)
10.0

So I expect self._protocol.query() to throw TimeoutError of some kind, but related coroutine hanged for three days with no progress.

I will happily provide you with any additional information, if I can. My app has aiomonitor onboard, so if any info reachable that way will help you - please let me know.

I tried to fiddle with conn._protocol, but almost nothing of its state is reachable from aioconsole since it's Cython.

My suspection is that exception that leads to rollback is coming from in-transaction query that somehow leads connection in such a state that rollback() cannot be processed normally. I will provide you with information about exception once that problem triggers next time.

  • asyncpg version: 0.18.3
  • PostgreSQL version: 10.7
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    :
  • Python version: 3.7
  • Platform: Ubuntu 16.04
  • Do you use pgbouncer?: Yes (session-level pooling)
  • 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?
    : Yes, I am using uvloop

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với asyncpg/transaction.py tại aexitrollback, sau đó lần theo connection.py execute() đến _protocol.query(). Nếu có thể, hãy tái hiện tình trạng treo với PostgreSQL 10.7, session-level pooling của pgbouncer và uvloop; được xem là hoàn tất khi đường dẫn rollback hoàn thành hoặc đưa ra timeout đã cấu hình thay vì bị treo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
postgresql, python
Lĩnh vực
backend, databases
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.