Expose most common QueuePoll parameters from SQLAlchemy

Fixes bug 1160442

The defualt parameters are used unless otherwise configured. This
is applicable for:
 - pool_size
 - max_overflow
 - pool_timeout

By increasing the pool_size and the max_overflow and lowering the timeout
the issue reported in the bug is resolved.

NOTE: the configuration values enable the user to make use of the default
QueuePool tuning values.

Change-Id: Ic258442531a2caf2db4f05c4ddd6fbfb0c180f17
This commit is contained in:
Gary Kotton 2013-06-04 15:14:39 +00:00
parent 9105172d46
commit 725d636da5
13 changed files with 81 additions and 18 deletions

View File

@ -23,7 +23,11 @@ reconnect_interval = 2
# Timeout in seconds before idle sql connections are reaped # Timeout in seconds before idle sql connections are reaped
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_pool_size = 5
# Maximum number of overflow connections in a QueuePool in SQLAlchemy
# Example sqlalchemy_max_overflow = 10
# Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
[RESTPROXY] [RESTPROXY]
# All configuration for this plugin is in section '[restproxy]' # All configuration for this plugin is in section '[restproxy]'

View File

@ -22,7 +22,11 @@
# Timeout in seconds before idle sql connections are reaped # Timeout in seconds before idle sql connections are reaped
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_pool_size = 5
# Maximum number of overflow connections in a QueuePool in SQLAlchemy
# Example sqlalchemy_max_overflow = 10
# Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
# #
# Example: # Example:
# sql_connection = mysql://root:pass@localhost/brcd_quantum?charset=utf8 # sql_connection = mysql://root:pass@localhost/brcd_quantum?charset=utf8

View File

@ -21,7 +21,11 @@ reconnect_interval = 2
# Timeout in seconds before idle sql connections are reaped # Timeout in seconds before idle sql connections are reaped
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_pool_size = 5
# Maximum number of overflow connections in a QueuePool in SQLAlchemy
# Example sqlalchemy_max_overflow = 10
# Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
[HYPERV] [HYPERV]
# (StrOpt) Type of network to allocate for tenant networks. The # (StrOpt) Type of network to allocate for tenant networks. The

View File

@ -43,7 +43,11 @@ reconnect_interval = 2
# Timeout in seconds before idle sql connections are reaped # Timeout in seconds before idle sql connections are reaped
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_pool_size = 5
# Maximum number of overflow connections in a QueuePool in SQLAlchemy
# Example sqlalchemy_max_overflow = 10
# Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
[LINUX_BRIDGE] [LINUX_BRIDGE]
# (ListOpt) Comma-separated list of # (ListOpt) Comma-separated list of

View File

@ -23,7 +23,11 @@ reconnect_interval = 2
# Timeout in seconds before idle sql connections are reaped # Timeout in seconds before idle sql connections are reaped
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_pool_size = 5
# Maximum number of overflow connections in a QueuePool in SQLAlchemy
# Example sqlalchemy_max_overflow = 10
# Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
[META] [META]
## This is list of flavor:quantum_plugins ## This is list of flavor:quantum_plugins

View File

@ -21,7 +21,11 @@ reconnect_interval = 2
# Timeout in seconds before idle sql connections are reaped # Timeout in seconds before idle sql connections are reaped
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_pool_size = 5
# Maximum number of overflow connections in a QueuePool in SQLAlchemy
# Example sqlalchemy_max_overflow = 10
# Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
[MIDONET] [MIDONET]
# MidoNet API server URI # MidoNet API server URI

View File

@ -40,11 +40,12 @@
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Example: sql_idle_timeout = 6000 # Example: sql_idle_timeout = 6000
# (IntOpt) Maximum number of SQL connections to keep open in a # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# QueuePool in SQLAlchemy. # Example sqlalchemy_pool_size = 5
# # Maximum number of overflow connections in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_max_overflow = 10
# Example: sqlalchemy_pool_size = 10 # Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
[ml2] [ml2]
# (ListOpt) List of network type driver entrypoints to be loaded from # (ListOpt) List of network type driver entrypoints to be loaded from

View File

@ -23,7 +23,11 @@ reconnect_interval = 2
# Timeout in seconds before idle sql connections are reaped # Timeout in seconds before idle sql connections are reaped
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_pool_size = 5
# Maximum number of overflow connections in a QueuePool in SQLAlchemy
# Example sqlalchemy_max_overflow = 10
# Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
[OVS] [OVS]
# Do not change this parameter unless you have a good reason to. # Do not change this parameter unless you have a good reason to.

