
Diagnose Replication Lag
Diagnoses MySQL and MariaDB replication latency, IO/SQL thread failures, GTID...
Install
npx skills add major/MySQLTuner-perl --skill diagnose_replication_lag -g -a claude-code -y- Repository
- major/MySQLTuner-perl9.5k
- Category
- Data and ML
- Updated
- 7d ago
- License
- GPL-3.0
- Context cost
- Lightabout 381 tokens
- Runs scripts
- No, instructions only
What it does
Diagnoses MySQL and MariaDB replication latency, IO/SQL thread failures, GTID synchronization, and parallel worker saturation.
AI Skill: Database Replication Latency & Health Diagnostics
🧠 Purpose & Operational Objectives
The diagnose_replication_lag skill allows AI agents to monitor binary log transport latency, parallel worker thread concurrency, and replication thread failures in master-replica and multi-source topologies.
📋 Preconditions & Context
- Server configured as a MySQL or MariaDB replica/slave node.
- Read-only queries executed (
SHOW REPLICA STATUSorSHOW SLAVE STATUS). - Compatible with legacy (
SLAVE) and modern (REPLICA) keywords.
🛠️ Input Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
max_acceptable_lag_seconds | integer | No | 30 | Threshold in seconds above which replication is considered degraded. |
channel_name | string | No | "" | Multi-source replication channel identifier (optional). |
📊 Status Evaluation
- NOT_A_REPLICA: No replication configuration detected on the instance.
- THREAD_FAILED:
Slave_IO_Running != 'Yes'orSlave_SQL_Running != 'Yes'. Returns exact SQL/IO error code and message. - DEGRADED_LAG: Threads running, but
Seconds_Behind_Master > max_acceptable_lag_seconds. - HEALTHY: Both threads running and latency within acceptable bounds.
🛡️ Guardrails & Remediation
- Automatically suggests parallel worker thread tuning (
replica_parallel_workers,replica_parallel_type = 'LOGICAL_CLOCK') to absorb heavy write streams. - Provides rollback commands for all global variables.
