This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user