polardb/polardbx-sql/polardbx-online-ddl
- community
Checking that the SKILL.md file is still in the repository.
Online DDL safety assessment and lock-free execution for PolarDB-X 2.0 Enterprise Edition. Determines if DDL locks the table via EXPLAIN ONLINE_DDL, rewrites with ALGORITHM=OMC for lock-free execution, checks long transactions before DDL, and guides safe DDL execution with user confirmation. Use when executing DDL on PolarDB-X and needing to assess table-locking risk, when DDL would lock the table and a lock-free alternative is needed, or when checking long transactions before DDL. Triggers: "Online DDL", "DDL锁表", "lock-free DDL", "OMC", "MDL lock", "DDL安全", "EXPLAIN ONLINE_DDL", "DDL进度", "长事务检查", "无锁变更", "DDL locks table", "lock-free change", "DDL progress", "safe DDL"
Install
npx vskill@latest install polardb/polardbx-sql/polardbx-online-ddlSKILL.md
PolarDB-X Online DDL — Safe DDL Assessment & Lock-Free Execution
Assess whether DDL operations lock the table and execute them safely on PolarDB-X 2.0 Enterprise Edition (AUTO mode). This skill covers the complete DDL safety workflow: assessment → lock-free rewriting → long transaction checks → user confirmation → execution.
Scope: PolarDB-X 2.0 Enterprise Edition + AUTO mode database only.
Version requirement: Instance version >= 5.4.20-20241224 for EXPLAIN ONLINE_DDL and OMC support. For older versions, see reference guide for legacy compatibility methods.
Core Workflow (Follow each time)
Important: DDL is a high-risk operation. NEVER execute DDL directly without presenting assessment results and obtaining explicit user confirmation.
- Assess table-locking risk with
EXPLAIN ONLINE_DDL:
``sql EXPLAIN ONLINE_DDL ALTER TABLE ...; ` Check the DDL TYPE` in the result.
- Determine execution strategy based on
DDL TYPE:
ONLINE_DDL→ Execute the original SQL directly (no table lock).LOCK_TABLE→ Rewrite withALGORITHM=OMCand re-EXPLAIN to confirm lock-free:
``sql EXPLAIN ONLINE_DDL ALTER TABLE t1 MODIFY COLUMN b text, ALGORITHM=OMC; -- Confirm: DDL TYPE = ONLINE_DDL, ALGORITHM = OMC ``
- Check long transactions on the target table:
``sql SELECT TRX_ID, PROCESS_ID, SCHEMA, START_TIME, ROUND(DURATION_TIME/1000/1000, 3) AS 'Duration(s)', SQL AS 'Current SQL' FROM INFORMATION_SCHEMA.POLARDBX_TRX WHERE DURATION_TIME > 15 * 1000 * 1000; `` If long transactions exist, assess risk before proceeding.
- Present results to user and obtain explicit confirmation before executing DDL.
DDL TYPE / ALGORITHM Quick Reference
| DDL TYPE | ALGORITHM | Description | Business Impact | |
|---|---|---|---|---|
| ONLINE_DDL | INSTANT / META_ONLY | Metadata-only change, completes in seconds | Minimal | |
| ONLINE_DDL | INPLACE / OMC / OSC | No table lock, duration depends on data volume | Small | |
| LOCK_TABLE | COPY | Locks table, table not writable during execution | Large |
Common DDL Operations Assessment
| Operation | Typical DDL TYPE | ALGORITHM | |
|---|---|---|---|
| Add column | ONLINE_DDL | INSTANT | |
| Add partition | ONLINE_DDL | META_ONLY | |
| Add index | ONLINE_DDL | INPLACE | |
| Modify column type | LOCK_TABLE | COPY → rewrite with OMC | |
| Drop column | ONLINE_DDL | INPLACE |
OMC Lock-Free Column Type Change
When EXPLAIN ONLINE_DDL returns LOCK_TABLE, append ALGORITHM=OMC to avoid table locking:
OMC trade-offs: Executes slower and consumes more resources than native DDL. Only use when avoiding table lock is critical.
Long Transaction Decision Matrix
| Situation | Recommended Action | |
|---|---|---|
| Long transaction is unexpected | Investigate business logic, resolve before DDL | |
| Long transaction is expected + high priority | Postpone DDL | |
| Long transaction is expected + low priority | Can proceed; DDL will kill the connection (default 15s timeout) |
Side effect of MDL preemption: Connections with transactions/queries exceeding 15 seconds will be killed. Avoid DDL during DataWorks/DTS/mysqldump executions.
Monitor DDL Progress
For long-running DDL operations (OMC, INPLACE with data backfill):
Best Practices
- Always EXPLAIN before executing: Never run DDL without first checking
EXPLAIN ONLINE_DDL. - Prefer native Online DDL over OMC: Only use OMC when the operation would lock the table.
- Check long transactions: Especially for tables with known long-running sync tasks.
- Schedule DDL during low-traffic windows: Even lock-free DDL consumes IO/CPU resources.
- Monitor progress for large tables: Use
DDL_PROGRESSview for operations involving data backfill.
Reference
| Reference | Description | |
|---|---|---|
| references/online-ddl.md | Complete Online DDL guide: EXPLAIN ONLINE_DDL, OMC, MDL optimizations, long transaction checks, DMS integration, legacy version compatibility |
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpolardbx-executor/src/main/resources/ai/skills/polardbx-online-ddl/SKILL.md
Popularity
- Repository stars
- 1,687
- Repository forks
- 338
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/polardb/polardbx-sql/polardbx-online-ddl)