Pt-online-schema-change does not execute before_exit plugin if alter table fails

I am using the --plugin option to perform operations based on the progress of pt-online-schema-change operations.

Example:
hook init> set A.field = 1
hook after_swap_tables > I set B.field = ‘ok’.
hook before_exit > set A.field=0

I have noticed that if pt-online-schema-change fails (SQL error such as: added already existing field) it does not execute subsequent hooks, not even the before_exit one.
Is there any way to catch exceptions and have pt-online-schema-change perform actions before terminating?

1 Like