django事务导致的死锁

这几个试着执行下就好了

SHOW FULL PROCESSLIST;

SELECT * FROM information_schema.INNODB_TRX
where trx_mysql_thread_id in ();

kill 111;

简化
SELECT p.ID FROM information_schema.INNODB_TRX
left join information_schema.processlist as p on p.ID = trx_mysql_thread_id
where  p.command != 'Sleep' and p.time > 2*60;

kill p.ID;


其他
select * from information_schema.innodb_trx;

show full processlist;

kill 1123;

django直接删除死锁
        from django.db import connection
        with connection.cursor() as cur:
            cur.execute('SELECT trx_mysql_thread_id from information_schema.INNODB_TRX  where trx_state != "RUNNING";')
            rs = cur.fetchall()
            if len(rs) > 0:
                for item in rs:
                    cur.execute('kill %s' % item[0])

你可能感兴趣的:(django,django,mysql,数据库)