diff --git a/plugins/data_query/sql_mysql.py b/plugins/data_query/sql_mysql.py index d96ce5f75..e1d4007be 100755 --- a/plugins/data_query/sql_mysql.py +++ b/plugins/data_query/sql_mysql.py @@ -546,10 +546,33 @@ class nosqlMySQLCtr(): a.trx_started """ ) - - print(data) return mw.returnData(True, 'ok', data) + def killLockPid(self, args): + sid = args['sid'] + my_instance = self.getInstanceBySid(sid).conn() + if my_instance is False: + return mw.returnData(False,'无法链接') + + pid = args['pid'] + my_instance.execute('kill %s' % pid) + return mw.returnData(True, '执行成功!') + + def killAllLock(self, args): + sid = args['sid'] + my_instance = self.getInstanceBySid(sid).conn() + if my_instance is False: + return mw.returnData(False,'无法链接') + + data = self.getLockSql(args) + if data['status']: + pid_data = data['data'] + for x in pid_data: + my_instance.execute('kill %s' % x['processlist_id']) + return mw.returnData(True, '执行成功!') + + + def getDeadlockInfo(self, args): sid = args['sid'] my_instance = self.getInstanceBySid(sid).conn() @@ -589,9 +612,7 @@ class nosqlMySQLCtr(): else: msg = '主从复制报错,请检查\nSlave_IO_Running状态值是:%s, | Slave_SQL_Running状态值是:%s\nLast_Error错误信息是:%s\nLast_SQL_Error错误信息是:%s\n' \ % (slave_info['Slave_IO_Running'], slave_info['Slave_SQL_Running'], slave_info['Last_Error'], slave_info['Last_SQL_Error']) - error_dict = my_instance.find('select LAST_ERROR_NUMBER,LAST_ERROR_MESSAGE,LAST_ERROR_TIMESTAMP ' - 'from performance_schema.replication_applier_status_by_worker ' - 'ORDER BY LAST_ERROR_TIMESTAMP desc limit 1') + error_dict = my_instance.find('select LAST_ERROR_NUMBER,LAST_ERROR_MESSAGE,LAST_ERROR_TIMESTAMP from performance_schema.replication_applier_status_by_worker ORDER BY LAST_ERROR_TIMESTAMP desc limit 1') msg += '错误号是:%s \n' % error_dict['LAST_ERROR_NUMBER'] msg += '错误信息是:%s \n' % error_dict['LAST_ERROR_MESSAGE'] msg += '报错时间是:%s \n' % error_dict['LAST_ERROR_TIMESTAMP'] @@ -665,6 +686,16 @@ def get_lock_sql(args): t = nosqlMySQLCtr() return t.getLockSql(args) +# KILL阻塞SQL +def kill_lock_pid(args): + t = nosqlMySQLCtr() + return t.killLockPid(args) + +# KILL阻塞SQL +def kill_all_lock(args): + t = nosqlMySQLCtr() + return t.killAllLock(args) + # 查看死锁信息 def get_deadlock_info(args): t = nosqlMySQLCtr() @@ -676,6 +707,10 @@ def get_slave_status(args): return t.getSlaveStatus(args) + + + + # 测试 def test(args): sid = args['sid'] diff --git a/plugins/data_query/static/js/app.js b/plugins/data_query/static/js/app.js index b630235ee..d46aa31c0 100755 --- a/plugins/data_query/static/js/app.js +++ b/plugins/data_query/static/js/app.js @@ -666,12 +666,35 @@ function mysqlCommonFuncLockSQL(){ var tbody = ''; for (var i = 0; i < items.length; i++) { var t = '
库名 | \ -表名 | \ +事务ID | \ +事务状态 | \ +执行时间 | \ +线程ID | \ +Info | \ +user | \ +host | \ +db | \ +command | \ +state | \ +kill | \ +操作 | \ \ \
---|