Skip to content

ddl code refactor/optimize #54436

@D3Hunter

Description

@D3Hunter

Enhancement

We have listed a lot of items that we want to refactor, to make the structure more clear and code easier to maintain and extend, and some optimize tasks to make general DDL run faster. And in the last 8.2 sprint, we optimized for general DDL, and done some refactor for job scheduling and have left some TODOs during the refactor, #53246.
In 8.3 sprint, we have the same goal as in 8.2 and we also want to enhance testibility of DDL component, by decoupling different part of DDL(TODO), and replacing ddl.Hook with simplier failpoint.

Decouple components of DDL

Currently, ddl/ddlCtx is quite large and has a lot of responsibility, including:

  • handle job submission which come from sql executor, this is the biggest part
    • This part shares the same interface as schema-tracker, maybe extract this interface as something called DDLExecutor.
  • Handle local ddl job execution for fast creating tables. It runs on every node
  • owner election, start job scheduler
  • Enable/disable some functions, such as whether this node can attend owner election, and fast-create
  • It contains a lot of methods related to job execution, such as writePhysicalTableRecord
  • Manages fields which are shared with other components, such as below. They only use part of their function, and there are no intersections. Maybe we can create those fields on each side or separate the function.
    • SchemaSyncer, or should be called schema-version-syncer, shared with domain
    • StateSyncer, shared with SyncUpgrade api handling.
  • Manages fields that should be part of job scheduler: reorg-ctx/job-ctx/ddlSeqNum/waitSchemaSyncedController
  • Some fields are used for unit tests: hook/interceptor inside ddlCtx. We can replace them with failpoints.
  • Some util methods which should be moved out: GetTableMaxHandle

Tasks

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementThe issue or PR belongs to an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions