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

Fix #178 -- Close connections when exeting threads #182

Merged
merged 1 commit into from
Feb 1, 2018
Merged

Conversation

codingjoe
Copy link
Collaborator

Django uses separate connections for each thread be default.
Open connections are only closed by default when the
request_finished signal is called, which does not happen in our
case.

Django uses separate connections for each thread be default.
Open connections are only closed by default when the
`request_finished` signal is called, which does not happen in our
case.
@codecov-io
Copy link

codecov-io commented Jan 28, 2018

Codecov Report

Merging #182 into master will increase coverage by 0.15%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #182      +/-   ##
==========================================
+ Coverage   86.56%   86.71%   +0.15%     
==========================================
  Files          25       25              
  Lines         253      256       +3     
==========================================
+ Hits          219      222       +3     
  Misses         34       34
Impacted Files Coverage Δ
health_check/views.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca38778...e883a74. Read the comment docs.

@courcelm
Copy link
Contributor

This fix works if CONN_MAX_AGE = 0 in Django database settings. Otherwise, the connections are still pilling up.

@codingjoe codingjoe merged commit d292ada into master Feb 1, 2018
@codingjoe codingjoe deleted the issue/178 branch February 1, 2018 12:54
@codingjoe
Copy link
Collaborator Author

@courcelm that's a good start I guess. I really don't have any idea how to close a connection forcefully before the connection timeout is reached.

@codingjoe
Copy link
Collaborator Author

Released in 3.4.2

@courcelm
Copy link
Contributor

courcelm commented Feb 1, 2018

@codingjoe I would suggest to use close() instead of close_if_unusable_or_obsolete(). This way it will not cause any problem to anyone with CONN_MAX_AGE > 0.

It seems db health check is not re-using existing connection and makes a new one every time from what I can see. If we want to re-use connection, maybe you should exclude this db check from the parralel execution.

@codingjoe
Copy link
Collaborator Author

Ok @courcelm would you mind creating a Pull-Request for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants