MagicStack / MagicStack/asyncpg

ConnectionDoesNotExistError when releasing

Đang mở
#624 0 bình luận 4 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
468
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

  • asyncpg version: 0.21.0
  • PostgreSQL version: 10.7
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : no
  • Python version: 3.7
  • Platform: debian (docker image python:3.7.9-slim)
  • Do you use pgbouncer?: no
  • Did you install asyncpg with pip?: yes
  • If you built asyncpg locally, which version of Cython did you use?: no
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : only tried asyncio

I've found the following exception in our logs:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 214, in release
    self._con.terminate()
AttributeError: 'NoneType' object has no attribute 'terminate'

During handling of the above exception, another exception occurred:
File "/usr/local/lib/python3.7/site-packages/my_code_calling_release.py", line 40, in acquire
     await self.pool.release(con)
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 654, in release
     return await asyncio.shield(ch.release(timeout))   
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 216, in release
     raise ex   
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 206, in release
     await self._con.reset(timeout=budget)
File "/usr/local/lib/python3.7/site-packages/asyncpg/connection.py", line 1137, in reset
     await self.execute(reset_query, timeout=timeout)
File "/usr/local/lib/python3.7/site-packages/asyncpg/connection.py", line 295, in execute
     return await self._protocol.query(query, timeout)
File "asyncpg/protocol/protocol.pyx", line 316, in query

From what I can see, the call at self._con.reset is raising a ConnectionDoesNotExistError.
Should the exception be reraised at line 218 if the exception is an ConnectionDoesNotExistError (we know it's already closed)? It shouldn't even try to self._con.terminate() because self._con is already None (see the exception).

Not sure if the comments in that code still apply for that type of exception

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

Đọc đường dẫn release quanh các dòng 206-218 của asyncpg/pool.py và đường dẫn reset trong asyncpg/connection.py, tập trung vào cách ConnectionDoesNotExistError để self._con ở giá trị None. Tái hiện hoặc thêm một trường hợp hồi quy cho việc release một kết nối đã đóng, sau đó xác minh rằng release không cố gắng kết thúc một kết nối không tồn tại và vẫn giữ nguyên hành vi ngoại lệ như dự kiến.

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
databases
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
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.