YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: increase write connection pool to prevent timeout (#3205)
Louis Beaumontffe65c55e04e
diff --git a/crates/screenpipe-config/src/defaults.rs b/crates/screenpipe-config/src/defaults.rsindex 351d86236..c4dafc778 100644--- a/crates/screenpipe-config/src/defaults.rs+++ b/crates/screenpipe-config/src/defaults.rs@@ -113,14 +113,14 @@ impl DbConfig {cache_size_kb: 32_000, // 32 MBread_pool_max: 12,read_pool_min: 2,- write_pool_max: 3,+ write_pool_max: 6,},DeviceTier::Low => Self {mmap_size: 32 * 1024 * 1024, // 32 MBcache_size_kb: 8_000, // 8 MBread_pool_max: 5,read_pool_min: 1,- write_pool_max: 2,+ write_pool_max: 4,},}}@@ -134,7 +134,7 @@ impl Default for DbConfig {cache_size_kb: 64_000, // 64 MBread_pool_max: 27,read_pool_min: 3,- write_pool_max: 3,+ write_pool_max: 8,}}}diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rsindex f69aef8a0..ab01db77c 100644--- a/crates/screenpipe-core/src/agents/pi.rs+++ b/crates/screenpipe-core/src/agents/pi.rs@@ -77,7 +77,7 @@ async fn fetch_models_from_gateway(let has_vision = best_for.map(|arr| {arr.iter()- .any(|v| v.as_str().map_or(false, |s| s.contains("vision")))+ .any(|v| v.as_str().is_some_and(|s| s.contains("vision")))}).unwrap_or(false);let input = if has_vision {diff --git a/crates/screenpipe-db/src/write_queue.rs b/crates/screenpipe-db/src/write_queue.rsindex e582e5a5d..d9ca38f90 100644--- a/crates/screenpipe-db/src/write_queue.rs+++ b/crates/screenpipe-db/src/write_queue.rs@@ -401,7 +401,7 @@ async fn drain_loop(batch.len());}- let notify = RESUME_NOTIFY.get_or_init(|| tokio::sync::Notify::new());+ let notify = RESUME_NOTIFY.get_or_init(tokio::sync::Notify::new);tokio::select! {_ = notify.notified() => {info!("write_queue: resumed after sleep, {} pending", batch.len());diff --git a/crates/screenpipe-db/tests/db_config_test.rs b/crates/screenpipe-db/tests/db_config_test.rsindex b949025c1..fa8a9b7ca 100644--- a/crates/screenpipe-db/tests/db_config_test.rs+++ b/crates/screenpipe-db/tests/db_config_test.rs@@ -17,7 +17,7 @@ async fn low_tier_db_initializes_successfully() {assert_eq!(config.mmap_size, 32 * 1024 * 1024);assert_eq!(config.cache_size_kb, 8_000);assert_eq!(config.read_pool_max, 5);- assert_eq!(config.write_pool_max, 2);+ assert_eq!(config.write_pool_max, 4);// DB should initialize without errorslet _db = DatabaseManager::new("sqlite::memory:", config)@@ -66,3 +66,44 @@ async fn low_tier_db_can_insert_and_query() {.await.unwrap();}++#[tokio::test]+async fn write_pool_size_increased_for_all_tiers() {+ // Regression test for issue SCREENPIPE-CLI-FZ: connection pool timeout+ // Verifies that the write pool size has been increased to handle+ // high-volume UI event batches without timing out.++ let high_config = DbConfig::default();+ assert!(+ high_config.write_pool_max >= 8,+ "high-tier write_pool_max should be at least 8, was {}",+ high_config.write_pool_max+ );++ let mid_config = DbConfig::for_tier(screenpipe_config::DeviceTier::Mid);+ assert!(+ mid_config.write_pool_max >= 6,+ "mid-tier write_pool_max should be at least 6, was {}",+ mid_config.write_pool_max+ );++ let low_config = DbConfig::for_tier(screenpipe_config::DeviceTier::Low);+ assert!(+ low_config.write_pool_max >= 4,+ "low-tier write_pool_max should be at least 4, was {}",+ low_config.write_pool_max+ );++ // Verify all pool configs initialize without error+ let _high_db = DatabaseManager::new("sqlite::memory:", high_config)+ .await+ .expect("high-tier DB with increased write pool should initialize");++ let _mid_db = DatabaseManager::new("sqlite::memory:", mid_config)+ .await+ .expect("mid-tier DB with increased write pool should initialize");++ let _low_db = DatabaseManager::new("sqlite::memory:", low_config)+ .await+ .expect("low-tier DB with increased write pool should initialize");+}