Compare commits

...

3 Commits

Author SHA1 Message Date
Sasha Krassovsky
a9d281ddbf wtf is cargo hakari?! 2024-06-17 16:31:36 -07:00
Sasha Krassovsky
e709848629 Make the code completely unreadable 2024-06-17 15:53:14 -07:00
Sasha Krassovsky
7e9a03505d Make activity monitor take pg_stat_wal_receiver into account 2024-06-17 15:51:05 -07:00
4 changed files with 33 additions and 1 deletions

4
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",
]
@@ -7394,6 +7395,8 @@ dependencies = [
"num-traits",
"once_cell",
"parquet",
"postgres",
"postgres-types",
"prost",
"rand 0.8.5",
"regex",
@@ -7414,6 +7417,7 @@ dependencies = [
"time",
"time-macros",
"tokio",
"tokio-postgres",
"tokio-rustls 0.24.0",
"tokio-util",
"toml_datetime",

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,31 @@ 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
//

View File

@@ -53,6 +53,8 @@ num-integer = { version = "0.1", features = ["i128"] }
num-traits = { version = "0.2", features = ["i128", "libm"] }
once_cell = { version = "1" }
parquet = { git = "https://github.com/apache/arrow-rs", branch = "master", default-features = false, features = ["zstd"] }
postgres = { git = "https://github.com/neondatabase/rust-postgres.git", branch = "neon", default-features = false, features = ["with-chrono-0_4"] }
postgres-types = { git = "https://github.com/neondatabase/rust-postgres.git", branch = "neon", default-features = false, features = ["with-chrono-0_4"] }
prost = { version = "0.11" }
rand = { version = "0.8", features = ["small_rng"] }
regex = { version = "1" }
@@ -70,6 +72,7 @@ subtle = { version = "2" }
sync_wrapper = { version = "0.1", default-features = false, features = ["futures"] }
time = { version = "0.3", features = ["macros", "serde-well-known"] }
tokio = { version = "1", features = ["fs", "io-std", "io-util", "macros", "net", "process", "rt-multi-thread", "signal", "test-util"] }
tokio-postgres = { git = "https://github.com/neondatabase/rust-postgres.git", branch = "neon", features = ["with-chrono-0_4"] }
tokio-rustls = { version = "0.24" }
tokio-util = { version = "0.7", features = ["codec", "compat", "io", "rt"] }
toml_datetime = { version = "0.6", default-features = false, features = ["serde"] }