mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Close the database connection we create during startup (#8131)
... otherwise it gets leaked.
This commit is contained in:
parent
c9c544cda5
commit
12aebdfa5a
1
changelog.d/8131.bugfix
Normal file
1
changelog.d/8131.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix a bug which could cause a leaked postgres connection if synapse was set to daemonize.
|
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user