next build opens registry.db in several workers at once, and switching to WAL before the timeout was set failed at once with "database is locked". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Showing 1 changed file with 2 additions and 1 deletion.
| @@ -112,7 +112,8 @@ CREATE TABLE IF NOT EXISTS registry_tags ( | ||
| 112 | 112 | function open() { |
| 113 | 113 | mkdirSync(DATA_ROOT, { recursive: true }); |
| 114 | 114 | const db = new DatabaseSync(path.join(DATA_ROOT, "registry.db")); |
| 115 | - db.exec("PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON; PRAGMA busy_timeout = 5000;"); | |
| 115 | + // The timeout first, so the rest waits for the lock: next build opens this in several workers at once. | |
| 116 | + db.exec("PRAGMA busy_timeout = 5000; PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;"); | |
| 116 | 117 | db.exec(SCHEMA); |
| 117 | 118 | return db; |
| 118 | 119 | } |