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

ddl code refactor/optimize #54436

Open
45 of 54 tasks
D3Hunter opened this issue Jul 4, 2024 · 0 comments
Open
45 of 54 tasks

ddl code refactor/optimize #54436

D3Hunter opened this issue Jul 4, 2024 · 0 comments
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@D3Hunter
Copy link
Contributor

D3Hunter commented Jul 4, 2024

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

@D3Hunter D3Hunter added the type/enhancement The issue or PR belongs to an enhancement. label Jul 4, 2024
ti-chi-bot bot pushed a commit that referenced this issue Jul 22, 2024
ti-chi-bot bot pushed a commit that referenced this issue Jul 23, 2024
ti-chi-bot bot pushed a commit that referenced this issue Jul 24, 2024
ti-chi-bot bot pushed a commit that referenced this issue Jul 24, 2024
ti-chi-bot bot pushed a commit that referenced this issue Sep 27, 2024
ti-chi-bot bot pushed a commit that referenced this issue Sep 27, 2024
EricZequan pushed a commit to EricZequan/tidb that referenced this issue Sep 29, 2024
ti-chi-bot bot pushed a commit that referenced this issue Oct 14, 2024
ti-chi-bot bot pushed a commit that referenced this issue Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

1 participant