zoukankan      html  css  js  c++  java
  • 查询MySQL锁等待的语句

    select
     'Blocker' role,
        p.id,
        p.user,
        left(p.host, locate(':', p.host) - 1) host,
        tx.trx_id,
        tx.trx_state,
        tx.trx_started,
     timestampdiff(second, tx.trx_started, now()) duration,
     lo.lock_mode,
     lo.lock_type,
     lo.lock_table,
     lo.lock_index,
        tx.trx_query,
        tx.trx_tables_in_use,
        tx.trx_tables_locked,
        tx.trx_rows_locked
    from
        information_schema.innodb_trx tx,
        information_schema.innodb_lock_waits lw,
     information_schema.innodb_locks lo,
        information_schema.processlist p
    where
        lw.blocking_trx_id = tx.trx_id
     and p.id = tx.trx_mysql_thread_id
     and lo.lock_trx_id = tx.trx_id
    union all
    select
        'Blockee' role,
        p.id,
        p.user,
        left(p.host, locate(':', p.host) - 1) host,
        tx.trx_id,
        tx.trx_state,
        tx.trx_started,
     timestampdiff(second, tx.trx_started, now()) duration,
     lo.lock_mode,
     lo.lock_type,
     lo.lock_table,
     lo.lock_index,
        tx.trx_query,
        tx.trx_tables_in_use,
        tx.trx_tables_locked,
        tx.trx_rows_locked
    from
        information_schema.innodb_trx tx,
        information_schema.innodb_lock_waits lw,
     information_schema.innodb_locks lo,
        information_schema.processlist p
    where
        lw.requesting_trx_id = tx.trx_id
     and p.id = tx.trx_mysql_thread_id
     and lo.lock_trx_id = tx.trx_id G

  • 相关阅读:
    docker tcp配置
    PostgreSQL 数据库备份
    docker 几种磁盘卷挂载方式的区别
    MAT
    OkHttp
    HashMap 在 Java1.7 与 1.8 中的区别
    【zabbix】zabbix 高可用架构的实现
    利用zabbix监控Vmware运行
    logback在SpringBoot下出现no applicable action for [appender], current ElementPath is
    NGUI:HUD Text(头顶伤害漂浮文字)
  • 原文地址:https://www.cnblogs.com/yuyue2014/p/4581604.html
Copyright © 2011-2022 走看看