Skip to content

Commit

Permalink
Support sql_connection_debug to get SQL diagnostic information
Browse files Browse the repository at this point in the history
We've had a few reports of SQL issues; it'll be very helpful to be able to get SQL information
into our log.

Bug #964844

Change-Id: I9d08991a3677bc6cbed45a930ede9271d685cac1
  • Loading branch information
justinsb committed Mar 26, 2012
1 parent 129150c commit 6432997
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nova/db/sqlalchemy/session.py
Expand Up @@ -93,6 +93,12 @@ def get_engine():
'convert_unicode': True,
}

# Map our SQL debug level to SQLAlchemy's options
if FLAGS.sql_connection_debug >= 100:
engine_args['echo'] = 'debug'
elif FLAGS.sql_connection_debug >= 50:
engine_args['echo'] = True

if "sqlite" in connection_dict.drivername:
engine_args["poolclass"] = NullPool

Expand Down
4 changes: 4 additions & 0 deletions nova/flags.py
Expand Up @@ -99,6 +99,10 @@ def _get_my_ip():
default='sqlite:///$state_path/$sqlite_db',
help='The SQLAlchemy connection string used to connect to the '
'database'),
cfg.IntOpt('sql_connection_debug',
default=0,
help='Verbosity of SQL debugging information. 0=None, '
'100=Everything'),
cfg.StrOpt('api_paste_config',
default="api-paste.ini",
help='File name for the paste.deploy config for nova-api'),
Expand Down

0 comments on commit 6432997

Please sign in to comment.