Skip to content
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

ITVR - task queue creates too many database connections #778

Open
tim738745 opened this issue Jan 28, 2025 · 0 comments
Open

ITVR - task queue creates too many database connections #778

tim738745 opened this issue Jan 28, 2025 · 0 comments
Assignees
Labels
Bug Something isn't working Medium Medium priority

Comments

@tim738745
Copy link
Collaborator

tim738745 commented Jan 28, 2025

Describe the Bug
From time to time, the task queue service may create and leave open too many database connections; this impacts the ability for the backend to connect to the database.

Expected Behaviour
This should not happen.

Actual Behaviour
This does happen.

Implications
The backend may not be able to connect to the database, and the task queue itself is unable to make new connections to the database.

Steps To Reproduce
This is hard to reproduce, because it does not happen deterministically. The task queue has 4 worker processes, and the threads in each process manages its own database connections. While django-q, the library we're using, does close db connections, it only seems to close them at the beginning of each task/job. So it could be the case that a scheduled job that opens some connections executes in process 1, and then in process 2, and then process 3. This would lead to an accumulation of connections. However, if it executes in process 1 the second time around, the connections it created the first time around would be closed. We do not determine in which process a job executes. So to address this issue, we should close db connections at the end of each task/job (see scheduled_jobs.py).

Also, the job that expires rebates runs each expiry action inside a transaction; maybe each transaction opens a new connection?

@ArawuSamuel1 ArawuSamuel1 added Bug Something isn't working Medium Medium priority labels Jan 31, 2025
@tim738745 tim738745 self-assigned this Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Medium Medium priority
Projects
None yet
Development

No branches or pull requests

2 participants