# Replication lag & Long running alter queries

**URL:** <https://forums.percona.com/t/replication-lag-long-running-alter-queries/31679>\
**Category:** Uncategorized\
**Created:** [July 18, 2024, 8:14am UTC](https://forums.percona.com/t/replication-lag-long-running-alter-queries/31679 "2024-07-18T08:14:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kapilsingla](https://avatars.discourse-cdn.com/v4/letter/k/58f4c7/32.png) [@kapilsingla](https://forums.percona.com/u/kapilsingla)\
**Post date:** [July 18, 2024, 8:14am UTC](https://forums.percona.com/t/replication-lag-long-running-alter-queries/31679/1 "2024-07-18T08:14:24Z")

</div>

Hi All,

We have long running “ALTER TABLE … ROW\_FORMAT=COMPRESSED KEY\_BLOCK\_SIZE = 4;” queries on source mysql instance. After the queries reach the replica mysql instance, over replication, we have noticed that the replication lag is getting increased continously. We also use MTR (Multi-threaded-replication) on the replica with the following settings:

slave\_parallel\_type=‘LOGICAL\_CLOCK’  
slave\_parallel\_workers=128

on Primary, we have also enabled “binlog\_group\_commit\_sync\_delay=10000;”

Kindly advise.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [July 18, 2024, 1:22pm UTC](https://forums.percona.com/t/replication-lag-long-running-alter-queries/31679/2 "2024-07-18T13:22:28Z")

</div>

Yes, what you are experiencing with replica lag is correct and expected. ALTER TABLE is not written/replicated until _after_ the ALTER completes and immediately lags the replica.

You should switch to using [pt-online-schema-change](https://docs.percona.com/percona-toolkit/pt-online-schema-change.html) for your ALTER TABLE. This will keep replication lag near 0 during the ALTER process.
