Skip to content

Commit 8e905a5

Browse files
committed
fix: SQLite busy_timeout + stable concurrent tests
- Set PRAGMA busy_timeout=5000ms so concurrent reads wait instead of failing - Fix flaky TestPhase6DualStream (was failing ~80% due to slow path goroutine lock) - Tests now pass 5/5 consecutive runs
1 parent 8de066d commit 8e905a5

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

integration_test.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -631,18 +631,22 @@ func TestPhase6DualStream(t *testing.T) {
631631
}
632632

633633
// Give slow path time to run and release DB lock
634-
time.Sleep(200 * time.Millisecond)
635-
636-
// Verify temporal backbone edge exists
637-
edges, _ := eng.Store().GetEdgesFrom(node.ID)
638-
hasTemporalEdge := false
639-
for _, e := range edges {
640-
if e.ToID == node2.ID && e.Type == "learned_in" {
641-
hasTemporalEdge = true
634+
// Retry up to 500ms (slow path runs async)
635+
var hasTemporalEdge bool
636+
for i := 0; i < 10; i++ {
637+
time.Sleep(50 * time.Millisecond)
638+
edges, _ := eng.Store().GetEdgesFrom(node.ID)
639+
for _, e := range edges {
640+
if e.ToID == node2.ID && e.Type == "learned_in" {
641+
hasTemporalEdge = true
642+
}
643+
}
644+
if hasTemporalEdge {
645+
break
642646
}
643647
}
644648
if !hasTemporalEdge {
645-
t.Error("dual stream: temporal backbone edge not created")
649+
t.Error("dual stream: temporal backbone edge not created within 500ms")
646650
}
647651
}
648652

internal/storage/sqlite.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ func NewStore(dbPath string) (*Store, error) {
6161
if err := db.Ping(); err != nil {
6262
return nil, err
6363
}
64+
// Set busy timeout so concurrent reads wait instead of failing immediately
65+
if _, err := db.Exec("PRAGMA busy_timeout = 5000"); err != nil {
66+
return nil, err
67+
}
6468
s := &Store{db: db}
6569
if err := s.createTables(); err != nil {
6670
return nil, err

0 commit comments

Comments
 (0)