Skip to content

Commit

Permalink
perf(config): make closing of database connections optional (reanahub…
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonadoni committed Aug 6, 2024
1 parent 1288088 commit a41e330
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions reana_job_controller/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@

"""Flask application configuration."""

from distutils.util import strtobool
import os

from reana_commons.config import REANA_COMPONENT_PREFIX

from werkzeug.utils import import_string

REANA_DB_CLOSE_POOL_CONNECTIONS = bool(
strtobool(os.getenv("REANA_DB_CLOSE_POOL_CONNECTIONS", "false"))
)

CACHE_ENABLED = False
"""Determines if jobs caching is enabled."""

Expand Down
3 changes: 2 additions & 1 deletion reana_job_controller/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def receive_checkin(dbapi_connection, connection_record):
# To improve scalability, we should consider refactoring job-controller to avoid
# accessing the database, or at least consider using external connection pooling
# mechanisms such as pgBouncer.
connection_record.close()
if config.REANA_DB_CLOSE_POOL_CONNECTIONS:
connection_record.close()


def shutdown_session(response_or_exc):
Expand Down

0 comments on commit a41e330

Please sign in to comment.