Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support online DDL #38

Closed
sjjian opened this issue Oct 18, 2021 · 1 comment
Closed

Support online DDL #38

sjjian opened this issue Oct 18, 2021 · 1 comment
Assignees
Labels
feature verified the issue all pr is verified
Milestone

Comments

@sjjian
Copy link
Member

sjjian commented Oct 18, 2021

No description provided.

@sjjian sjjian added the feature label Oct 18, 2021
@sjjian sjjian added this to the 1.2110.0 milestone Oct 18, 2021
@drivebyer
Copy link
Contributor

drivebyer commented Oct 20, 2021

功能

  1. MySQL 上线DDL时,对于大表DDL可以采用集成 online schema change 工具进行改表,而不是直接执行DDL SQL,避免大表DDL造成锁表的问题;
  2. 可以通过规则模板配置该规则的形式开启或者关闭该功能。

方案

集成 gh-ost

流程

MySQL driver 新增全局配置类型规则 ConfigDDLGhost。当上线的 Alter 语句满足以下条件时,使用 gh-ost :

  1. 数据源启用该规则
  2. 表空间超过 ConfigDDLGhost 配置的 value 阈值

gh-ost 配置目前使用全局配置文件的方式(放在 SQLE 的 etc 目录下)。

适配

  1. NewDriver 方法新增参数 rules(当前审核上下文中的审核规则集):
    1. 优化了 Driver 接口的 Audit 方法,不用每次都传入规则集(SQLE-202)
    2. 为下面的 Exec 做准备
  2. 修改 MySQL 插件的 Exec 做适配。执行 Exec 方法时需要根据规则集是否有 ConfigDDLGHOst 来决策是否使用 gh-ost。

新增

MySQL 插件中新增 onlineddl 包,包含:

  1. Executor 对象,该对象包装 https://github.com/github/gh-ost/blob/master/go/logic/migrator.go#L89:6
  2. Executor.Execute() 方法,该方法包装 https://github.com/github/gh-ost/blob/master/go/logic/migrator.go#L335:23,执行 Online DDL。

由于是集成第三方组件,需要将 gh-ost 的所有输出集成到 SQLE 的日志文件中,便于排查问题。gh-ost 的日志输出主要分为两部分:

  1. gh-ost Logger 接口的输出。将 SQLE 的 logger 包装成 gh-ost Logger,可以将 gh-ost 的这部分日志输出到 SQLE 的日志文件。
  2. 标准输出。如 迁移进度

考虑

  1. gh-ost 配置从全局配置优化成实例级配置(后续优化)
  2. 数据源用户权限问题
  3. gh-ost 本身的限制,如从实例 binlog 需要 RBR 格式等

@sjjian sjjian closed this as completed Oct 26, 2021
@Marcus9530 Marcus9530 added the verified the issue all pr is verified label Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature verified the issue all pr is verified
Projects
None yet
Development

No branches or pull requests

3 participants