Resolve blocking commit deadlock and clippy warnings
This commit is contained in:
1 parent
afc7cbdad5
commit
cbd3d5801c
5 files changed
+55
-32
No files matched your search
+5
-8
@@ -89,12 +89,10 @@ async fn index_committer_worker(state: Arc<MemoryState>) {
|
||||
loop {
|
||||
tokio::time::sleep(Duration::from_secs(5)).await;
|
||||
// Periodically commit the search index to persist inline indexing operations
|
||||
let state_clone = Arc::clone(&state);
|
||||
let _ = tokio::task::spawn_blocking(move || {
|
||||
if let Ok(idx) = state_clone.search_index.read() {
|
||||
let _ = idx.commit();
|
||||
}
|
||||
}).await;
|
||||
let idx_opt = state.search_index.read().ok().map(|idx| idx.clone());
|
||||
if let Some(idx) = idx_opt {
|
||||
let _ = idx.commit().await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,6 +217,7 @@ async fn gate_set_handler(
|
||||
fn run_server(state: Arc<MemoryState>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
rt.block_on(async {
|
||||
state.rebuild_index().await;
|
||||
tokio::spawn(index_committer_worker(Arc::clone(&state)));
|
||||
let app_state = Arc::new(AppState {
|
||||
handler: Arc::new(MemoryHandler {
|
||||
@@ -831,7 +830,5 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
activity_tx: tokio::sync::broadcast::channel(100).0,
|
||||
});
|
||||
|
||||
state.rebuild_index();
|
||||
|
||||
run_server(state)
|
||||
}
|
||||
Reference in new issue
Block a user