Make app-server state DB init atomic

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Charles Cunningham
2026-03-24 15:06:36 -07:00
parent 081b1394b4
commit 74ec7c1be5

View File

@@ -486,18 +486,12 @@ impl CodexMessageProcessor {
}
async fn app_server_state_db(&self) -> Option<StateDbHandle> {
if let Some(state_db_ctx) = self.app_server_state_db_cell.get() {
return Some(state_db_ctx.clone());
}
let state_db_ctx = get_state_db(&self.config).await?;
let _ = self.app_server_state_db_cell.set(state_db_ctx.clone());
Some(
self.app_server_state_db_cell
.get()
.cloned()
.unwrap_or(state_db_ctx),
)
let config = Arc::clone(&self.config);
self.app_server_state_db_cell
.get_or_try_init(|| async move { get_state_db(&config).await.ok_or(()) })
.await
.ok()
.cloned()
}
async fn find_thread_path_by_id_with_state_db(