Allow configuration of sql_idle_timeout
This helps to avoid `MySQL server has gone away` errors.
Change-Id: I62082a3b07d66ddd97b1cde3ad84ee308f36313e
diff --git a/README.rst b/README.rst
index 4d28f57..970ef1d 100644
--- a/README.rst
+++ b/README.rst
@@ -132,6 +132,29 @@
ks_notifications_allow_requeue: true
+MySQL server has gone away
+
+MySQL uses a default `wait_timeout` of 8 hours, after which it will drop
+idle connections. This can result in 'MySQL Gone Away' exceptions. If you
+notice this, you can lower `sql_idle_timeout` to ensure that SQLAlchemy
+reconnects before MySQL can drop the connection.
+
+.. code-block:: yaml
+
+ barbican:
+ server:
+ enabled: true
+ version: ocata
+ database:
+ engine: "mysql+pymysql"
+ host: 10.0.106.20
+ port: 3306
+ name: barbican
+ user: barbican
+ password: password
+ sql_idle_timeout: 1200
+
+
Configuring plugins
-------------------
diff --git a/barbican/files/ocata/barbican.conf.Debian b/barbican/files/ocata/barbican.conf.Debian
index 54ff0be..eaf7280 100644
--- a/barbican/files/ocata/barbican.conf.Debian
+++ b/barbican/files/ocata/barbican.conf.Debian
@@ -49,7 +49,7 @@
# idle connections. This can result in 'MySQL Gone Away' exceptions. If you
# notice this, you can lower this value to ensure that SQLAlchemy reconnects
# before MySQL can drop the connection.
-sql_idle_timeout = 3600
+sql_idle_timeout = {{ server.database.get('sql_idle_timeout', 3600) }}
# Accepts a class imported from the sqlalchemy.pool module, and handles the
# details of building the pool for you. If commented out, SQLAlchemy
diff --git a/metadata/service/server/cluster.yml b/metadata/service/server/cluster.yml
index 73a690e..9ca3660 100644
--- a/metadata/service/server/cluster.yml
+++ b/metadata/service/server/cluster.yml
@@ -23,6 +23,7 @@
name: barbican
user: barbican
password: ${_param:mysql_barbican_password}
+ sql_idle_timeout: 1200
identity:
engine: keystone
host: ${_param:cluster_vip_address}
diff --git a/metadata/service/server/single.yml b/metadata/service/server/single.yml
index 91d1b2f..d5c4cf2 100644
--- a/metadata/service/server/single.yml
+++ b/metadata/service/server/single.yml
@@ -23,6 +23,7 @@
name: barbican
user: barbican
password: ${_param:mysql_barbican_password}
+ sql_idle_timeout: 1200
identity:
engine: keystone
host: ${_param:single_address}