From 5a20d34ce69a65a612ffa1dd34694eeec2bbbe43 Mon Sep 17 00:00:00 2001 From: JuanJo Ciarlante Date: Wed, 4 Mar 2015 12:30:55 -0300 Subject: [PATCH] [jjo, r=] sync charmhelpers, then expose wait-timeout config --- config.yaml | 4 ++++ hooks/charmhelpers/contrib/database/mysql.py | 5 +++-- templates/my.cnf | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config.yaml b/config.yaml index 0c78ddd..ef7f87c 100644 --- a/config.yaml +++ b/config.yaml @@ -11,6 +11,10 @@ options: default: -1 type: int description: Maximum connections to allow. -1 means use the server's compiled in default. + wait-timeout: + default: -1 + type: int + description: The number of seconds the server waits for activity on a noninteractive connection before closing it. -1 means use the server's compiled in default. root-password: type: string default: diff --git a/hooks/charmhelpers/contrib/database/mysql.py b/hooks/charmhelpers/contrib/database/mysql.py index e3c16ac..e9f1052 100644 --- a/hooks/charmhelpers/contrib/database/mysql.py +++ b/hooks/charmhelpers/contrib/database/mysql.py @@ -1,6 +1,5 @@ """Helper for working with a MySQL database""" import json -import socket import re import sys import platform @@ -22,7 +21,6 @@ from charmhelpers.core.hookenv import ( log, DEBUG, INFO, - WARNING, ) from charmhelpers.fetch import ( apt_install, @@ -359,6 +357,9 @@ class PerconaClusterHelper(object): if 'max-connections' in config: mysql_config['max_connections'] = config['max-connections'] + if 'wait-timeout' in config: + mysql_config['wait_timeout'] = config['wait-timeout'] + # Set a sane default key_buffer size mysql_config['key_buffer'] = self.human_to_bytes('32M') total_memory = self.human_to_bytes(self.get_mem_total()) diff --git a/templates/my.cnf b/templates/my.cnf index 19f3f86..6df56b5 100644 --- a/templates/my.cnf +++ b/templates/my.cnf @@ -59,6 +59,11 @@ wsrep_sst_auth="sstuser:{{ sst_password }}" max_connections = {{ max_connections }} {% endif %} +# Seconds before clearing idle connections +{% if wait_timeout != -1 %} +wait_timeout = {{ wait_timeout }} +{% endif %} + # Fine tuning key_buffer_size = {{ key_buffer }} table_open_cache = {{ table_open_cache }}