修复: MCP 多进程缺陷(update CAS乐观锁 + 审计落盘 + 空闲超时 + busy_timeout + stdio写回调 + list分页)

This commit is contained in:
lxy
2026-08-08 18:43:38 +08:00
parent 6aa334fc9b
commit 02c8d8e5ea
5 changed files with 559 additions and 55 deletions
+3
View File
@@ -19,6 +19,9 @@ impl Database {
/// 打开(或创建)数据库文件
pub async fn open(path: &Path) -> Result<Self> {
let conn = Connection::open(path)?;
// GUI 与 MCP server 多进程写同库(WAL 下写写仍互斥),无 busy_timeout 时并发写
// 立即报 SQLITE_BUSY。设 5s 等待,让短暂持锁的一方先完成而非直接失败。
conn.busy_timeout(std::time::Duration::from_millis(5000))?;
conn.execute_batch("PRAGMA journal_mode=WAL; PRAGMA foreign_keys=ON;")?;
// 执行迁移