$npx -y skills add digoal/postgres_skill --skill polardb-daily-checkComprehensive daily health check for PolarDB for PostgreSQL databases, including LogIndex status, HTAP/MPP monitoring, shared storage performance, and high availability checks
| 1 | # PolarDB Daily Check Agent |
| 2 | |
| 3 | This skill guides the agent in conducting a thorough daily health check of a PolarDB for PostgreSQL database instance. It extends the PostgreSQL daily check capabilities with PolarDB-specific checks for its unique architecture (Shared-Storage, LogIndex, HTAP/MPP). |
| 4 | |
| 5 | ## Purpose |
| 6 | |
| 7 | The primary goal of this skill is to empower the agent to proactively monitor the health and performance of PolarDB for PostgreSQL, leveraging its unique features like storage-compute separation, LogIndex, and HTAP capabilities. It performs routine inspections efficiently with PolarDB-specific insights. |
| 8 | |
| 9 | ## Core Capabilities |
| 10 | |
| 11 | The agent performs checks across several key areas: |
| 12 | |
| 13 | * **PolarDB Core Health**: Node type verification, LogIndex status, PFS storage usage |
| 14 | * **Availability & Health**: Standard PostgreSQL health checks (invalid indexes, XID wraparound, blocking locks) |
| 15 | * **Performance & Activity**: Active sessions, long-running queries, cache efficiency, MPP parallel query performance |
| 16 | * **HTAP & MPP**: Parallel query statistics, worker status, coordinator coordination |
| 17 | * **Storage & I/O**: Shared storage performance, PolarFS usage, buffer pool status |
| 18 | * **Replication & Consistency**: Primary-readonly node sync status, LogIndex replay lag |
| 19 | |
| 20 | ## PolarDB-Specific Checks |
| 21 | |
| 22 | ### LogIndex Architecture |
| 23 | |
| 24 | PolarDB uses **LogIndex** to maintain page replay history for read-only nodes, solving the "past page" problem. Key checks include: |
| 25 | |
| 26 | - LogIndex replay status and latency |
| 27 | - WAL metadata consistency between primary and read-only nodes |
| 28 | - Lazy and Parallel replay efficiency |
| 29 | |
| 30 | ### HTAP & MPP Architecture |
| 31 | |
| 32 | PolarDB supports HTAP via distributed MPP execution engine: |
| 33 | |
| 34 | - **PxScan** and **Shuffle** operators for parallel execution |
| 35 | - Coordinator-Worker coordination for skew elimination |
| 36 | - Serverless elastic scaling of compute nodes |
| 37 | - `polar_enable_px` parameter controls MPP functionality |
| 38 | |
| 39 | ### Storage-Compute Separation |
| 40 | |
| 41 | In this architecture: |
| 42 | |
| 43 | - **Storage**: Shared PolarFS, scales independently |
| 44 | - **Compute**: Multiple read-write and read-only nodes, stateless |
| 45 | - **Benefits**: No data replication during scaling, cost-effective read replicas |
| 46 | |
| 47 | ## Workflow |
| 48 | |
| 49 | When activated, this skill executes a predefined sequence of checks: |
| 50 | 1. First runs PolarDB-specific checks (node type, LogIndex, PFS) |
| 51 | 2. Then runs standard PostgreSQL compatibility checks |
| 52 | 3. Generates a comprehensive Markdown report with PolarDB-specific recommendations |
| 53 | |
| 54 | ## Available Skills |
| 55 | |
| 56 | Each item below represents a callable skill, returning structured JSON output. |
| 57 | |
| 58 | --- |
| 59 | |
| 60 | ## 1. PolarDB Core Health |
| 61 | |
| 62 | ### Skill: `get_polar_node_type` |
| 63 | |
| 64 | - **Description**: Checks the current PolarDB node type and role using `polar_node_type()` function. |
| 65 | - **Usage**: `./run_polardb_check.sh get_polar_node_type` |
| 66 | - **Expected Output**: |
| 67 | ```json |
| 68 | { |
| 69 | "skill": "get_polar_node_type", |
| 70 | "status": "success", |
| 71 | "data": [ |
| 72 | { |
| 73 | "node_type": "Primary", |
| 74 | "is_writable": true, |
| 75 | "polar_version": "2.0" |
| 76 | } |
| 77 | ] |
| 78 | } |
| 79 | ``` |
| 80 | - **Analysis**: Reports the node role (Primary/ReadOnly) and write capability. |
| 81 | |
| 82 | ### Skill: `get_logindex_status` |
| 83 | |
| 84 | - **Description**: Monitors LogIndex replay status and lag between primary and read-only nodes. |
| 85 | - **Usage**: `./run_polardb_check.sh get_logindex_status` |
| 86 | - **Expected Output**: |
| 87 | ```json |
| 88 | { |
| 89 | "skill": "get_logindex_status", |
| 90 | "status": "success", |
| 91 | "data": [ |
| 92 | { |
| 93 | "node_role": "ReadOnly", |
| 94 | "replay_lag_mb": 15, |
| 95 | "replay_lag_seconds": 2, |
| 96 | "pending_wal_count": 50 |
| 97 | } |
| 98 | ] |
| 99 | } |
| 100 | ``` |
| 101 | - **Analysis**: WARNING if replay lag >100MB or >10 seconds. CRITICAL if lag >1GB. |
| 102 | |
| 103 | ### Skill: `get_pfs_usage` |
| 104 | |
| 105 | - **Description**: Reports Polar File System (PFS) storage usage using `pfs_du_with_depth()` and `pfs_info()`. |
| 106 | - **Usage**: `./run_polardb_check.sh get_pfs_usage` |
| 107 | - **Expected Output**: |
| 108 | ```json |
| 109 | { |
| 110 | "skill": "get_pfs_usage", |
| 111 | "status": "success", |
| 112 | "data": [ |
| 113 | { |
| 114 | "total_size_gb": 500, |
| 115 | "used_size_gb": 350, |
| 116 | "used_percentage": 70, |
| 117 | "file_count": 15000 |
| 118 | } |
| 119 | ] |
| 120 | } |
| 121 | ``` |
| 122 | - **Analysis**: WARNING if usage >80%, CRITICAL if >90%. |
| 123 | |
| 124 | ### Skill: `get_polar_process_status` |
| 125 | |
| 126 | - **Description**: Detailed process information using `polar_stat_process()` - PID, wait events, I/O stats, CPU, RSS. |
| 127 | - **Usage**: `./run_polardb_check.sh get_polar_process_status` |
| 128 | - **Expected Output**: |
| 129 | ```json |
| 130 | { |
| 131 | "skill": "get_polar_process_status", |
| 132 | "status": "success", |
| 133 | "data": [ |
| 134 | { |
| 135 | "pid": 1234, |
| 136 | "state": "active", |
| 137 | "wait_event": "ClientRead", |
| 138 | "cpu_user": 5.2, |