Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ PROMETHEUS_URL=https://prometheus.example.com cargo build --release --features p
- Labels: `host` (hostname) and `mountpoint` (e.g., `/var/lib/pgsql`)

**How it works:**
1. During primary health check, captures total database size
2. For replicas using pg_basebackup, queries Prometheus for filesystem usage
3. Estimates progress: `(used_bytes / primary_db_size) * 100`
4. Progress stored in analysis results (0-10000, where 4156 = 41.56%)
1. Fetches filesystem metrics for all nodes in the cluster at startup using a single batch query (e.g., `host=~"dev-pg-app001.*"`)
2. For replicas using pg_basebackup, compares the replica's filesystem used bytes against the primary's filesystem used bytes
3. Estimates progress: `(replica_used_bytes / primary_used_bytes) * 100`
4. Progress stored as percentage * 100 (e.g., 4156 = 41.56%), keyed by replica IP address

**Note:** This is a rough estimate assuming filesystem usage is mostly from the backup. May be inaccurate if significant other data exists on the filesystem.
**Note:** This is a filesystem-to-filesystem comparison (not database size), chosen for performance reasons as querying database size is too slow on large clusters. This is a rough estimate assuming both filesystems primarily contain PostgreSQL data. Will be inaccurate if filesystems have significantly different amounts of other data. As of this writing, the system queries the pgsql mount point, so it shouldn't drift too far. Except for WAL, logs etc...

## Configuration

Expand Down
6 changes: 3 additions & 3 deletions src/v2/analyze/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,12 +763,12 @@ fn pg_lsn_diff(lsn1: &str, lsn2: &str) -> Option<u64> {
///
/// This is a rough estimate assuming the used bytes on the replica are mostly from the backup.
/// This may be inaccurate if there's other data on the filesystem.
fn estimate_backup_progress(primary_db_size: u64, replica_used_bytes: u64) -> u16 {
if primary_db_size == 0 {
fn estimate_backup_progress(primary_used_bytes: u64, replica_used_bytes: u64) -> u16 {
if primary_used_bytes == 0 {
return 0;
}

let progress = (replica_used_bytes as f64 / primary_db_size as f64) * 10000.0;
let progress = (replica_used_bytes as f64 / primary_used_bytes as f64) * 10000.0;
progress.min(10000.0) as u16
}

Expand Down