MySQL中InnoDB锁不住表的原因

时间:2023-01-17 15:28:44

MySQL中InnoDB锁不住表是因为如下两个参数的设置:

mysql> show variables like '%timeout%';

+-----------------------------+----------+

| Variable_name               | Value    |

+-----------------------------+----------+

| connect_timeout             | 10       |

| delayed_insert_timeout      | 300      |

| innodb_flush_log_at_timeout | 1        |

| innodb_lock_wait_timeout    | 50       |

| innodb_rollback_on_timeout  | OFF      |

| interactive_timeout         | 1800     |  #默认是1800

| lock_wait_timeout           | 31536000 |

| net_read_timeout            | 30       |

| net_write_timeout           | 60       |

| rpl_stop_slave_timeout      | 31536000 |

| slave_net_timeout           | 3600     |

| wait_timeout                | 1800     |  #默认是1800

+-----------------------------+----------+

mysql> set  wait_timeout=60;  #修改参数

mysql> set interactive_timeout=60;

mysql> show variables like 'wait_timeout';

+--------------------------+----------+

| Variable_name            | Value    |

+--------------------------+----------+

| wait_timeout             | 60       |

+--------------------------+----------+

mysql> show variables like '%interactive_timeout%';

+---------------------+-------+

| Variable_name       | Value |

+---------------------+-------+

| interactive_timeout | 60    |

+---------------------+-------+

mysql> flush tables with read lock;  #锁表

mysql> unlock tables;  #解锁