Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
add execution option for asyncpg_timeout #7604
Copy link
Copy link
Open
Labels
asynciocode review in progresscode has been provided that's in review as PR and/or gerritcode has been provided that's in review as PR and/or gerritpostgresqluse casenot really a feature or a bug; can be support for new DB features or user use cases not anticipatednot really a feature or a bug; can be support for new DB features or user use cases not anticipated
Milestone
Description
Metadata
Metadata
Assignees
Labels
asynciocode review in progresscode has been provided that's in review as PR and/or gerritcode has been provided that's in review as PR and/or gerritpostgresqluse casenot really a feature or a bug; can be support for new DB features or user use cases not anticipatednot really a feature or a bug; can be support for new DB features or user use cases not anticipated
Describe the use case
In our company we use PostgreSQL, one of the tables that is quite big with over 1.5B records. We have few queries constructed with SQLAlchemy Core which we use on it and with help of indexes they're usually quite fast (100's of milliseconds at most). Lately we have discovered and issue with PG's query planner that would omit an index and would run a plan that was stalling the connection for multiple days. After running a particular API request many times our connection pool got exhausted and application basically crashed.
Natural solution to prevent this type of issues would be to implement some sort of timeout. Value of the timeout would depend on the expected execution time of given query. There are of course multiple ways to achieve this:
statement_timeouton current connection in case of PostgreSQL.AsyncConnection.execute()inasyncio.wait_for().timeoutargument toasyncpgdriver via for exampleexecution_optionsargument.Where 1. and 2. seems to be possible options I think it would be very useful if option 3. would be implemented in SQLAlchemy. Timeout mechanism is already built in in
asyncpgdriver but access to it would need to be added.Databases / Backends / Drivers targeted
asyncpgfor PostgreSQLExample Use
Additional context
No response