Terminate function does not work when a stream is cancelled prematurely when in an anyio task group
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bản tái hiện tối thiểu được liên kết trong phần thảo luận của SQLAlchemy; trước tiên hãy chạy nó với thiết lập asyncpg và anyio được báo cáo, rồi theo dõi đường dẫn close-then-terminate trong quá trình hủy nhóm tác vụ. Sử dụng các entry point terminate và close của asyncpg để xác định vị trí xử lý vòng đời kết nối. Hoàn tất khi một stream bị hủy không còn để kết nối ở trạng thái idle in transaction.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
- asyncpg version: 0.29.0
- PostgreSQL version: 14.10
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: Yes, I can reproduce it locally - Python version: 3.12
- Platform: linux and Mac OS
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
- If you built asyncpg locally, which version of Cython did you use?: n/a
- Can the issue be reproduced under both asyncio and
uvloop?: No, the issue is not producible with asyncio only with anyio
Hi, I have a Fast API application that uses SQLAlchemy and asyncpg. I opened up a discussion on the SQLAlchemy page here (full discussion) reporting a major problem that affected my application after an update they released.
To summarize the problem and what we concluded in that discussion,
I asynchronously stream data from my API to a client using the starlette StreamingResponse class which takes advantage ofanyio under the hood. For some reason when the anyio task group gets cancelled before the stream is finished the asyncpg terminate function does not terminate the connection when the close function is used first, leaving it stuck in an idle in transaction state. This causes connections to run up eventually stopping other applications from creating new connections.
With some help from the SQLAlchemy folks, after some time working through the problem we were able to reproduce a small example of my problem using only the asyncpg and anyio libraries here (Example of problem)
Any help resolving this issue would be greatly appreciated! If you need any more info from me please do not hesitate to message back
Thanks in advance!
- Ngôn ngữ chính
- Python
- Star
- 8.1k
- Fork
- 469
- Merge trung bình
- 2 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 9
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.
Issue khác của MagicStack/asyncpg
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MagicStack/asyncpg#1357 · 1 bình luận · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
MagicStack/asyncpg#1342 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
MagicStack/asyncpg#1340 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 28/100
MagicStack/asyncpg#1337 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
MagicStack/asyncpg#1330 · 1 bình luận ·
Tất cả issue của MagicStack/asyncpg
Issue tương tự
-
bug confirmed issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
open-webui/open-webui#30750 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100