Make activity monitor take pg_stat_wal_receiver into account

This commit is contained in:
Sasha Krassovsky
2024-06-17 15:51:05 -07:00
parent b6e1c09c73
commit 7e9a03505d
3 changed files with 30 additions and 1 deletions

1
Cargo.lock generated
View File

@@ -4037,6 +4037,7 @@ version = "0.2.4"
source = "git+https://github.com/neondatabase/rust-postgres.git?branch=neon#20031d7a9ee1addeae6e0968e3899ae6bf01cee2"
dependencies = [
"bytes",
"chrono",
"fallible-iterator",
"postgres-protocol",
]

View File

@@ -17,7 +17,7 @@ nix.workspace = true
notify.workspace = true
num_cpus.workspace = true
opentelemetry.workspace = true
postgres.workspace = true
postgres = { workspace = true, features = ["with-chrono-0_4"] }
regex.workspace = true
serde.workspace = true
serde_json.workspace = true

View File

@@ -165,6 +165,34 @@ fn watch_compute_activity(compute: &ComputeNode) {
continue;
}
}
//
// Don't suspend compute if there is activity in physical replication
//
let physical_replication_query =
"select last_msg_receipt_time from pg_stat_wal_receiver;";
match cli.query_opt(physical_replication_query, &[])
{
Ok(Some(row)) => match row.try_get::<&str, DateTime<Utc>>("last_msg_receipt_time")
{
Ok(last_msg_receipt_time) =>
{
compute.update_last_active(Some(last_msg_receipt_time));
continue;
}
Err(e) =>
{
warn!("failed to parse `pg_stat_wal_receiver` `last_msg_receipt_time`: {:?}", e);
continue;
}
},
Ok(None) => { /* fall through */ },
Err(e) =>
{
warn!("Failed to query `pg_stat_wal_receiver`: {:?}", e);
continue;
}
}
//
// Do not suspend compute if autovacuum is running
//