aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-04-14 08:56:31 +0300
committerFrederick Muriuki Muriithi2022-04-14 08:59:55 +0300
commit58101923291172e9999ffc607d5f3d1b9507ccfb (patch)
treeb81456937f2c69d2235336bd63197f0307f9d00d
parent47686b74aa4ca4f1dee5c7174b4f4dc54b1a1de8 (diff)
downloadgenenetwork2-58101923291172e9999ffc607d5f3d1b9507ccfb.tar.gz
Debug: Add logging to track db connection creation and stoppingdebug-too-many-connections-error
As part of debugging the "Too many connections" error to the database, this commit adds logging to track the creation of connections to the database, and their eventual closing.
-rw-r--r--wqflask/wqflask/views.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 2138146c..fdb49c7f 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -110,6 +110,9 @@ logger = utility.logger.getLogger(__name__)
def connect_db():
db = getattr(g, '_database', None)
if request.endpoint not in ("static", "js") and db is None:
+ logger.debug(
+ f"Creating a database connection\n"
+ f"\t\tfor request: {request.endpoint}")
g.db = g._database = sqlalchemy.create_engine(
SQL_URI, encoding="latin1")
@@ -118,8 +121,10 @@ def connect_db():
def shutdown_session(exception=None):
db = getattr(g, '_database', None)
if db is not None:
+ logger.debug(f"Removing the session")
g.db.dispose()
g.db = None
+ logger.debug(f"g.db: {g.db}\n\tg._database: {g._database}")
@app.errorhandler(Exception)