场景描述:
主从使用MySQL 5.7.19
1、从库上使用xtrabackup进行热备。
2、主库行执行DDL创建索引:
ALTER TABLE `tb_xxx` ADD INDEX idx_goods_no ( `goods_no` );
3、DDL操作通过复制传递到从库,从库同时进行DDL+xtrabackup,备份出错:
190523 18:19:51 >> log scanned up to (5543703294525) InnoDB: Last flushed lsn: 5542978935310 load_index lsn 5543703473020 InnoDB: An optimized (without redo logging) DDLoperation has been performed. All modified pages may not have been flushed to the disk yet. PXB will not be able take a consistent backup. Retry the backup operation
问题原因:
在MySQL 5.7版本中,MySQL使用Bulk Load for Create Index特性来提升索引创建速度,但由于Bulk Load不会产生redo log,数据库从write-ahead logging方式退化成direct persist data,而xtrabackup依赖redo log来保证数据一致性,因此导致xtrabackup失败。