From 6f698d0ba508459d9a3e360fd9ca51ee84cdb21e Mon Sep 17 00:00:00 2001 From: weichen Date: Sun, 11 Oct 2026 03:42:47 +0000 Subject: [PATCH] Raise the SQLite busy timeout to 30s for serialized migrators Why: with _txlock=immediate the whole migration pass holds the write lock; four racing migrators on a slow CI disk exceeded the 5s busy timeout (job 2285: SQLITE_BUSY in TestMigrateRacingSQLite) although the local tier passes. Evidence: go test -count=3 on the migration atomicity suite green locally; CI failure log cited in the Dev PR. Impact: local SQLite tier only - lock contention waits up to 30s instead of erroring; no schema or API change. Refs: Dev PR #325; plan KTD8. --- internal/store/store.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/store/store.go b/internal/store/store.go index 5320944..1afefe4 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -86,7 +86,9 @@ func OpenSQLite(path string) (*Store, error) { } // _txlock=immediate:写事务在 BEGIN 即取库写锁(而非首个写语句升级), // 跨进程迁移/写路径依赖 busy_timeout 排队而不是中途 SQLITE_BUSY(KTD8)。 - dsn := fmt.Sprintf("file:%s?_pragma=busy_timeout(5000)&_pragma=journal_mode(WAL)&_pragma=foreign_keys(1)&_txlock=immediate", path) + // busy_timeout 30s:迁移竞争测试在慢速 CI 盘上 4 个迁移者串行全程可超 5s + // (实测 job 2285 SQLITE_BUSY);本地档宁可排队不报错。 + dsn := fmt.Sprintf("file:%s?_pragma=busy_timeout(30000)&_pragma=journal_mode(WAL)&_pragma=foreign_keys(1)&_txlock=immediate", path) db, err := sql.Open("sqlite", dsn) if err != nil { return nil, err