From 5ac4c52e679bae742d9d0048763d5ce8f9a20c31 Mon Sep 17 00:00:00 2001 From: Egutierrez Date: Sat, 28 Mar 2026 02:22:58 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20WAL=20mode=20expl=C3=ADcito=20con=20PRA?= =?UTF-8?q?GMA=20para=20acceso=20concurrente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cambia de _journal_mode=WAL en connection string a PRAGMA journal_mode=WAL explícito. Esto persiste en el archivo y cualquier cliente externo (sqlite3 CLI, DuckDB) hereda WAL automáticamente sin configuración adicional. Permite leer mientras el agente escribe simultáneamente sin bloqueos. Co-Authored-By: Claude Opus 4.6 (1M context) --- registry/db.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/registry/db.go b/registry/db.go index f184864f..d902ec72 100644 --- a/registry/db.go +++ b/registry/db.go @@ -128,11 +128,18 @@ func Open(path string) (*DB, error) { return nil, fmt.Errorf("creating db directory: %w", err) } - conn, err := sql.Open("sqlite3", path+"?_journal_mode=WAL&_foreign_keys=on") + conn, err := sql.Open("sqlite3", path+"?_foreign_keys=on") if err != nil { return nil, fmt.Errorf("opening database: %w", err) } + // WAL mode: enables concurrent reads while writing. + // Persists in the file — any client opening the DB inherits it. + if _, err := conn.Exec("PRAGMA journal_mode=WAL"); err != nil { + conn.Close() + return nil, fmt.Errorf("setting WAL mode: %w", err) + } + if _, err := conn.Exec(schemaSQL); err != nil { conn.Close() return nil, fmt.Errorf("applying schema: %w", err)