Make pt-osc compatible with AFTER triggers

Bug #1491133 reported by Sveta Smirnova
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
Wishlist
Carlos Salguero

Bug Description

Currently pt-online-schema-change cannot run if table already has AFTER triggers. But it can, if add an option which instruct the tool to do following (see pseudo-code):

The workflow to add triggers would be as follows (from our own experiences doing this with trigger-based tools):
- lock the table in question (standard mysql lock tables write)
- pull the existing trigger code, call that block 1
- log trigger code into temporary file to avoid trigger definition loss in case of pt-osc failure
- generate the trigger code for pt-osc, call that block 2
- drop the existing trigger
- create a new trigger with block 1 and block 2 appended, wrap them in /* BLOCK 1 START */ comments or similar if that makes it easier to parse out
- repeat for other events (cover all of ins,upd,del)
- unlock table
To remove triggers, the reverse:
- lock the table with write lock
- pull the trigger code and parse out block 1
- drop the trigger
- create the trigger with only code from block 1
- repeat for other event
- unlock table

Do not make this option default and add a warning about database can be in inconsistent state if the tool or MySQL Server is killed during execution.

Changed in percona-toolkit:
status: New → Confirmed
no longer affects: percona-server
Changed in percona-toolkit:
importance: Undecided → Wishlist
tags: added: pt-online-schema-change
Revision history for this message
Frank Cizmich (frank-cizmich) wrote :

Current behavior is not to work with tables which have any kind of trigger, so this is a bit of a leap.
Many possibilities for things to go wrong, IMHO.
Will continue to analyze feasibility and perhaps prepare an experimental version.

Revision history for this message
Sveta Smirnova (svetasmirnova) wrote :

Maybe implement this feature for 5.7 and up only? It has AFTER and BEFORE triggers, so no need to remove any trigger now. Just:

- Check if version is 5.7 or up
- Create a trigger which is AFTER the last trigger, attached to the table

tags: added: pt91
Changed in percona-toolkit:
status: Confirmed → In Progress
assignee: nobody → Carlos Salguero (carlos-salguero)
milestone: none → 3.0.2
Changed in percona-toolkit:
milestone: 3.0.2 → none
Revision history for this message
Sveta Smirnova (svetasmirnova) wrote :

This is resolved. Status tracked in https://jira.percona.com/browse/PT-91

Changed in percona-toolkit:
status: In Progress → Fix Released
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-863

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.