From b0cfc49c0dd71ae1c2df19e9ee06f7e1e9c68519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=AB=E3=83=B3?= Date: Tue, 28 Apr 2026 12:08:01 +0900 Subject: [PATCH] docs(database): scope the lock-prevention guarantee to intra-process access Co-Authored-By: Claude Sonnet 4.6 --- database/concurrent_test.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/database/concurrent_test.go b/database/concurrent_test.go index e88f2548..9707b8a0 100644 --- a/database/concurrent_test.go +++ b/database/concurrent_test.go @@ -14,20 +14,23 @@ import ( "gorm.io/gorm/logger" ) -// TestInitDBConcurrencyConfig verifies that InitDB applies both settings that -// are proven by TestConcurrentWrites to prevent "database is locked": +// TestInitDBConcurrencyConfig verifies that InitDB applies both settings used +// by TestConcurrentWrites to reduce "database is locked" errors from +// concurrent access within this process: // // 1. WAL journal mode — reduces the window during which a write lock is held // (readers no longer block writers and vice-versa). // 2. SetMaxOpenConns(1) — serialises all GORM writes through a single -// connection at the Go pool level, so SQLite write-lock contention cannot -// occur at all. +// connection at the Go pool level, which prevents the specific +// intra-process write-contention pattern exercised by these tests. // // Chain of proof: // -// TestConcurrentWrites/with_fix_* proves SetMaxOpenConns(1) fixes the bug. +// TestConcurrentWrites/with_fix_* shows SetMaxOpenConns(1) prevents the +// specific concurrent-write lock contention reproduced by that test. // TestInitDBConcurrencyConfig/single_connection_pool proves InitDB calls it. -// Therefore InitDB fixes the bug. +// Therefore InitDB applies the same mitigation for this process/pool, +// without implying that SQLite lock errors cannot occur in all scenarios. func TestInitDBConcurrencyConfig(t *testing.T) { dbPath := filepath.Join(t.TempDir(), "test.db") if err := InitDB(dbPath); err != nil {