From 6432997f672f5b20b3d5b6b961fc3b9bf1117022 Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Mon, 26 Mar 2012 09:32:43 -0700 Subject: Support sql_connection_debug to get SQL diagnostic information 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 --- nova/db/sqlalchemy/session.py | 6 ++++++ nova/flags.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/nova/db/sqlalchemy/session.py b/nova/db/sqlalchemy/session.py index fe1b44c41..eeadd9611 100644 --- a/nova/db/sqlalchemy/session.py +++ b/nova/db/sqlalchemy/session.py @@ -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 diff --git a/nova/flags.py b/nova/flags.py index fb73182cf..430abe67e 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -99,6 +99,10 @@ core_opts = [ 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'), -- cgit