# Pt-online-schema-change does not execute before\_exit plugin if alter table fails

**URL:** <https://forums.percona.com/t/pt-online-schema-change-does-not-execute-before-exit-plugin-if-alter-table-fails/9721>\
**Category:** Percona Toolkit\
**Tags:** community, mysql, closed-no-reply\
**Created:** [March 19, 2021, 5:25pm UTC](https://forums.percona.com/t/pt-online-schema-change-does-not-execute-before-exit-plugin-if-alter-table-fails/9721 "2021-03-19T17:25:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![i.migliozzi](https://avatars.discourse-cdn.com/v4/letter/i/858c86/32.png) [@i.migliozzi](https://forums.percona.com/u/i.migliozzi)\
**Post date:** [March 19, 2021, 5:25pm UTC](https://forums.percona.com/t/pt-online-schema-change-does-not-execute-before-exit-plugin-if-alter-table-fails/9721/1 "2021-03-19T17:25:32Z")

</div>

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?
