• 数据库死锁


    SELECT * FROM information_schema.INNODB_TRX;

    最近在维护数据库时,解析数据时候,数据一直不能入库。原因知道,是因为MySQL的事务产生了死锁,前几次我直接重启MySQL。
      www.2cto.com  
    最近发现频繁的出现。所以找到一种方法。
    SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX;  
     
    trx_id trx_state trx_started trx_requested_lock_id trx_wait_started trx_weight trx_mysql_thread_id trx_query trx_operation_state trx_tables_in_use trx_tables_locked trx_lock_structs trx_lock_memory_bytes trx_rows_locked trx_rows_modified trx_concurrency_tickets trx_isolation_level trx_unique_checks trx_foreign_key_checks trx_last_foreign_key_error trx_adaptive_hash_latched trx_adaptive_hash_timeouttrx_id trx_state trx_started trx_requested_lock_id trx_wait_started trx_weight trx_mysql_thread_id trx_query trx_operation_state trx_tables_in_use trx_tables_locked trx_lock_structs trx_lock_memory_bytes trx_rows_locked trx_rows_modified trx_concurrency_tickets trx_isolation_level trx_unique_checks trx_foreign_key_checks trx_last_foreign_key_error trx_adaptive_hash_latched trx_adaptive_hash_timeout
      www.2cto.com  
    查看事件比较久的事物。如何当前时间select sysdate();AM 10:07而事物开始的时间是:AM 9:50,显示是不正常的。根据这个事物的线程ID(trx_mysql_thread_id)。
    执行命令:
    kill 线程ID  
    数据库修复正常。
     
    查看正在锁的事务
    SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS;  
     
    查看等待锁的事务
    SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS; 
  • 相关阅读:
    通过HTTP请求Websocket
    理解C#中的“静态”
    C#垃圾回收机制详解
    详说C#中的结构struct
    readonly和const区别
    深入理解C#中this/partial/null的使用
    面向对象的几个基本概念的理解
    C#中out和ref使用
    C#中params使用
    值类型引用类型详解
  • 原文地址:https://www.cnblogs.com/root429/p/9251343.html
Copyright © 2020-2023  润新知