add new option and behaviour to pt-online-schema-change to detect long running transactions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Long running transactions can make pt-online-
I think it would be a good addition if the script detected long running transactions and aborts unless the user chooses to ignore this.
To implement this, two new options could be added:
--long-
to specify how many seconds a trx needs to be ACTIVE to be considered long running. I'd default it to 60.
--ignore-
to tell the script to go ahead and start its work even if there are long running transactions present.
Able to reproduce this issue that long running transactions can make pt-online- schema- change abort in the final stages of dropping triggers. I have started pt-osc on one session and then run update from another without commit the transaction. Got below output.
nilnandan@ Dell-XPS: ~$ pt-online- schema- change --user=root --password=root --alter "ADD COLUMN phone INT" D=test, t=members_ without_ part --execute foreign_ keys, 10, 1 `members_ without_ part`.. . without_ part_new OK. `_members_ without_ part_new` OK. `pt_osc_ test_members_ without_ part_del` ;"] at /usr/bin/ pt-online- schema- change line 10187.
No slaves found. See --recursion-method if host Dell-XPS has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
Operation, tries, wait:
copy_rows, 10, 0.25
create_triggers, 10, 1
drop_triggers, 10, 1
swap_tables, 10, 1
update_
Altering `test`.
Creating new table...
Created new table test._members_
Altering new table...
Altered `test`.
2014-10-14T13:29:15 Creating triggers...
2014-10-14T13:29:15 Created triggers OK.
2014-10-14T13:29:15 Copying approximately 3281355 rows...
2014-10-14T13:30:03 Dropping triggers...
2014-10-14T13:40:12 Error dropping trigger: 2014-10-14T13:40:12 DBD::mysql::db do failed: Lock wait timeout exceeded; try restarting transaction [for Statement "DROP TRIGGER IF EXISTS `test`.
^C `pt_osc_ test_members_ without_ part_del` ; `pt_osc_ test_members_ without_ part_upd` ; `pt_osc_ test_members_ without_ part_ins` ; `members_ without_ part` was not altered. Dell-XPS: ~$
^C^C# Exiting on SIGINT.
Not dropping triggers because the tool was interrupted. To drop the triggers, execute:
DROP TRIGGER IF EXISTS `test`.
DROP TRIGGER IF EXISTS `test`.
DROP TRIGGER IF EXISTS `test`.
`test`.
nilnandan@
mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)
mysql> update members_ without_ part set fname='nandan' where fname = 'nil';
Query OK, 1097152 rows affected (1 min 4.01 sec)
Rows matched: 1097152 Changed: 1097152 Warnings: 0
mysql>