# can pt-online-schema-change pause after copy but before table rename

**URL:** <https://forums.percona.com/t/can-pt-online-schema-change-pause-after-copy-but-before-table-rename/6710>\
**Category:** Percona Toolkit\
**Created:** [November 28, 2018, 10:54am UTC](https://forums.percona.com/t/can-pt-online-schema-change-pause-after-copy-but-before-table-rename/6710 "2018-11-28T10:54:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwbrumett](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@cwbrumett](https://forums.percona.com/u/cwbrumett)\
**Post date:** [November 28, 2018, 10:54am UTC](https://forums.percona.com/t/can-pt-online-schema-change-pause-after-copy-but-before-table-rename/6710/1 "2018-11-28T10:54:56Z")

</div>

We have a scenario where pt-online-schema-change is causing issues with our downstream ETL tool (Attunity) happening when the new table gets renamed to the old.

Is it possible to have pt-online-schema-change copy all the data (including all incoming changes) into the new altered table and then pause (and still process incoming records into both the original and the new table). That would allow us to stop our always-on ETL tool. Then manually trigger pt-online-schema-change to do the table rename (without losing any records after the pause).

Here’s the command we are currently using for pt-online-schema-change if it provides insight.

pt-online-schema-change   
–nocheck-replication-filters   
–recursion-method=“dsn=D=dba,t=dsn”   
–max-load Threads\_running=150   
–critical-load Threads\_running=300   
–execute   
–alter “DROP FOREIGN KEY \_\_fk\_tradeline\_comp\_client\_id,   
DROP FOREIGN KEY \_\_fk\_tradeline\_comp\_eq\_id,   
DROP FOREIGN KEY \_\_fk\_tradeline\_comp\_ex\_id,   
DROP FOREIGN KEY \_\_fk\_tradeline\_comp\_tu\_id,   
MODIFY tu\_reportitemserialid BIGINT UNSIGNED DEFAULT NULL,   
MODIFY eq\_reportitemserialid BIGINT UNSIGNED DEFAULT NULL,   
MODIFY ex\_reportitemserialid BIGINT UNSIGNED DEFAULT NULL”   
h=localhost,D=SQL\_AuditPro,t=tradeline\_comp

---

<div class="post-metadata">

**Author:** ![carlos.salguero](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/carlos.salguero/32/20_2.png) [@carlos.salguero](https://forums.percona.com/u/carlos.salguero)\
**Post date:** [November 28, 2018, 12:29pm UTC](https://forums.percona.com/t/can-pt-online-schema-change-pause-after-copy-but-before-table-rename/6710/2 "2018-11-28T12:29:56Z")

</div>

Hi,

You can use the pause file: [URL][pt-online-schema-change — Percona Toolkit Documentation](https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html#cmdoption-pt-online-schema-change-pause-file%5B/URL%5D)

Regards

---

<div class="post-metadata">

**Author:** ![cwbrumett](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@cwbrumett](https://forums.percona.com/u/cwbrumett)\
**Post date:** [November 28, 2018, 3:03pm UTC](https://forums.percona.com/t/can-pt-online-schema-change-pause-after-copy-but-before-table-rename/6710/3 "2018-11-28T15:03:09Z")

</div>

Thanks Carlos. I’m assuming this will pause the entire execution of [LEFT][COLOR=#252C2F]pt-online-schema-change, even during the copy phase?

Would there be a way to generate this pause file once the copy phase completes or would someone have to manually watch and create the file?[/LEFT]

---

<div class="post-metadata">

**Author:** ![carlos.salguero](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/carlos.salguero/32/20_2.png) [@carlos.salguero](https://forums.percona.com/u/carlos.salguero)\
**Post date:** [November 28, 2018, 4:50pm UTC](https://forums.percona.com/t/can-pt-online-schema-change-pause-after-copy-but-before-table-rename/6710/4 "2018-11-28T16:50:33Z")

</div>

Hello again,

Yes, it is possible. At lines [9847~9850 in pt-online-schema-change](https://github.com/percona/percona-toolkit/blob/3.0/bin/pt-online-schema-change#L9847-L9850), it calls plugins hooks before swapping tables.

The code looks like this:

```auto
# --plugin hook
if ( $plugin && $plugin->can('before_swap_tables') ) {
$plugin->before_swap_tables();
}

```

so, you could write a custom plugin that does anything you need before swapping the tables, like signaling Attunity to stop.  
I hope it helps.

Regards

---

<div class="post-metadata">

**Author:** ![cwbrumett](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@cwbrumett](https://forums.percona.com/u/cwbrumett)\
**Post date:** [November 28, 2018, 5:49pm UTC](https://forums.percona.com/t/can-pt-online-schema-change-pause-after-copy-but-before-table-rename/6710/5 "2018-11-28T17:49:41Z")

</div>

Exactly what I need! Thanks again Carlos
