aio-libs / aiopg

aiopg is a library for accessing a PostgreSQL database from the asyncio
http://aiopg.readthedocs.io
BSD 2-Clause "Simplified" License
1.39k stars 159 forks source link

Connection, returned to pool, should not be usable #288

Open themylogin opened 7 years ago

themylogin commented 7 years ago

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 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.

jettify commented 7 years ago

I think it is good idea! asyncpg doing similar thing https://github.com/MagicStack/asyncpg/pull/99

iasemin commented 4 years ago

Hello!

what about this issue? in version 1.0.0 this bug fixed?