-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Connection pool throws error instead of blocking until connection is available: redis.exceptions.ConnectionError: Too many connections #2517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looking at source I found
import asyncio
from redis import asyncio as redis
async def main() -> None:
pool = redis.BlockingConnectionPool(max_connections=2)
async with redis.Redis(connection_pool=pool) as rd:
await asyncio.gather(*[rd.set(str(i), i) for i in range(100)])
asyncio.run(main()) It solves both problems: has sane number of connections by default and blocks instead of raising exception so that all operations complete successfully. Another note is that redis client accepting pool object means it ignores quite a lot of configuration present in |
I created this PR: #2618 as a way to pass in the ConnectionPool's class. Otherwise I think all this logic and these defaults have to be copy and pasted outside where the ConnectionPool is then created: redis-py/redis/asyncio/client.py Lines 158 to 169 in 6c708c2
redis-py/redis/asyncio/client.py Lines 217 to 248 in 6c708c2
|
This issue is marked stale. It will be closed in 30 days if it is not updated. |
Version: 4.4.0
Platform: Linux
Description: Connection pool works in unexpected way: when connection limit is reached it throws an error.
Code to reproduce:
By default redis sets connection limit to ridiculously high number: #2220
This hides the issue with pool. When set so something realistic like 50 or 100 it starts throwing
redis.exceptions.ConnectionError: Too many connections
under load.This bug was introduced in aioredis 2.0, here is relevant issue in aioredis repo: aio-libs-abandoned/aioredis-py#1173
This comment in particular explains the problem: aio-libs-abandoned/aioredis-py#1173 (comment)
aredis has the same design for some reason: NoneGG/aredis#167
Other than that I am unfamiliar with async connection pool implementations that would throw errors instead of waiting so I think this is a bug.
I think sync pool works in the same way. Probably not a desired behaviour for sync apps as well.
The text was updated successfully, but these errors were encountered: