fix: SQLite WAL mode + log all swallowed 500 errors

- internal/db/db.go: Use _pragma syntax so modernc.org/sqlite actually
  applies busy_timeout(5000) and journal_mode(WAL). Eliminates SQLITE_BUSY
  500s when concurrent reads hit a writer holding the DELETE-mode lock.
- internal/api/handlers_*.go: Add slog.Error before every writeError with
  StatusInternalServerError so real errors appear in logs (30+ sites across
  handlers_jobs, handlers_machines, handlers_syncpairs, handlers_sshkeys).
This commit is contained in:
2026-07-08 23:55:55 -04:00
parent d0fd0e994f
commit 1734167f83
5 changed files with 31 additions and 1 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ func Open(dbPath string) (*DB, error) {
return nil, err
}
db, err := sql.Open("sqlite", dbPath+"?_journal_mode=WAL&_foreign_keys=ON&_busy_timeout=5000")
db, err := sql.Open("sqlite", dbPath+"?_pragma=busy_timeout(5000)&_pragma=journal_mode(WAL)")
if err != nil {
return nil, fmt.Errorf("opening db: %w", err)
}