Daemon 中的搜索索引竞争条件
作者: markovejnovic创建于 2026年9月3日更新于 2026年9月23日
标签type:bugarea:daemon
async fn rebuild_index_only(&self) {
let Some(handle) = self.handle.as_ref() else {
error!("Component not initialized");
return;
};
info!("Rebuilding search index from database");
// Create a new index
let new_index = SearchIndex::new(self.index.read().await.shells.clone());
if build_index_only(async || &new_index, handle).await.is_err() {
return;
}
// Note that **any** add_history calls go through the .read() side of self.index which
// is an rwlock.
// If we get a new history here, it would hit the **old** index, rather than the
// new one.
info!("Search index rebuild complete; {} unique commands", new_index.command_count());
*self.index.write().await = new_index;
}我认为这里的正确设计是有一种类似于包装 shell 索引并作为其守护程序的新类型。我设想了一种类似于
内容来源: atuinsh/atuin