Raise the SQLite busy timeout to 30s for serialized migrators
ci / vet-and-test (pull_request) Successful in 42s

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.
This commit is contained in:
2026-10-11 03:42:47 +00:00
parent 2497508271
commit 6f698d0ba5
+3 -1
View File
@@ -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