- 论坛徽章:
- 1
|
官方说法是5.6实现了ddl online,以前只测过alter addcolumn,确实没加锁(没有默认值)...
今天在做另一个测试时,遇到alter change 就加锁了...我去...测试如下:
对一个大表进行alter change,更改字段长度(增加大小),在进行alter的同时,可以select的,但不能update和insert,delete.
mysql> select * from innodb_trx\G
*************************** 1. row ***************************
trx_id: 21191
trx_state: RUNNING
trx_started: 2015-05-12 10:41:38
trx_requested_lock_id: NULL
trx_wait_started: NULL
trx_weight: 5929
trx_mysql_thread_id: 28
trx_query: alter table request_info_his change column trade_no trade_no varchar(101)
trx_operation_state: NULL
trx_tables_in_use: 2
trx_tables_locked: 2
trx_lock_structs: 37
trx_lock_memory_bytes: 6544
trx_rows_locked: 5892
trx_rows_modified: 5892
trx_concurrency_tickets: 3219
trx_isolation_level: READ COMMITTED
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
1 row in set (0.00 sec)
mysql> show processlist;
+----+------+-----------+--------------------+---------+------+---------------------------------+---------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+--------------------+---------+------+---------------------------------+---------------------------------------------------------------------------+
| 27 | root | localhost | test | Query | 87 | Waiting for table metadata lock | update request_info_his set charset ='21' where id = 51793683 |
| 28 | root | localhost | test | Query | 391 | copy to tmp table | alter table request_info_his change column trade_no trade_no varchar(101) |
| 29 | root | localhost | information_schema | Query | 0 | init | show processlist |
+----+------+-----------+--------------------+---------+------+---------------------------------+---------------------------------------------------------------------------+
3 rows in set (0.00 sec)
出现了Waiting for table metadata lock,这种就属于一个等待另一个事物结束的状态了吧?
那ddl online就只是说alter add column,其他的ddl还是会锁表??? 可以这么理解吧???
哪位大牛研究过??? 能解惑一二么?
|
|