polardb/polardbx-sql/polardbx-online-ddl

Trust tier 3
  • community
Source check pending

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-ddl

SKILL.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.
  1. Assess table-locking risk with EXPLAIN ONLINE_DDL:

``sql EXPLAIN ONLINE_DDL ALTER TABLE ...; ` Check the DDL TYPE` in the result.

  1. Determine execution strategy based on DDL TYPE:
  • ONLINE_DDL → Execute the original SQL directly (no table lock).
  • LOCK_TABLE → Rewrite with ALGORITHM=OMC and 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 ``

  1. 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.

  1. Present results to user and obtain explicit confirmation before executing DDL.

DDL TYPE / ALGORITHM Quick Reference

DDL TYPEALGORITHMDescriptionBusiness Impact
ONLINE_DDLINSTANT / META_ONLYMetadata-only change, completes in secondsMinimal
ONLINE_DDLINPLACE / OMC / OSCNo table lock, duration depends on data volumeSmall
LOCK_TABLECOPYLocks table, table not writable during executionLarge

Common DDL Operations Assessment

OperationTypical DDL TYPEALGORITHM
Add columnONLINE_DDLINSTANT
Add partitionONLINE_DDLMETA_ONLY
Add indexONLINE_DDLINPLACE
Modify column typeLOCK_TABLECOPY → rewrite with OMC
Drop columnONLINE_DDLINPLACE

OMC Lock-Free Column Type Change

When EXPLAIN ONLINE_DDL returns LOCK_TABLE, append ALGORITHM=OMC to avoid table locking:

sql
-- Before: locks table
ALTER TABLE t1 MODIFY COLUMN c bigint;
-- After: lock-free via OMC
ALTER TABLE t1 MODIFY COLUMN c bigint, ALGORITHM=OMC;

OMC trade-offs: Executes slower and consumes more resources than native DDL. Only use when avoiding table lock is critical.

Long Transaction Decision Matrix

SituationRecommended Action
Long transaction is unexpectedInvestigate business logic, resolve before DDL
Long transaction is expected + high priorityPostpone DDL
Long transaction is expected + low priorityCan 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):

sql
SELECT JOB_ID, TABLE_NAME, STATE, PROGRESS, CURRENT_SPEED, DDL_STMT
FROM INFORMATION_SCHEMA.DDL_PROGRESS;

Best Practices

  1. Always EXPLAIN before executing: Never run DDL without first checking EXPLAIN ONLINE_DDL.
  2. Prefer native Online DDL over OMC: Only use OMC when the operation would lock the table.
  3. Check long transactions: Especially for tables with known long-running sync tasks.
  4. Schedule DDL during low-traffic windows: Even lock-free DDL consumes IO/CPU resources.
  5. Monitor progress for large tables: Use DDL_PROGRESS view for operations involving data backfill.

Reference

ReferenceDescription
references/online-ddl.mdComplete 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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/polardb/polardbx-sql/polardbx-online-ddl/badge)](https://verified-skill.com/skills/polardb/polardbx-sql/polardbx-online-ddl)

Something wrong with this skill or its page? Tell us.