Randomized concurrent DDL/DML correctness testing framework for TiDB.
schrddl continuously generates and executes mixed workloads (DDL + DML), then checks whether TiDB’s behavior matches the expected in-memory/metadata model (and, in parallel mode, uses TiDB DDL job ordering to replay operations locally).
main.go: CLI entry and flags.ddl/: DDL/DML execution engine (parallel/serial/txn modes, metadata, validators).framework/: unified SQL correctness framework (optional engine).sqlgenerator/: probabilistic SQL generator (functional DSL + hooks).
- Go
1.24+(seego.mod) - A TiDB instance reachable via MySQL protocol
- A dedicated database/schema for testing (the tool creates/drops/renames tables, indexes, schemas, etc.)
Warning: do not run this against a production cluster.
go build -o schrddl./schrddl \
-addr "127.0.0.1:4000" \
-db "test" \
-mode "parallel" \
-concurrency 20 \
-tables 1 \
-time 2hschrddl supports two engines:
-engine ddl(default): legacy randomized concurrent DDL/DML engine inddl/.-engine framework: unified SQL correctness framework inframework/(optional oracles such as NoREC/TLP/EET/CERT).
Framework-specific flags:
-aqs: enable Approximate Query Synthesis-cert: enable CERT-tlp: enable TLP-eet: enable EET-pprof-addr: start pprof HTTP server (e.g.127.0.0.1:6060)
Note: -global-sort-uri only applies to -engine ddl.
-addr: TiDB address inhost:port(default127.0.0.1:4000)-db: database/schema name (defaulttest)-mode:serialorparallel-concurrency: number of concurrent workers (default20)-tables: initial tables to create per worker (default1, but currently clamped to a minimum of2)-time: total running time (default2h)-mysql-compatible: disable TiDB-only checks/features where applicable-output: log file path (empty means stdout)
-txn: enable transactional DML executor-rc-txn: use read-committed isolation (also sets TiDB globaltransaction_isolation)-prepare: use prepared statements for DML-check-ddl-extra-timeout: extra timeout for background “DDL queue drained” checks-global-sort-uri: enable dist task and settidb_cloud_storage_uri(for features that require global sort storage)
- Connection DSN is currently fixed as
root:@tcp(<addr>)/<db>(no user/password flags). - The runner sets some TiDB globals (e.g. time zone,
max_execution_time; and dist-task globals when-global-sort-uriis set). - The process has a hard exit loop after the configured duration (see
main.go), so expectos.Exit(0)shortly after-time.
Run unit tests:
go test ./...Generate example SQL (prints to stdout):
go test -v -run TestReadMeExample ./sqlgenerator/docker build -t hub.pingcap.net/qa/schrddl-master .