kaxil commented on a change in pull request #7172: [AIRFLOW-6564] Additional 
diagnostics information on CI check failure
URL: https://github.com/apache/airflow/pull/7172#discussion_r367115505
 
 

 ##########
 File path: airflow/utils/db.py
 ##########
 @@ -501,3 +501,13 @@ def resetdb():
     Base.metadata.drop_all(connection)  # pylint: disable=no-member
 
     initdb()
+
+
+@provide_session
+def check(session=None):
+    """
+    Checks if the database works.
+    :param session: session of the sqlalchemy
+    """
+    session.execute('select 1 as is_alive;')
+    log.info("Connection successful.")
 
 Review comment:
   I think the `health` endpoint I mentioned above would be more useful as it 
checks if the Scheduler can connect to the metadata DB. 
`session.execute('select 1 as is_alive;')` would check if the machine where the 
cli is run can execute that query on the Metadb -> i.e. it will check 
connection between Machine running CLI with DB

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to