Run aliyun version to verify >= 3.3.3. If not installed or version too low,
run curl -fsSL https://aliyuncli.alicdn.com/setup.sh | bash to install/update,
or see references/cli-installation-guide.md for installation instructions.
Pre-check: Aliyun CLI plugin update required
[MUST] run aliyun configure set --auto-plugin-install true to enable automatic plugin installation.
[MUST] run aliyun plugin update to ensure that any existing plugins are always up-to-date.
[MUST] CLI User-Agent — Every aliyun CLI command that calls a cloud API must include:
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-history-lock-diagnose/{session-id}
(See Observability section below for session-id generation)
Runtime Requirements:
Python >= 3.7 (standard library only)
Aliyun CLI >= 3.3.3
Authentication
Pre-check: Alibaba Cloud Credentials Required
Security Rules:
NEVER read, echo, or print AK/SK values
NEVER ask the user to input AK/SK directly
ONLY use aliyun configure list to check credential status
bash
aliyun configure list
Check the output for a valid profile (AK, STS, or OAuth identity).
[MUST] Execute the script directly with the command below.Do NOT read scripts/smart-lock-diagnosis.py — it is 3700+ lines and reading it will waste context and slow down execution.
The script handles everything internally: SQL audit query, lock type detection, blocking chain analysis, deadlock diagnosis, and report generation.
Detects lock type (InnoDB row lock / MDL / Deadlock / FLUSH / Gap Lock etc.)
Identifies lock holder thread via time overlap analysis
Outputs structured diagnosis report with blocking chain
Step 3: Present Diagnosis Report
Extract the key findings from the script output and present to the user:
Lock holder thread — who holds the lock and what SQL was executed
Blocking chain — the wait relationship (A blocks B blocks C...)
Lock type — Record Lock / Gap Lock / MDL Lock / Deadlock / Flush Lock etc.
Transaction timeline — lock holder's BEGIN → DML → (uncommitted)
Recommendations — based on actual SQL content (shorten transactions, add indexes, etc.)
Key requirements:
Do NOT paste the full raw script output — extract and summarize key information only
Timestamps must include milliseconds (e.g., 10:39:28.390)
Recommendations must be based strictly on actual SQL content observed
Notes
The instance must have SQL Insight (SQL Audit) enabled
Hot data: GetDasSQLLogHotData retention depends on instance config (check HotRetention field). Data outside retention window may be unavailable
Deadlock analysis (GetDeadLockHistory) can query historical records beyond hot data window
This skill does not modify any user data or instance configurations. CreateLatestDeadLockAnalysis triggers DAS server-side deadlock parsing (classified as Write) but does not alter the database
Cleanup
This is a diagnostic skill. No user resources are created or modified; no cleanup required.