Skip to content

Commit 220d29d

Browse files
Fix Go SQLite E2E: force single connection for in-memory DB
Go's sql.DB is a connection pool. With :memory:, each connection gets its own separate in-memory database, so INSERT on one connection is invisible to SELECT on another. SetMaxOpenConns(1) forces all queries to share the same in-memory database. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5387c54 commit 220d29d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

go/internal/e2e/session_fs_sqlite_e2e_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ func (p *inMemorySqliteProvider) getOrCreateDBLocked() (*sql.DB, error) {
4949
if err != nil {
5050
return nil, err
5151
}
52+
// Force single connection so all queries share the same in-memory database.
53+
db.SetMaxOpenConns(1)
5254
_, err = db.Exec("PRAGMA busy_timeout = 5000")
5355
if err != nil {
5456
db.Close()

0 commit comments

Comments
 (0)