如果遇到死鎖了
我們來演示下
線程A
mysql> set @@autocommit=
Query OK
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with
Database changed
mysql> show tables;
+
| Tables_in_test |
+
| demo_test |
| t
+
mysql> select * from t
+
| id | fname | lname | birthday | c
+
|
|
+
mysql> update t
Query OK
Rows matched:
mysql> select connection_id()
+
| connection_id() |
+
|
+
mysql>
線程B
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with
Database changed
mysql> select @@autocommit;
+
| @@autocommit |
+
|
+
mysql> update t
ERROR
mysql> select connection_id()
+
| connection_id() |
+
|
+
mysql> show processlist;
+
| Id | User | Host | db | Command | Time | State | Info |
+
|
|
|
|
|
+
mysql> show engine innodb status\G
TRANSACTIONS
Trx id counter
Purge done for trx
History list length
LIST OF TRANSACTIONS FOR EACH SESSION:
MySQL thread id
show engine innodb status
mysql tables in use
LOCK WAIT
MySQL thread id
update t
RECORD LOCKS space id
Record lock
MySQL thread id
Trx read view will not see trx with id >=
上面的信息很繁多
不過現在
mysql> SELECT * FROM information_schema
***************************
trx_id:
trx_state: RUNNING
trx_started:
trx_requested_lock_id: NULL
trx_wait_started: NULL
trx_weight:
trx_mysql_thread_id:
trx_query: NULL
trx_operation_state: NULL
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: REPEATABLE READ
trx_unique_checks:
trx_foreign_key_checks:
trx_last_foreign_key_error: NULL
trx_adaptive_hash_latched:
trx_adaptive_hash_timeout:
trx_is_read_only:
trx_autocommit_non_locking:
mysql>
From:http://tw.wingwit.com/Article/program/MySQL/201311/29500.html