Skip to content

Commit fe37e50

Browse files
sj-robertrobert-sjoblom
authored andcommitted
Update readme
1 parent de4482d commit fe37e50

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ PROMETHEUS_URL=https://prometheus.example.com cargo build --release --features p
116116
- Labels: `host` (hostname) and `mountpoint` (e.g., `/var/lib/pgsql`)
117117

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

124-
**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.
124+
**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...
125125

126126
## Configuration
127127

src/v2/analyze/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,12 +763,12 @@ fn pg_lsn_diff(lsn1: &str, lsn2: &str) -> Option<u64> {
763763
///
764764
/// This is a rough estimate assuming the used bytes on the replica are mostly from the backup.
765765
/// This may be inaccurate if there's other data on the filesystem.
766-
fn estimate_backup_progress(primary_db_size: u64, replica_used_bytes: u64) -> u16 {
767-
if primary_db_size == 0 {
766+
fn estimate_backup_progress(primary_used_bytes: u64, replica_used_bytes: u64) -> u16 {
767+
if primary_used_bytes == 0 {
768768
return 0;
769769
}
770770

771-
let progress = (replica_used_bytes as f64 / primary_db_size as f64) * 10000.0;
771+
let progress = (replica_used_bytes as f64 / primary_used_bytes as f64) * 10000.0;
772772
progress.min(10000.0) as u16
773773
}
774774

0 commit comments

Comments
 (0)