View File

@ -91,8 +91,13 @@ sql_connection = sqlite://
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_pool_size = 5
# Maximum number of overflow connections in a QueuePool in SQLAlchemy
# Example sqlalchemy_max_overflow = 10
# Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
[QUOTAS] [QUOTAS]
# number of network gateways allowed per tenant, -1 means unlimited # number of network gateways allowed per tenant, -1 means unlimited

View File

@ -21,7 +21,11 @@ reconnect_interval = 2
# Timeout in seconds before idle sql connections are reaped # Timeout in seconds before idle sql connections are reaped
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_pool_size = 5
# Maximum number of overflow connections in a QueuePool in SQLAlchemy
# Example sqlalchemy_max_overflow = 10
# Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
[OVS] [OVS]
# (StrOpt) Type of network to allocate for tenant networks. The # (StrOpt) Type of network to allocate for tenant networks. The

View File

@ -23,7 +23,11 @@
# Timeout in seconds before idle sql connections are reaped # Timeout in seconds before idle sql connections are reaped
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_pool_size = 5
# Maximum number of overflow connections in a QueuePool in SQLAlchemy
# Example sqlalchemy_max_overflow = 10
# Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
[PLUMgridNOS] [PLUMgridNOS]
# This line should be pointing to the NOS server, # This line should be pointing to the NOS server,

View File

@ -13,7 +13,11 @@ sql_connection = sqlite://
# Timeout in seconds before idle sql connections are reaped # Timeout in seconds before idle sql connections are reaped
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
# Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy # Maximum number of SQL connections to keep open in a QueuePool in SQLAlchemy
# sqlalchemy_pool_size = 5 # Example sqlalchemy_pool_size = 5
# Maximum number of overflow connections in a QueuePool in SQLAlchemy
# Example sqlalchemy_max_overflow = 10
# Timeout of the open connections QueuePool in SQLAlchemy
# Example sqlalchemy_pool_timeout = 30
[OVS] [OVS]
integration_bridge = br-int integration_bridge = br-int

View File

@ -64,9 +64,17 @@ database_opts = [
default=False, default=False,
help=_("Enable the use of eventlet's db_pool for MySQL")), help=_("Enable the use of eventlet's db_pool for MySQL")),
cfg.IntOpt('sqlalchemy_pool_size', cfg.IntOpt('sqlalchemy_pool_size',
default=5, default=None,
help=_("Maximum number of SQL connections to keep open in a " help=_("Maximum number of SQL connections to keep open in a "
"QueuePool in SQLAlchemy")), "QueuePool in SQLAlchemy")),
cfg.IntOpt('sqlalchemy_max_overflow',
default=None,
help=_("If set, use this value for max_overflow with "
"sqlalchemy")),
cfg.IntOpt('sqlalchemy_pool_timeout',
default=None,
help=_("If set, use this value for pool_timeout with "
"sqlalchemy")),
] ]
cfg.CONF.register_opts(database_opts, "DATABASE") cfg.CONF.register_opts(database_opts, "DATABASE")
@ -124,9 +132,18 @@ def configure_db():
'pool_recycle': 3600, 'pool_recycle': 3600,
'echo': False, 'echo': False,
'convert_unicode': True, 'convert_unicode': True,
'pool_size': cfg.CONF.DATABASE.sqlalchemy_pool_size,
} }
if cfg.CONF.DATABASE.sqlalchemy_pool_size is not None:
pool_size = cfg.CONF.DATABASE.sqlalchemy_pool_size
engine_args['pool_size'] = pool_size
if cfg.CONF.DATABASE.sqlalchemy_max_overflow is not None:
max_overflow = cfg.CONF.DATABASE.sqlalchemy_max_overflow
engine_args['max_overflow'] = max_overflow
if cfg.CONF.DATABASE.sqlalchemy_pool_timeout is not None:
pool_timeout = cfg.CONF.DATABASE.sqlalchemy_pool_timeout
engine_args['pool_timeout'] = pool_timeout
if 'mysql' in connection_dict.drivername: if 'mysql' in connection_dict.drivername:
engine_args['listeners'] = [MySQLPingListener()] engine_args['listeners'] = [MySQLPingListener()]
if (MySQLdb is not None and if (MySQLdb is not None and