Fix bug where we reconnected to the database on every query.

This commit is contained in:
Erik Johnston 2015-05-01 10:24:24 +01:00
parent 23c639ff32
commit fabb7acd45
2 changed files with 2 additions and 1 deletions

View file

@ -301,6 +301,7 @@ class SQLBaseStore(object):
def inner_func(conn, *args, **kwargs):
with LoggingContext("runInteraction") as context:
if self.database_engine.is_connection_closed(conn):
logger.debug("Reconnecting closed database connection")
conn.reconnect()
current_context.copy_to(context)

View file

@ -53,7 +53,7 @@ class PostgresEngine(object):
return False
def is_connection_closed(self, conn):
return bool(conn)
return bool(conn.closed)
def lock_table(self, txn, table):
txn.execute("LOCK TABLE %s in EXCLUSIVE MODE" % (table,))