change pt-online-schema-change to warn on empty alter table
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
This is a feature request and not a bug report.
I had pt-osc abort due to load on a server earlier this week, so I used --critical-load to work around that.
However, I had a command line invocation like this one:
pt-online-
DSN \
--execute \
--no-drop-
--alter 'SQL'
And after the change I ran this:
pt-online-
DSN \
--execute \
--no-drop-
--critical-
--alter 'SQL'
Note that I forgot to add '\' before the newline in the --critical--load line, so the tool ran an empty alter, rebuilding the table.
I think it would be friendlier if the tool warned on that, perhaps requiring some other arg like --empty-alter if --alter is not present.
I think the problem is that --alter seems to take the default of a noop alter table, and this is not explicit in the docs. Further, this example:
Change sakila.actor to InnoDB, effectively performing OPTIMIZE TABLE in a non-blocking fashion because it is already an InnoDB table:
pt-online- schema- change --alter "ENGINE=InnoDB" D=sakila,t=actor
Makes me think that there is no implicit value for --alter, if I have to include that for a noop/optimize table one.
The minimal test case I found is by using --execute and the DSN alone, and checking the timestamp on the frm file I can confirm it is altered:
telecaster:tmp fernandoipar$ ls -lah /usr/local/ var/mysql/ test/pt_ osc_test. frm var/mysql/ test/pt_ osc_test. frm
-rw-rw---- 1 fernandoipar admin 8.4K Mar 9 13:06 /usr/local/
telecaster:tmp fernandoipar$ ./pt-online- schema- change D=test, t=pt_osc_ test foreign_ keys, 10, 1 `pt_osc_ test` because neither --dry-run nor --execute was specified. Please read the tool's documentation carefully before using this tool. schema- change --execute D=test, t=pt_osc_ test foreign_ keys, 10, 1 `pt_osc_ test`.. . osc_test_ new OK. `_pt_osc_ test_old` OK. `pt_osc_ test`.
Operation, tries, wait:
copy_rows, 10, 0.25
create_triggers, 10, 1
drop_triggers, 10, 1
swap_tables, 10, 1
update_
Exiting without altering `test`.
telecaster:tmp fernandoipar$ ./pt-online-
No slaves found. See --recursion-method if host telecaster 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._pt_
2015-03-09T13:11:14 Creating triggers...
2015-03-09T13:11:14 Created triggers OK.
2015-03-09T13:11:14 Copying approximately 1 rows...
2015-03-09T13:11:14 Copied rows OK.
2015-03-09T13:11:14 Swapping tables...
2015-03-09T13:11:14 Swapped original and new tables OK.
2015-03-09T13:11:14 Dropping old table...
2015-03-09T13:11:14 Dropped old table `test`.
2015-03-09T13:11:14 Dropping triggers...
2015-03-09T13:11:14 Dropped triggers OK.
Successfully altered `test`.
telecaster:tmp fernandoipar$ ls -lah /usr/local/ var/mysql/ test/pt_ osc_test. frm var/mysql/ test/pt_ osc_test. frm
-rw-rw---- 1 fernandoipar admin 8.4K Mar 9 13:11 /usr/local/
So I think my feature request is to either:
- make the tool print a warning if no --alter is provided, printing the actual ALTER TABLE command that will be run on the new table, or
- improve the documentation to make it explicit that --alter has a defaut value, and adjust the 'optimize table' example accordingly.