From 2c18e125dc34fa5949e6f569dffabd0349d282ae Mon Sep 17 00:00:00 2001 From: YoVinchen Date: Mon, 22 Dec 2025 23:46:26 +0800 Subject: [PATCH] fix(database): clear provider health record when removing from failover queue When a provider is removed from the failover queue, its health monitoring is no longer needed. This change ensures the health record is also deleted from the database to prevent stale data. --- src-tauri/src/database/dao/failover.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src-tauri/src/database/dao/failover.rs b/src-tauri/src/database/dao/failover.rs index e9cc31e65..85f1c6e38 100644 --- a/src-tauri/src/database/dao/failover.rs +++ b/src-tauri/src/database/dao/failover.rs @@ -78,12 +78,22 @@ impl Database { ) -> Result<(), AppError> { let conn = lock_conn!(self.conn); + // 1. 从队列中移除 conn.execute( "UPDATE providers SET in_failover_queue = 0 WHERE id = ?1 AND app_type = ?2", rusqlite::params![provider_id, app_type], ) .map_err(|e| AppError::Database(e.to_string()))?; + // 2. 清除该供应商的健康状态(退出队列后不再需要健康监控) + conn.execute( + "DELETE FROM provider_health WHERE provider_id = ?1 AND app_type = ?2", + rusqlite::params![provider_id, app_type], + ) + .map_err(|e| AppError::Database(e.to_string()))?; + + log::info!("已从故障转移队列移除供应商 {provider_id} ({app_type}), 并清除其健康状态"); + Ok(()) }