pt-online-schema-change, MySQL 5.6, and InnoDB optimizer stats can cause downtime
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Fix Released
|
High
|
Frank Cizmich |
Bug Description
In 5.6 there is a bug (or bad design) about when the statistics are calculated with persistent innodb_
"In PS 5.6 with innodb_
So, on a very loaded server that could cause that several hundred of queries that run without problems (under ms of execution time) switches to full table scan for some time, causing million of row scans and most probably a server down problem. It is clear that Oracle doesn't want to investigate/fix it, both reports are marked as "not bug":
http://
https:/
so we need a workaround so pt-osc doesn't cause server down problems. And it seems to be easy. We just need to run analyze on the new table just before the rename. Consider this a proof of concept, not a patch :)
# diff /usr/bin/
9950d9949
<
9965d9963
<
9974,9975d9971
< my $sqlanalyze = "ANALYZE TABLE $new_tbl->{name}";
< $cxn->dbh(
So, we run analyze on the new table and then we rename it as usual.
PTDEBUG && _d($sql);
After that small change, the statistics are correct after rename and queries continue to use the correct execution plan.
The patch should be something like:
- we check if this is 5.6 with innodb_
-> NO, we do nothing.
-> YES, we analyze before rename.
There is a test case that can be used to check if the patch works here:
Changed in percona-toolkit: | |
status: | New → Confirmed |
tags: | added: i58783 |
Changed in percona-toolkit: | |
assignee: | nobody → Frank Cizmich (frank-cizmich) |
Changed in percona-toolkit: | |
status: | Confirmed → In Progress |
milestone: | none → 2.3.1 |
importance: | Undecided → High |
tags: | added: pt-online-schema-change |
summary: |
- pt-online-schema-change needs a workaround for a bug on 5.6 + pt-online-schema-change, MySQL 5.6, and InnoDB optimizer stats can cause + downtime |
Changed in percona-toolkit: | |
milestone: | 2.3.1 → 2.2.16 |
Changed in percona-toolkit: | |
status: | Fix Committed → Fix Released |
I have heard what was proposed to implement the change, I would like to request that by default the pt-osc tool will leave the environment the same as much as possible. To this end, I propose:
if -analyze- before- rename is NOT specified and the old table has stats
then analyze the new table
else
then do what as specified
end if
Please second my proposal.