Skip to content

Commit

Permalink
pool_pre_ping defaults to True
Browse files Browse the repository at this point in the history
  • Loading branch information
frafra committed Jun 19, 2019
1 parent cae3949 commit ae9eb13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ckan/config/environment.py
Expand Up @@ -293,6 +293,10 @@ def update_config():
# CONFIGURATION OPTIONS HERE (note: all config options will override
# any Pylons config options)

# Enable pessimistic disconnect handling (added in SQLAlchemy 1.2)
# to eliminate database errors due to stale pooled connections
config.setdefault('pool_pre_ping', True)

# Initialize SQLAlchemy
engine = sqlalchemy.engine_from_config(config)
model.init_model(engine)
Expand Down
1 change: 1 addition & 0 deletions ckanext/datastore/backend/postgres.py
Expand Up @@ -115,6 +115,7 @@ def _get_engine_from_url(connection_url):
engine = _engines.get(connection_url)
if not engine:
extras = {'url': connection_url}
config.setdefault('pool_pre_ping', True)
engine = sqlalchemy.engine_from_config(config,
'ckan.datastore.sqlalchemy.',
**extras)
Expand Down

0 comments on commit ae9eb13

Please sign in to comment.