Jul 31 - Fix database issue which leads to the app dies
This commit is contained in:
@@ -41,8 +41,21 @@ class Config:
|
||||
'pool_timeout': int(os.environ.get('SQLALCHEMY_ENGINE_OPTIONS_POOL_TIMEOUT', '20')),
|
||||
'pool_recycle': int(os.environ.get('SQLALCHEMY_ENGINE_OPTIONS_POOL_RECYCLE', '3600')),
|
||||
'max_overflow': int(os.environ.get('SQLALCHEMY_ENGINE_OPTIONS_MAX_OVERFLOW', '20')),
|
||||
# Validate a pooled connection before handing it out. Without this, every
|
||||
# connection opened while mysqld was down/restarting stays in the pool as a
|
||||
# dead socket and keeps failing requests long after MySQL has recovered.
|
||||
'pool_pre_ping': True,
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# Startup DB-connect retry (server reboot: gunicorn may start before mysqld)
|
||||
# ------------------------------------------------------------------ #
|
||||
# Observed worst case: an unattended-upgrades restart of mysql-server left
|
||||
# mysqld down for ~15s. 8 attempts x 3s covers ~21s of downtime while
|
||||
# staying inside gunicorn's 30s worker-boot timeout.
|
||||
DB_STARTUP_RETRY_ATTEMPTS = int(os.environ.get('DB_STARTUP_RETRY_ATTEMPTS', '8'))
|
||||
DB_STARTUP_RETRY_DELAY = int(os.environ.get('DB_STARTUP_RETRY_DELAY', '3'))
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# Session / cookies
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
Reference in New Issue
Block a user