Skip to content

Commit

Permalink
Don't suspend compute if there is active LR subscriber.
Browse files Browse the repository at this point in the history
  • Loading branch information
arssher committed Jan 5, 2024
1 parent 7de829e commit a41c412
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion compute_tools/src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{thread, time::Duration};

use chrono::{DateTime, Utc};
use postgres::{Client, NoTls};
use tracing::{debug, info};
use tracing::{debug, info, warn};

use crate::compute::ComputeNode;

Expand Down Expand Up @@ -84,6 +84,29 @@ fn watch_compute_activity(compute: &ComputeNode) {
}
}

// If there are existing (logical) walsenders, do not suspend.
//
// walproposer doesn't currently show up in pg_stat_replication,
// but protect if it will be
let ws_count_query = "select count(*) from pg_stat_replication where application_name != 'walproposer';";
match cli.query_one(ws_count_query, &[]) {
Ok(r) => match r.try_get::<&str, i64>("count") {
Ok(num_ws) => {
if num_ws > 0 {
last_active = Some(Utc::now());
}
}
Err(e) => {
warn!("failed to parse ws count: {:?}", e);
continue;
}
},
Err(e) => {
warn!("failed to get list of walsenders: {:?}", e);
continue;
}
}

// Update the last activity in the shared state if we got a more recent one.
let mut state = compute.state.lock().unwrap();
// NB: `Some(<DateTime>)` is always greater than `None`.
Expand Down

1 comment on commit a41c412

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2306 tests run: 2214 passed, 0 failed, 92 skipped (full report)


Test coverage report is not available

The comment gets automatically updated with the latest test results
a41c412 at 2024-01-05T22:02:48.553Z :recycle:

Please sign in to comment.