Repository: incubator-airflow
Updated Branches:
  refs/heads/master 406d738b1 -> 1359d8735


[AIRFLOW-1559] Make database pooling optional

In situations where a database is heavily loaded with connections it
can be beneficial for operators to (temporarily) reduce the connection
footprint of Airflow on the database. This is particularly important
when Airflow or self-made extensions do not dispose the connection
pool when terminating.

Disabling the connection pool comes with a slowdown but that may be
acceptable in many deployment scenarios.


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/3bde95e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/3bde95e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/3bde95e5

Branch: refs/heads/master
Commit: 3bde95e599b56af9bb98caf66ac8248d6b7b9094
Parents: 0211219
Author: Stephan Erb <[email protected]>
Authored: Fri Nov 24 20:40:10 2017 +0100
Committer: Stephan Erb <[email protected]>
Committed: Wed Nov 29 08:50:34 2017 +0100

----------------------------------------------------------------------
 airflow/config_templates/default_airflow.cfg | 5 ++++-
 airflow/settings.py                          | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/3bde95e5/airflow/config_templates/default_airflow.cfg
----------------------------------------------------------------------
diff --git a/airflow/config_templates/default_airflow.cfg 
b/airflow/config_templates/default_airflow.cfg
index a339673..7a8ddf2 100644
--- a/airflow/config_templates/default_airflow.cfg
+++ b/airflow/config_templates/default_airflow.cfg
@@ -67,8 +67,11 @@ executor = SequentialExecutor
 # their website
 sql_alchemy_conn = sqlite:///{AIRFLOW_HOME}/airflow.db
 
+# If SqlAlchemy should pool database connections.
+sql_alchemy_pool_enabled = True
+
 # The SqlAlchemy pool size is the maximum number of database connections
-# in the pool.
+# in the pool. 0 indicates no limit.
 sql_alchemy_pool_size = 5
 
 # The SqlAlchemy pool recycle is the number of seconds a connection

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/3bde95e5/airflow/settings.py
----------------------------------------------------------------------
diff --git a/airflow/settings.py b/airflow/settings.py
index 39342df..5559646 100644
--- a/airflow/settings.py
+++ b/airflow/settings.py
@@ -139,7 +139,9 @@ def configure_orm(disable_connection_pool=False):
     global engine
     global Session
     engine_args = {}
-    if disable_connection_pool:
+
+    pool_connections = conf.getboolean('core', 'SQL_ALCHEMY_POOL_ENABLED')
+    if disable_connection_pool or not pool_connections:
         engine_args['poolclass'] = NullPool
     elif 'sqlite' not in SQL_ALCHEMY_CONN:
         # Engine args not supported by sqlite

Reply via email to