postgres-errors-replication-lag

Analyze PostgreSQL replication lag using pg_stat_replication, pg_replication_slots, and pg_stat_subscription views.

Updated May 19, 2026
One-click install
npx skills add https://github.com/Impertio-Studio/PostgreSQL-Claude-Skill-Package --skill postgres-errors-replication-lag
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: postgres-errors-replication-lag
Source: https://github.com/Impertio-Studio/PostgreSQL-Claude-Skill-Package/tree/main/skills/source/postgres-errors/postgres-errors-replication-lag
Command: npx skills add https://github.com/Impertio-Studio/PostgreSQL-Claude-Skill-Package --skill postgres-errors-replication-lag

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps identify and resolve replication lag issues in PostgreSQL, ensuring data consistency and preventing system failures.

Core Features & Use Cases

  • Replication Lag Monitoring: Tracks streaming and logical replication lag, including WAL bloat and stuck subscriptions.
  • Slot Bloat Management: Alerts on and resolves slot bloat, preventing disk space issues.
  • Stuck Subscription Recovery: Provides steps to recover stuck logical subscriptions due to conflicts.
  • Use Case: For a PostgreSQL primary server experiencing replication lag, this Skill can identify the root cause, such as a slow standby or a stuck subscription, and guide the user through recovery steps.

Quick Start

Run the postgres-errors-replication-lag skill to monitor replication lag and slot bloat on your PostgreSQL server.

Frequently Asked Questions about postgres-errors-replication-lag

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check PostgreSQL replication lag and identify the root cause?▼

To check PostgreSQL replication lag, analyze the pg_stat_replication, pg_replication_slots, and pg_stat_subscription views to identify root causes like slow standby servers or stuck subscriptions.

Why does PostgreSQL replication slot bloat happen and how do I resolve it?▼

PostgreSQL replication slot bloat happens when WAL files accumulate for inactive subscribers. Resolve slot bloat by monitoring pg_replication_slots to prevent disk space issues and remove or advance inactive slots.

How do I recover a stuck logical subscription in PostgreSQL?▼

Recover a stuck logical subscription in PostgreSQL by identifying conflicts in pg_stat_subscription and applying targeted recovery steps to resume logical replication without losing data consistency.

Does this PostgreSQL replication lag monitoring approach support older database versions?▼

This PostgreSQL replication lag monitoring approach requires PostgreSQL version 15, 16, or 17. Older database versions are not supported for analyzing replication slots and subscription recovery.

What is the best way to monitor both streaming and logical replication lag in PostgreSQL?▼

The best way to monitor streaming and logical replication lag is to query pg_stat_replication for streaming metrics and pg_stat_subscription for logical replication status to catch WAL bloat early.

What should I do when PostgreSQL logical replication is not working due to conflicts?▼

When PostgreSQL logical replication is not working due to conflicts, check pg_stat_subscription for stuck statuses and follow subscription recovery steps to clear the conflict and restart replication.