GreptimeTeam/greptimedb
View on GitHubSupport WITH (timeout/wait) for DDL statements
Open
#7,603 opened on Jan 22, 2026
C-enhancementgood first issue
Repository metrics
- Stars
- (6,332 stars)
- PR merge metrics
- (PR metrics pending)
Description
What type of enhancement is this?
Tech debt reduction, User experience
What does the enhancement do?
Enable all DDL procedures (CREATE/ALTER/DROP/TRUNCATE/COMMENT/VIEW/FLOW, and trigger where applicable) to accept WITH (timeout='...', wait=...) and propagate these options to the DDL executor, so callers can control async behavior consistently. Today only ALTER TABLE repartition supports these options; this change makes it uniform and predictable across all DDLs.
We can break this issue down into multiple subtasks:
- CREATE TABLE
- CREATE VIEW
- DROP TABLE
- DROP DATABASE
- CREATE FLOW
- TRUNCATE TABLE
- ...
Implementation challenges
- DDL options are currently mixed with table/database options via
parse_with_optionsandOptionMap(seesrc/sql/src/parsers/utils.rsandsrc/table/src/requests.rs); for CREATE TABLE/CREATE DATABASE,timeout/waitmust not be persisted as table/db options. parse_ddl_optionsexists but is only used in the repartition path (src/operator/src/statement/ddl.rs); the logic needs to be generalized and applied to all DDL submission paths.DdlOptionsinsrc/common/meta/src/ddl_manager.rsis only used by repartition; other procedures lack a timeout mechanism and always wait for completion.- Decide semantic behavior when
wait=trueand timeout triggers (return timeout error vs. procedure id), and ensure consistency with existing Repartition timeout semantics.
Research notes (current state)
- DDL option keys are defined in
src/table/src/requests.rs(DDL_TIMEOUT,DDL_WAIT,VALID_DDL_OPTION_KEYS). - SQL parser only attaches
WITHoptions to ALTER TABLE (seesrc/sql/src/parsers/alter_parser.rs, includes TODO for DDL options); other DDL statements do not parseWITH. parse_ddl_optionslives insrc/operator/src/statement/ddl.rsand is only applied in the repartition flow; all otherSubmitDdlTaskRequestcreation paths ignore options.DdlManagerusesDdlOptionsonly in repartition; other procedures always callexecute_procedure_and_waitwithout timeout.- Repartition procedure supports per-operation timeouts (
src/meta-srv/src/procedure/repartition.rs), but other DDL procedures do not.
Proposed plan
-
SQL layer
- Add
WITH (...)DDL options to DDL statements that currently have none: DROP TABLE/DATABASE/FLOW/VIEW, TRUNCATE TABLE, COMMENT ON, CREATE/DROP VIEW/FLOW, CREATE/DROP DATABASE, etc. - Introduce a
ddl_options: OptionMapfield (or equivalent) in relevant AST structs, separate from table/db options. - Add parser helper to validate only
wait/timeoutfor DDL options, and split them from table/db options whereWITHalready exists (e.g., CREATE TABLE/CREATE DATABASE). - Add parser tests for each statement (positive and invalid option cases).
- Add
-
Operator layer
- Extend statement handling to extract DDL options and set
SubmitDdlTaskRequest.wait/timeoutconsistently for every DDL submission path insrc/operator/src/statement/ddl.rs. - Ensure DDL options are removed before building
CreateTableExpr/TableOptions/ database options.
- Extend statement handling to extract DDL options and set
-
Metasrv layer
- Add a generic timeout path for
wait=truerequests (e.g.,tokio::time::timeoutaroundwatcher::wait). - Propagate
DdlOptionsto procedures where needed; add procedure-level timeouts for long-running tasks (drop database, create/drop table, truncate table, flow/view ops) where external RPCs can block.
- Add a generic timeout path for
-
Tests and docs
- Unit tests for
parse_ddl_optionsand new statement parsing. - Integration tests for
WAIT=false(returns procedure id) andTIMEOUTbehavior. - Update docs/examples to show
WITH (timeout, wait)on multiple DDLs.
- Unit tests for