pt-online-schema-change blocks on metadata locks
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Fix Released
|
High
|
Daniel Nichter |
Bug Description
# pt-online-
pt-online-
The tool pt-online-
Please see the test cases below, they all involve the following table:
mysql [localhost] {msandbox} (test) > show create table test\G
*******
Table: test
Create Table: CREATE TABLE `test` (
`id` int(10) unsigned NOT NULL,
`x` char(3) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `x` (`x`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
-- Test case for pt-online-
session1 > start transaction;
Query OK, 0 rows affected (0.00 sec)
session1 > select * from test;
+----+------+
| id | x |
+----+------+
| 2 | bar |
| 1 | foo |
+----+------+
2 rows in set (0.00 sec)
# pt-online-
# /usr/bin/perl 5.010001
# Linux ovaistariq-net 2.6.32-
# Arguments: _[--alter]_ _[add column c char(32) default 'dummy_test']_ _[--execute]_ _[h=localhost,
Altering `test`.`test`...
Creating new table...
Created new table test._test_new OK.
Altering new table...
Altered `test`.`_test_new` OK.
Creating triggers... <-- blocks here
session2 > show processlist;
+----+-
| Id | User | Host | db | Command | Time | State | Info |
+----+-
| 20 | msandbox | localhost | test | Sleep | 245 | | NULL |
| 21 | msandbox | localhost | test | Query | 0 | NULL | show processlist |
| 24 | msandbox | localhost | test | Query | 115 | Waiting for table metadata lock | CREATE TRIGGER `pt_osc_
+----+-
3 rows in set (0.00 sec)
-- Test case for pt-online-
session1 > select sleep(3);start transaction;select * from test;
+----------+
| sleep(3) |
+----------+
| 0 |
+----------+
1 row in set (3.00 sec)
Query OK, 0 rows affected (0.00 sec)
+----+------+
| id | x |
+----+------+
| 2 | bar |
| 1 | foo |
+----+------+
2 rows in set (0.00 sec)
[root@ovaistari
Altering `test`.`test`...
Creating new table...
Created new table test._test_new OK.
Altering new table...
Altered `test`.`_test_new` OK.
Creating triggers...
Created triggers OK.
Copying approximately 2 rows...
Copied rows OK.
Swapping tables... <-- blocks here
session1 > show processlist;
+----+-
| Id | User | Host | db | Command | Time | State | Info |
+----+-
| 20 | msandbox | localhost | test | Query | 0 | NULL | show processlist |
| 30 | msandbox | localhost | test | Query | 209 | Waiting for table metadata lock | RENAME TABLE `test`.`test` TO `test`.`_test_old`, `test`.`_test_new` TO `test`.`test` |
| 31 | msandbox | localhost | test | Query | 4 | Waiting for table metadata lock | select * from test |
+----+-
3 rows in set (0.00 sec)
Indefinite metadata locking can be prevented by setting the MySQL session variable lock_wait_timeout to a low value, however in that case pt-osc will simply fail:
# pt-online-
# /usr/bin/perl 5.010001
# Linux ovaistariq-net 2.6.32-
# Arguments: _[--alter]_ _[add column c char(32) default 'dummy_test']_ _[--set-vars]_ _[lock_
Altering `test`.`test`...
Creating new table...
Created new table test._test_new OK.
Altering new table...
Altered `test`.`_test_new` OK.
Creating triggers...
Dropping triggers...
Dropped triggers OK.
Dropping new table...
Dropped new table OK.
`test`.`test` was not altered.
The ideal solution would be to let the user specify lock_wait_timeout via another variable metadata_
I am also wondering if the pt-osc variable --lock-wait-timeout should actually be called innodb-
Please see this blog post for details on MDL:
http://
Related branches
- Daniel Nichter: Approve
-
Diff: 7587 lines (+3695/-1178) (has conflicts)85 files modifiedbin/pt-archiver (+111/-15)
bin/pt-config-diff (+110/-13)
bin/pt-deadlock-logger (+110/-13)
bin/pt-duplicate-key-checker (+110/-13)
bin/pt-find (+110/-13)
bin/pt-fk-error-logger (+110/-13)
bin/pt-heartbeat (+110/-13)
bin/pt-index-usage (+110/-13)
bin/pt-kill (+110/-13)
bin/pt-online-schema-change (+593/-634)
bin/pt-query-advisor (+110/-13)
bin/pt-query-digest (+110/-13)
bin/pt-show-grants (+110/-13)
bin/pt-slave-delay (+110/-13)
bin/pt-slave-find (+110/-13)
bin/pt-slave-restart (+110/-13)
bin/pt-table-checksum (+115/-65)
bin/pt-table-sync (+110/-13)
bin/pt-table-usage (+116/-22)
bin/pt-upgrade (+110/-13)
bin/pt-variable-advisor (+110/-13)
bin/pt-visual-explain (+116/-22)
lib/DSNParser.pm (+54/-8)
lib/NibbleIterator.pm (+2/-2)
lib/OptionParser.pm (+40/-39)
sandbox/set-mysql (+23/-0)
t/lib/Cxn.t (+14/-2)
t/lib/DSNParser.t (+11/-5)
t/lib/KeySize.t (+4/-4)
t/lib/NibbleIterator.t (+3/-3)
t/lib/Percona/XtraDB/Cluster-no-PXC.t (+14/-2)
t/lib/Percona/XtraDB/Cluster.t (+14/-2)
t/lib/ReplicaLagWaiter.t (+14/-2)
t/pt-archiver/check_slave_lag.t (+10/-18)
t/pt-fifo-split/pt-fifo-split.t (+85/-12)
t/pt-online-schema-change/alter_active_table.t (+2/-2)
t/pt-online-schema-change/ansi_quotes.t (+3/-2)
t/pt-online-schema-change/basics.t (+1/-1)
t/pt-online-schema-change/bugs.t (+3/-2)
t/pt-online-schema-change/check_alter.t (+3/-2)
t/pt-online-schema-change/metadata_locks.t (+102/-0)
t/pt-online-schema-change/plugin.t (+83/-0)
t/pt-online-schema-change/privs.t (+3/-2)
t/pt-online-schema-change/pxc.t (+3/-5)
t/pt-online-schema-change/rename_columns.t (+3/-2)
t/pt-online-schema-change/samples/plugins/all_hooks.pm (+99/-0)
t/pt-online-schema-change/samples/plugins/block_create_triggers.pm (+46/-0)
t/pt-online-schema-change/samples/plugins/block_swap_tables.pm (+46/-0)
t/pt-online-schema-change/samples/stats-dry-run.txt (+3/-3)
t/pt-online-schema-change/samples/stats-execute-5.5.txt (+4/-4)
t/pt-online-schema-change/samples/stats-execute.txt (+3/-3)
t/pt-online-schema-change/sanity_checks.t (+1/-1)
t/pt-online-schema-change/skip_innodb.t (+1/-1)
t/pt-table-checksum/basics.t (+3/-3)
t/pt-table-checksum/bugs.t (+2/-2)
t/pt-table-checksum/char_chunking.t (+2/-2)
t/pt-table-checksum/chunk_index.t (+7/-7)
t/pt-table-checksum/chunk_size.t (+2/-2)
t/pt-table-checksum/create_replicate_table.t (+2/-2)
t/pt-table-checksum/error_handling.t (+3/-3)
t/pt-table-checksum/filters.t (+2/-2)
t/pt-table-checksum/float_precision.t (+2/-2)
t/pt-table-checksum/fnv_64.t (+2/-2)
t/pt-table-checksum/ignore_columns.t (+2/-2)
t/pt-table-checksum/issue_388.t (+2/-2)
t/pt-table-checksum/issue_47.t (+2/-2)
t/pt-table-checksum/issue_602.t (+2/-2)
t/pt-table-checksum/option_sanity.t (+5/-5)
t/pt-table-checksum/privs.t (+2/-2)
t/pt-table-checksum/progress.t (+2/-2)
t/pt-table-checksum/pxc.t (+2/-2)
t/pt-table-checksum/replication_filters.t (+6/-2)
t/pt-table-checksum/resume.t (+2/-2)
t/pt-table-checksum/run_time.t (+2/-2)
t/pt-table-checksum/skip_innodb.t (+2/-2)
t/pt-table-checksum/standard_options.t (+2/-2)
t/pt-table-checksum/throttle.t (+2/-2)
t/pt-table-sync/basics.t (+3/-3)
t/pt-table-sync/bugs.t (+2/-2)
t/pt-table-sync/filters.t (+2/-2)
t/pt-table-sync/issue_560.t (+1/-1)
t/pt-table-sync/issue_627.t (+1/-1)
t/pt-table-sync/issue_996.t (+1/-1)
t/pt-table-sync/triggers.t (+2/-2)
util/aspell.en.pws (+3/-0)
- Daniel Nichter: Approve
-
Diff: 4956 lines (+2519/-490)67 files modifiedbin/pt-archiver (+109/-15)
bin/pt-config-diff (+108/-13)
bin/pt-deadlock-logger (+108/-13)
bin/pt-duplicate-key-checker (+108/-13)
bin/pt-find (+108/-13)
bin/pt-fk-error-logger (+108/-13)
bin/pt-heartbeat (+108/-13)
bin/pt-index-usage (+108/-13)
bin/pt-kill (+108/-13)
bin/pt-query-advisor (+108/-13)
bin/pt-query-digest (+108/-13)
bin/pt-show-grants (+108/-13)
bin/pt-slave-delay (+108/-13)
bin/pt-slave-find (+108/-13)
bin/pt-slave-restart (+108/-13)
bin/pt-table-checksum (+110/-62)
bin/pt-table-sync (+108/-13)
bin/pt-table-usage (+114/-22)
bin/pt-upgrade (+108/-13)
bin/pt-variable-advisor (+108/-13)
bin/pt-visual-explain (+114/-22)
lib/DSNParser.pm (+2/-0)
t/lib/Cxn.t (+14/-2)
t/lib/DSNParser.t (+11/-5)
t/lib/KeySize.t (+4/-4)
t/lib/Percona/XtraDB/Cluster-no-PXC.t (+14/-2)
t/lib/Percona/XtraDB/Cluster.t (+14/-2)
t/lib/ReplicaLagWaiter.t (+14/-2)
t/pt-archiver/check_slave_lag.t (+10/-18)
t/pt-fifo-split/pt-fifo-split.t (+73/-36)
t/pt-online-schema-change/ansi_quotes.t (+2/-1)
t/pt-online-schema-change/bugs.t (+2/-1)
t/pt-online-schema-change/check_alter.t (+2/-1)
t/pt-online-schema-change/privs.t (+2/-1)
t/pt-online-schema-change/pxc.t (+0/-2)
t/pt-online-schema-change/rename_columns.t (+2/-1)
t/pt-table-checksum/basics.t (+3/-3)
t/pt-table-checksum/bugs.t (+2/-2)
t/pt-table-checksum/char_chunking.t (+2/-2)
t/pt-table-checksum/chunk_index.t (+7/-7)
t/pt-table-checksum/chunk_size.t (+2/-2)
t/pt-table-checksum/create_replicate_table.t (+2/-2)
t/pt-table-checksum/error_handling.t (+3/-3)
t/pt-table-checksum/filters.t (+2/-2)
t/pt-table-checksum/float_precision.t (+2/-2)
t/pt-table-checksum/fnv_64.t (+2/-2)
t/pt-table-checksum/ignore_columns.t (+2/-2)
t/pt-table-checksum/issue_388.t (+2/-2)
t/pt-table-checksum/issue_47.t (+2/-2)
t/pt-table-checksum/issue_602.t (+2/-2)
t/pt-table-checksum/option_sanity.t (+5/-5)
t/pt-table-checksum/privs.t (+2/-2)
t/pt-table-checksum/progress.t (+2/-2)
t/pt-table-checksum/pxc.t (+2/-2)
t/pt-table-checksum/replication_filters.t (+2/-2)
t/pt-table-checksum/resume.t (+2/-2)
t/pt-table-checksum/run_time.t (+2/-2)
t/pt-table-checksum/skip_innodb.t (+2/-2)
t/pt-table-checksum/standard_options.t (+2/-2)
t/pt-table-checksum/throttle.t (+2/-2)
t/pt-table-sync/basics.t (+3/-3)
t/pt-table-sync/bugs.t (+2/-2)
t/pt-table-sync/filters.t (+2/-2)
t/pt-table-sync/issue_560.t (+1/-1)
t/pt-table-sync/issue_627.t (+1/-1)
t/pt-table-sync/issue_996.t (+1/-1)
t/pt-table-sync/triggers.t (+2/-2)
- Daniel Nichter: Approve
-
Diff: 560 lines (+190/-80)6 files modifiedbin/pt-online-schema-change (+166/-78)
lib/Retry.pm (+2/-0)
t/pt-online-schema-change/metadata_locks.t (+4/-2)
t/pt-online-schema-change/samples/stats-dry-run.txt (+6/-0)
t/pt-online-schema-change/samples/stats-execute-5.5.txt (+6/-0)
t/pt-online-schema-change/samples/stats-execute.txt (+6/-0)
Changed in percona-toolkit: | |
assignee: | nobody → Daniel Nichter (daniel-nichter) |
Changed in percona-toolkit: | |
status: | Triaged → In Progress |
summary: |
- pt-online-schema change blocks indefinitely on metadata locks, rendering - the target table inaccessible + pt-online-schema-change blocks on metadata locks |
tags: | added: mysql-5.6 |
Changed in percona-toolkit: | |
status: | In Progress → Fix Committed |
Changed in percona-toolkit: | |
status: | Fix Committed → Fix Released |
Thanks Ovais. We've been testing on 5.5 and 5.6 for awhile, but not specifically for/against meta-locks. We'll look into this new feature of MySQL more closely.