feat: 优化 SQLite 数据库连接配置,增加 busy_timeout 设置
torbox-admin / deploy (push) Successful in 1m8s

This commit is contained in:
2026-10-06 21:41:18 -07:00
parent 00062d45ec
commit aa2c0e33dd
+6 -2
View File
@@ -8,8 +8,12 @@ const createDb = () => {
const file = getDbFileName();
mkdirSync(dirname(file), { recursive: true });
const db = drizzle({ connection: { path: file } });
// node:sqlite 是同步驱动,写入会阻塞事件循环;WAL + NORMAL 下提交不再逐次刷盘
db.$client.exec("PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;");
// node:sqlite 是同步驱动,写入会阻塞事件循环;WAL + NORMAL 下提交不再逐次刷盘。
// busy_timeout 必须排在最前:默认遇到锁立刻报 database is locked,而 next build 的多个
// worker 会同时导入本模块、同时切换新库文件的 WAL 模式,后到的要等前一个切完
db.$client.exec(
"PRAGMA busy_timeout = 5000; PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;"
);
return db;
};