aio-libs / aio-libs/aiopg

Connection, returned to pool, should not be usable

未關閉
#288 2 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
1.4k
分支
170
PR 合併指標
30 天內沒有已合併 PR

描述

The following bug lived in our service for many month, once a few days producing strange error messages. I've even fixed a [real bug](https://github.com/aio-libs/aiopg/issues/216) in `aiopg` trying to figure out what is going on:
```
async with request.app["db"].acquire() as db:
await func1(db)

await func2(db)
```
Connection has been returned to pool, but is still being used outside of pool management logic. This can lead to various concurrency conflicts.

In my opinion, connections that are managed by the pool, should have some flag that either issues warning or raises exception that prevents using them this way. If community agrees, I can implement this and issue a pull-request.

貢獻指南

開啟貢獻指南

研究方向

The entry point shown is request.app["db"].acquire() used as an async context manager; start by tracing what happens when that context exits and the connection returns to the pool. Define and test the chosen warning or exception behavior for later use of db, including the concurrency-conflict case described.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
postgresql, python
領域
databases
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。