From ca65d01f1a85dca27720bf14ade4ee67f6f62d14 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Tue, 5 May 2020 15:42:59 -0400 Subject: [PATCH 1/3] Add SQLALCHEMY_ENGINE_OPTIONS with a slightly higher default max_overflow --- CTFd/config.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CTFd/config.py b/CTFd/config.py index 47b1edf..eede8a4 100644 --- a/CTFd/config.py +++ b/CTFd/config.py @@ -231,6 +231,11 @@ class Config(object): SERVER_SENT_EVENTS: Specifies whether or not to enable to server-sent events based Notifications system. + + SQLALCHEMY_ENGINE_OPTIONS: + A dictionary of keyword args to send to the underlying SQLAlchemy create_engine() call. + https://docs.sqlalchemy.org/en/13/core/engines.html#sqlalchemy.create_engine + https://flask-sqlalchemy.palletsprojects.com/en/2.x/config/#configuration-keys """ REVERSE_PROXY = os.getenv("REVERSE_PROXY") or False TEMPLATES_AUTO_RELOAD = not os.getenv("TEMPLATES_AUTO_RELOAD") # Defaults True @@ -241,6 +246,9 @@ class Config(object): UPDATE_CHECK = not os.getenv("UPDATE_CHECK") # Defaults True APPLICATION_ROOT = os.getenv("APPLICATION_ROOT") or "/" SERVER_SENT_EVENTS = not os.getenv("SERVER_SENT_EVENTS") # Defaults True + SQLALCHEMY_ENGINE_OPTIONS = { + "max_overflow": int(os.getenv("SQLALCHEMY_MAX_OVERFLOW", 20)), + } """ === OAUTH === From 565b218ebc83e6b0f5fbb4b2e160648973968db0 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Tue, 5 May 2020 16:45:22 -0400 Subject: [PATCH 2/3] Run format --- CTFd/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CTFd/config.py b/CTFd/config.py index eede8a4..629f1a2 100644 --- a/CTFd/config.py +++ b/CTFd/config.py @@ -247,7 +247,7 @@ class Config(object): APPLICATION_ROOT = os.getenv("APPLICATION_ROOT") or "/" SERVER_SENT_EVENTS = not os.getenv("SERVER_SENT_EVENTS") # Defaults True SQLALCHEMY_ENGINE_OPTIONS = { - "max_overflow": int(os.getenv("SQLALCHEMY_MAX_OVERFLOW", 20)), + "max_overflow": int(os.getenv("SQLALCHEMY_MAX_OVERFLOW", 20)) } """ From 2f6ee65f331f56586d287af6cf8dd92e751da215 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Tue, 5 May 2020 19:39:36 -0400 Subject: [PATCH 3/3] Only add SQLALCHEMY_ENGINE_OPTIONS under production databases --- CTFd/config.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CTFd/config.py b/CTFd/config.py index 629f1a2..7ac2ef5 100644 --- a/CTFd/config.py +++ b/CTFd/config.py @@ -246,9 +246,10 @@ class Config(object): UPDATE_CHECK = not os.getenv("UPDATE_CHECK") # Defaults True APPLICATION_ROOT = os.getenv("APPLICATION_ROOT") or "/" SERVER_SENT_EVENTS = not os.getenv("SERVER_SENT_EVENTS") # Defaults True - SQLALCHEMY_ENGINE_OPTIONS = { - "max_overflow": int(os.getenv("SQLALCHEMY_MAX_OVERFLOW", 20)) - } + if DATABASE_URL.startswith("sqlite") is False: + SQLALCHEMY_ENGINE_OPTIONS = { + "max_overflow": int(os.getenv("SQLALCHEMY_MAX_OVERFLOW", 20)) + } """ === OAUTH ===