Skip to content

Commit

Permalink
Merge "Removed db_pool complexities from nova.db.sqlalchemy.session. …
Browse files Browse the repository at this point in the history
…Fixes bug 838581."
  • Loading branch information
Jenkins authored and openstack-gerrit committed Sep 27, 2011
2 parents d2ac401 + f3dd56e commit d6b460e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 39 deletions.
34 changes: 1 addition & 33 deletions nova/db/sqlalchemy/session.py
Expand Up @@ -15,30 +15,16 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Session Handling for SQLAlchemy backend
"""

import eventlet.patcher
eventlet.patcher.monkey_patch()
"""Session Handling for SQLAlchemy backend."""

import eventlet.db_pool
import sqlalchemy.orm
import sqlalchemy.pool

import nova.exception
import nova.flags
import nova.log


FLAGS = nova.flags.FLAGS
LOG = nova.log.getLogger("nova.db.sqlalchemy")


try:
import MySQLdb
except ImportError:
MySQLdb = None


_ENGINE = None
Expand Down Expand Up @@ -71,24 +57,6 @@ def get_engine():
if "sqlite" in connection_dict.drivername:
engine_args["poolclass"] = sqlalchemy.pool.NullPool

elif MySQLdb and "mysql" in connection_dict.drivername:
LOG.info(_("Using mysql/eventlet db_pool."))
# MySQLdb won't accept 'None' in the password field
password = connection_dict.password or ''
pool_args = {
"db": connection_dict.database,
"passwd": password,
"host": connection_dict.host,
"user": connection_dict.username,
"min_size": FLAGS.sql_min_pool_size,
"max_size": FLAGS.sql_max_pool_size,
"max_idle": FLAGS.sql_idle_timeout,
}
creator = eventlet.db_pool.ConnectionPool(MySQLdb, **pool_args)
engine_args["pool_size"] = FLAGS.sql_max_pool_size
engine_args["pool_timeout"] = FLAGS.sql_pool_timeout
engine_args["creator"] = creator.create

return sqlalchemy.create_engine(FLAGS.sql_connection, **engine_args)


Expand Down
6 changes: 0 additions & 6 deletions nova/flags.py
Expand Up @@ -353,12 +353,6 @@ def _get_my_ip():
'directory')
DEFINE_integer('logfile_mode', 0644, 'Default file mode of the logs.')
DEFINE_string('sqlite_db', 'nova.sqlite', 'file name for sqlite')
DEFINE_integer('sql_pool_timeout', 30,
'seconds to wait for connection from pool before erroring')
DEFINE_integer('sql_min_pool_size', 10,
'minimum number of SQL connections to pool')
DEFINE_integer('sql_max_pool_size', 10,
'maximum number of SQL connections to pool')
DEFINE_string('sql_connection',
'sqlite:///$state_path/$sqlite_db',
'connection string for sql database')
Expand Down

0 comments on commit d6b460e

Please sign in to comment.