GithubHelp home page GithubHelp logo

Support online DDL about sqle HOT 1 CLOSED

actiontech avatar actiontech commented on May 20, 2024
Support online DDL

from sqle.

Comments (1)

drivebyer avatar drivebyer commented on May 20, 2024

功能

  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 格式等

from sqle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.