From 2b79099cfe5738ba7b660c0a872c220468b167e5 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Wed, 1 Feb 2023 18:09:30 -0600 Subject: [PATCH] improvement: drop slow readers more quickly --- src/repo/sqlite.rs | 8 ++++---- src/server.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/repo/sqlite.rs b/src/repo/sqlite.rs index 01221ce..6519abe 100644 --- a/src/repo/sqlite.rs +++ b/src/repo/sqlite.rs @@ -364,9 +364,9 @@ impl NostrRepo for SqliteRepo { if sql_gen_elapsed > Duration::from_millis(10) { debug!("SQL (slow) generated in {:?}", filter_start.elapsed()); } - // any client that doesn't cause us to generate new rows in 5 + // any client that doesn't cause us to generate new rows in 2 // seconds gets dropped. - let abort_cutoff = Duration::from_secs(5); + let abort_cutoff = Duration::from_secs(2); let mut slow_first_event; let mut last_successful_send = Instant::now(); // execute the query. @@ -436,8 +436,8 @@ impl NostrRepo for SqliteRepo { return Ok(()); } // give the queue a chance to clear before trying again - info!("query thread sleeping due to full query_tx (cid: {}, sub: {:?})", client_id, sub.id); - thread::sleep(Duration::from_millis(100)); + debug!("query thread sleeping due to full query_tx (cid: {}, sub: {:?})", client_id, sub.id); + thread::sleep(Duration::from_millis(500)); } // TODO: we could use try_send, but we'd have to juggle // getting the query result back as part of the error diff --git a/src/server.rs b/src/server.rs index d956459..8b34ebb 100644 --- a/src/server.rs +++ b/src/server.rs @@ -576,7 +576,7 @@ async fn nostr_server( // we will send out the tx handle to any query we generate. // this has capacity for some of the larger requests we see, which // should allow the DB thread to release the handle earlier. - let (query_tx, mut query_rx) = mpsc::channel::(20000); + let (query_tx, mut query_rx) = mpsc::channel::(20_000); // Create channel for receiving NOTICEs let (notice_tx, mut notice_rx) = mpsc::channel::(128);