Skip to content

Commit

Permalink
Removed db_pool complexities from nova.db.sqlalchemy.session. Fixes b…
Browse files Browse the repository at this point in the history
…ug 838581.

(cherry picked from commit f3dd56e)

Change-Id: I96442f9c9eeddc48ce8307da93ff289e3d679553
  • Loading branch information
Brian Lamar authored and markmc committed Oct 18, 2011
1 parent 2754749 commit 1a5e3e0
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 @@ -351,12 +351,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 1a5e3e0

Please sign in to comment.