zoukankan      html  css  js  c++  java
  • 数据库死锁解决办法

    1.之前遇到过一个场景:有一个用户登录一直失败,但是其他用户却可以正常登录,后来测试借口发现在登录时更新这个用户的登录时间时,一直没有反应然后超时了。因为innordb是行级锁的所以就想到了是这条用户的信息被锁住了。

    2.解决方案:

    执行语句:SELECT * FROM information_schema.INNODB_TRXG ;

    *************************** 1. row ***************************
    trx_id: 189324
    trx_state: RUNNING
    trx_started: 2013-04-18 17:48:14
    trx_requested_lock_id: NULL
    trx_wait_started: NULL
    trx_weight: 3
    trx_mysql_thread_id: 16
    trx_query: NULL
    trx_operation_state: NULL
    trx_tables_in_use: 0
    trx_tables_locked: 0
    trx_lock_structs: 2
    trx_lock_memory_bytes: 376
    trx_rows_locked: 3
    trx_rows_modified: 1
    trx_concurrency_tickets: 0
    trx_isolation_level: REPEATABLE READ
    trx_unique_checks: 1
    trx_foreign_key_checks: 1
    trx_last_foreign_key_error: NULL
    trx_adaptive_hash_latched: 0
    trx_adaptive_hash_timeout: 10000
    trx_is_read_only: 0
    trx_autocommit_non_locking: 0

    这个语句是查询innordb的事务信息的数据,一般trx_started这个时间到现在时间很长的话,说明这个事务已经锁死了,trx_rows_locked代表的是有多少行被锁定了。trx_tables_locked表示多少表被锁定了。所以可以根据这个信息去找到trx_mysql_thread_id的值然后使用kill 线程id 杀掉对应的线程就可以解开锁定了

  • 相关阅读:
    根据excel表格中的某一列内容,使用python将其拆分成多个excel表格
    Python操作excel
    opensips(三):load_balancer与NAT
    opensips(二):NAT官方脚本
    sip头域
    OPensips(一):NAT例子
    四、word2vec + siameseLSTM改进(1)
    三、word2vec + siameseLSTM
    二、LSTM处理不定长句子
    一、word2vec的使用
  • 原文地址:https://www.cnblogs.com/wzk1992/p/5735459.html
Copyright © 2011-2022 走看看