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

Connections to DB are still persisting #550

Closed
sellnat77 opened this issue Apr 22, 2020 · 2 comments · Fixed by #601
Closed

Connections to DB are still persisting #550

sellnat77 opened this issue Apr 22, 2020 · 2 comments · Fixed by #601
Assignees
Labels
Bug Something isn't working Role: Backend Related to API or other server-side work v1 The first version of the site

Comments

@sellnat77
Copy link
Member

Describe the bug
Some db operations are still persisting their connections. We have a limited pool of 20 connections so we need to make sure there arent any left over connections

To Reproduce
unsure

Expected behavior
Any call involving the database does not persist a connection

@sellnat77 sellnat77 added Bug Something isn't working Role: Backend Related to API or other server-side work labels Apr 22, 2020
@jmensch1
Copy link
Contributor

I'm thinking this might have to do with how we're using sqlalchemy. Right now we're creating the engine on every request, inside the DataService constructor. According to their docs, we should only really be creating the engine once --

"The Engine is intended to normally be a permanent fixture established up-front and maintained throughout the lifespan of an application. It is not intended to be created and disposed on a per-connection basis; it is instead a registry that maintains both a pool of connections as well as configurational information about the database and DBAPI in use, as well as some degree of internal caching of per-database resources."
https://docs.sqlalchemy.org/en/13/core/connections.html

We could try moving the engine into its own module and configuring it when the app starts, and then the DataService could just use that engine instead of creating a new one every time. But kinda hard to know if this would work since the bug seems to be intermittent.

@adamkendis adamkendis added this to the 311-Data - Beta milestone May 8, 2020
@jmensch1 jmensch1 self-assigned this May 8, 2020
@jmensch1 jmensch1 linked a pull request May 9, 2020 that will close this issue
4 tasks
@jmensch1
Copy link
Contributor

I'm ready to say this is fixed. The number of database connections reported in heroku is consistently 4, which I assume is the number of workers running in Sanic server.

@Rabia2219 Rabia2219 added the v1 The first version of the site label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Role: Backend Related to API or other server-side work v1 The first version of the site
Projects
Development

Successfully merging a pull request may close this issue.

4 participants