WEBBOOK CHAPTER

MySQL 8.4 LTS, 입문에서 시니어까지: 34장. Online DDL 릴리스 실습

34장. Online DDL 릴리스 실습

orders에 risk_score를 추가한다. 먼저 staging의 production-size fixture에서 공식 문서와 dry-run으로 algorithm/lock을 확인한다. INSTANT라도 metadata lock을 취득하므로 오래된 transaction이 있으면 대기할 수 있다.

변경 전 장시간 transaction, replica lag, free disk, DDL progress, rollback/cancel 계약을 확인한다. nullable column→dual-compatible app→chunk backfill→constraint/default 강화→old code 제거 순서를 쓴다.


set session lock_wait_timeout=2;
alter table orders add column risk_score tinyint unsigned null,
  algorithm=instant;
update orders set risk_score=0
where risk_score is null order by id limit 5000;

backfill은 마지막 PK를 기록하여 순차 진행하고 transaction 사이에 replication·redo·lock 지표를 본다. process가 재시작 가능하고 이미 완료된 row를 안전하게 건너뛰는지 테스트한다.