Rollback against the incorrect DDL


As far as I knew, after performing DDL(add column), there is no rollback process in MemSQL. And DDL does also not abort after DDL performed.

However, we have seen that DDL can be aborted immediately with Ctrl^C after performing DDL.
At this time, the status of DDL was ‘PREPARE’.
How long does the PREPARE status last?
How MemSQL is working internally in the PREPARE status.

The purpose of question is to check the exact time to execute the rollback against the incorrect DDL.



Yes ALTER TABLE runs as a two-phase commit (2PC). While the 2PC is preparing the ALTER can be killed. Once it commits, the ALTER can’t be killed. The PREPARE phase is typically very quick - it only does the metadata changes (on all nodes in the cluster) and waits for all replica partitions to replay them. There are two common ways for the PREPARE phase to take some time:

  1. Replica partitions that are out of sync. ALTER will wait for them to catch up (and fail if they don’t catch up with in a time)
  2. Long running queries. The PREPARE phase needs to wait until no queries are running against the table to switch over the metadata (so it can happen on all nodes in the cluster synchronously). If there are long running queries running at the time of an ALTER the prepare phase will wait on them.