views:

93

answers:

1

What happens if you kill a long-running alter query? Will the alter query simply revert? How long could that take (as a proportion of the time it has already been running)?

What if that query is being replicated onto another server? Will killing the process on the other server revert the original server's alter query?

We're running mysql

+1  A: 

It depends what you're doing. If you're running an alter table...add index command on an InnoDB table (not so sure about MyISAM), then it will just run and run as it copies the whole darn table lock-stock-and-barrel first: if it's in the middle of "copy to temp table" then it's pretty much unstoppable.

See here:

In most cases, ALTER TABLE works by making a temporary copy of the original table. The alteration is performed on the copy, and then the original table is deleted and the new one is renamed. While ALTER TABLE is executing, the original table is readable by other sessions. Updates and writes to the table are stalled until the new table is ready, and then are automatically redirected to the new table without any failed updates.

davek
It looks like our case was one where "no temporary table is necessary" - but it looks like our tables still locked up, our open connections spiked, and we had a 5 to 10 minute outage. If we kill a query that does *not* create a copy... then what?
B T