Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
12aebdfa
Unverified
Commit
12aebdfa
authored
4 years ago
by
Richard van der Hoff
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Close the database connection we create during startup (#8131)
... otherwise it gets leaked.
parent
c9c544cd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/8131.bugfix
+1
-0
1 addition, 0 deletions
changelog.d/8131.bugfix
synapse/storage/databases/__init__.py
+10
-1
10 additions, 1 deletion
synapse/storage/databases/__init__.py
with
11 additions
and
1 deletion
changelog.d/8131.bugfix
0 → 100644
+
1
−
0
View file @
12aebdfa
Fix a bug which could cause a leaked postgres connection if synapse was set to daemonize.
This diff is collapsed.
Click to expand it.
synapse/storage/databases/__init__.py
+
10
−
1
View file @
12aebdfa
...
@@ -87,12 +87,21 @@ class Databases(object):
...
@@ -87,12 +87,21 @@ class Databases(object):
logger
.
info
(
"
Database %r prepared
"
,
db_name
)
logger
.
info
(
"
Database %r prepared
"
,
db_name
)
# Closing the context manager doesn't close the connection.
# psycopg will close the connection when the object gets GCed, but *only*
# if the PID is the same as when the connection was opened [1], and
# it may not be if we fork in the meantime.
#
# [1]: https://github.com/psycopg/psycopg2/blob/2_8_5/psycopg/connection_type.c#L1378
db_conn
.
close
()
# Sanity check that we have actually configured all the required stores.
# Sanity check that we have actually configured all the required stores.
if
not
main
:
if
not
main
:
raise
Exception
(
"
No
'
main
'
data store configured
"
)
raise
Exception
(
"
No
'
main
'
data store configured
"
)
if
not
state
:
if
not
state
:
raise
Exception
(
"
No
'
main
'
data store configured
"
)
raise
Exception
(
"
No
'
state
'
data store configured
"
)
# We use local variables here to ensure that the databases do not have
# We use local variables here to ensure that the databases do not have
# optional types.
# optional types.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment