MagicStack / MagicStack/asyncpg
getaddrinfo() error / exception not re-raised?
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.22
- PostgreSQL version:
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: - Python version: 3.8
- Platform: linux ubuntu 20.04
- Do you use pgbouncer?:nope
- 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?: Did not test
Potential slight bug?
I have an asyncio loop with a task that sequentially pops queries from an asyncio queue to execute, one at a time, in a remote timescaleDB (postgresql) database. Everything works like a charm. And I'd rather say quite performant!
But, whenever I unplug the ethernet cable of query requester (to simulate sudden connection losses), an uncatched exception error pops up related to the impossibility to resolve the name address of the DSN
: 2021-09-10 10:10:44.846 ERROR: Future exception was never retrieved
: future: <Future finished exception=gaierror(-3, 'Temporary failure in name resolution')>
: Traceback (most recent call last):
: File "/home/venv/lib/python3.8/site-packages/asyncpg/connection.py", line 1393, in _cancel
: await connect_utils._cancel(
: File "/home/venv/lib/python3.8/site-packages/asyncpg/connect_utils.py", line 696, in _cancel
: tr, pr = await _create_ssl_connection(
: File "/home/venv/lib/python3.8/site-packages/asyncpg/connect_utils.py", line 544, in _create_ssl_connection
: tr, pr = await loop.create_connection(
: File "/usr/lib/python3.8/asyncio/base_events.py", line 986, in create_connection
: infos = await self._ensure_resolved(
: File "/usr/lib/python3.8/asyncio/base_events.py", line 1365, in _ensure_resolved
: return await loop.getaddrinfo(host, port, family=family, type=type,
: File "/usr/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
: return await self.run_in_executor(
: File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
: result = self.fn(*self.args, **self.kwargs)
: File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
: for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
: socket.gaierror: [Errno -3] Temporary failure in name resolution
I have the execute() code within a try: / exception: block. Amongst the several exceptions i trap i have the generic exception Exception. But this is of no use because this error is not re raised and keeps within the asyncpg library.
Shouldn't it be re raised so that the app deals with that issue?
Thank you for this fantastic library!
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách đọc asyncpg/connection.py quanh _cancel và asyncpg/connect_utils.py quanh _cancel cùng _create_ssl_connection, sau đó tái hiện lỗi DNS đã được báo cáo khi một kết nối đang hoạt động. Theo dõi cách gaierror được xử lý và liệu cancellation future có được theo dõi hay không. Được xem là hoàn tất khi hành vi lỗi được bao phủ bởi một bài kiểm thử hồi quy và exception phát sinh được chuyển đến ứng dụng thay vì được báo cáo dưới dạng unretrieved future exception.
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
- database
- 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
- Cần làm rõ
- Mức phù hợp với người mới
- 42/100