Repository navigation
IMPORT INTO nextgen: add Init->Prepared async prepare flow (prepare_mode) #68580
Copy link
Copy link
Closed
Labels
component/DXFDistributed eXecute Framework of tidbDistributed eXecute Framework of tidbcomponent/importtype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.
Description
Enhancement
Problem
IMPORT INTO can spend more time in submit-path prepare work before users see an actionable task lifecycle when the dataset is large, and some heavy initialization work may be duplicated between submit and later planning.
| Data Size (Source_File_Size) | Prepare Time |
|---|---|
| 10.21GiB | 1.176 sec |
| 80.54GiB | 1.172 sec |
| 181.1GiB | 1.312 sec |
| 906.2GiB | 1.681 sec |
| 8.067TiB | 7.087 sec |
| 27.84TiB | 18.227 sec |
Proposal
Introduce a framework-level Init -> Prepared flow guarded by prepare_mode for nextgen IMPORT INTO (global-sort path in v1):
- Task starts as
pending + initwithprepare_mode=required. - Framework runs prepare logic asynchronously while the task is still
pending + init. - On prepare success, framework atomically persists:
step=prepared(new marker step)- updated task
meta - updated
concurrency/max_node_count - updated
extra_params
- Scheduler continues normal business-step progression from
preparedto the first import step.
User-visible behavior
SHOW IMPORT JOBSshows phasepreparingfor prepare-enabled jobs.- Prepare-heavy work is moved out of the synchronous submit critical path.
- Resource-related parameters computed during prepare are persisted before first business-step subtask scheduling.
- Compatibility default remains unchanged (
prepare_mode=disabledkeeps existing flow).
Scope (v1)
- Nextgen
IMPORT INTOglobal-sort path only. - Framework support for
StepPreparedand pending-step transition API. - Import scheduler/planner integration with prepared external metadata consumption.
Alternatives considered
Init -> Prepared(chosen): smaller blast radius, explicit durable checkpoint, no phase mutation inextra_params.Init -> Preparing -> Prepared(deferred): better in-table progress observability, but higher scheduler/storage/test complexity for current one-shot prepare scope.
Acceptance criteria
- Prepare-enabled DXF tasks follow
StepInit -> StepPrepared -> first business step. - A dedicated pending-step transition persists prepared data atomically and tolerates benign zero-row CAS races.
- Import jobs enter
running + preparingduring prepare, then transition to existing phase flow at first business step. - Targeted framework/import tests cover HA/race/cancel paths and pass in Ready-profile validation.
Risks / compatibility notes
- While prepare is running, task table step remains
init(in-table observability tradeoff for v1). - Some file-discovery-dependent failures become asynchronous failures in
preparing. - External prepared metadata may produce orphan attempt artifacts under retries; cleanup should rely on task-scoped prefix lifecycle handling.
Reference
Design/implementation plan source:
docs/agents/import-into/execplan-nextgen-init-prepared.md
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
component/DXFDistributed eXecute Framework of tidbDistributed eXecute Framework of tidbcomponent/importtype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.
Activity
dxf: add StepPrepared prepare-mode transition in scheduler framework (#…
importinto: integrate async prepare flow for nextgen (#68668)
importer: add data source access precheck for async prepare (#71488)