taskiq icon indicating copy to clipboard operation
taskiq copied to clipboard

DB connection gives Quepool limit exceeded when run with TaskIQ

Open SifatHasnain opened this issue 1 year ago • 1 comments

Screenshot from 2024-09-28 00-40-35 I am using ListQueueBroker from taskiq-redis. The task I am running handles database queries with Python SqlAlchemy (Postgresql). The same task when running in the background for even 1000 times, the system does not break. But with TaskIQ I am getting this timeout error saying QueuePool limit is exceeded. The configuration I am using for the DB connection is engine = create_async_engine( DB_URI, poolclass=AsyncAdaptedQueuePool, pool_size=int(os.environ.get("DB_POOL_SIZE", 10)), max_overflow=int(os.environ.get("DB_MAX_OVERFLOW", 10)), pool_pre_ping=True, pool_recycle=3600, pool_timeout=20, )

I have tried increasing the values but even with 30 tasks the system breaks.

SifatHasnain avatar Sep 27 '24 18:09 SifatHasnain

If most of your tasks are async tasks and require a db session, you should probably lower the max_async_tasks to match the db pool size

kyboi avatar Apr 07 '25 17:04 kyboi