diff --git a/sql/db_diagnostic.py b/sql/db_diagnostic.py index d58c2b68f9..4045ab5008 100644 --- a/sql/db_diagnostic.py +++ b/sql/db_diagnostic.py @@ -263,6 +263,35 @@ def innodb_trx(request): ifnull(p.info, '') info from information_schema.INNODB_TRX trx join information_schema.processlist p on trx.trx_mysql_thread_id = p.id;''' + + sql = '''select trx.trx_started, + trx.trx_state, + trx.trx_operation_state, + trx.trx_mysql_thread_id, + trx.trx_tables_locked, + trx.trx_rows_locked, + trx.trx_rows_modified, + trx.trx_is_read_only, + trx.trx_isolation_level, + p.user, + p.host, + p.db, + TO_SECONDS(NOW()) - TO_SECONDS(trx.trx_started) trx_idle_time, + p.time thread_time, + IFNULL((SELECT + GROUP_CONCAT(t1.sql_text SEPARATOR '; + ') + FROM performance_schema.events_statements_history t1 + INNER JOIN performance_schema.threads t2 + ON t1.thread_id = t2.thread_id + WHERE t2.PROCESSLIST_ID = p.id), '') info +FROM information_schema.INNODB_TRX trx + INNER JOIN information_schema.PROCESSLIST p + ON trx.trx_mysql_thread_id = p.id + WHERE trx.trx_state = 'RUNNING' + AND p.COMMAND = 'Sleep' + AND P.TIME > 3 + ORDER BY trx.trx_started ASC;''' query_result = query_engine.query('information_schema', sql) if not query_result.error: