该脚本自动查找达梦的锁死,并自动杀死。
import dmPython
conn=dmPython.connect(user='SYSDBA',password='SYSDBA',server='localhost', port=5236)
cursor=conn.cursor()
result=cursor.execute("select concat('sp_close_session(',s.sess_id,');') from v$sessions s, v$trxwait t where s.trx_id = t.wait_for_id and s.state='IDLE' and s.sql_text like 'select count(docresourc0_.id) as col_0_0_ from doc_resources docresourc0_%' order by s.sess_id");
result=cursor.fetchall()
if result == []:
print ('ok')
else:
print (result[0][0])
print ('error')
cursor.execute(result[0][0]).fetchall()
cursor.close()
conn.close()
推荐python3运行该脚本。