Skip to content

Commit 8398f17

Browse files
Copilotcschleiden
andcommitted
Add _txlock=immediate to SQLite DSN for better concurrency
Co-authored-by: cschleiden <[email protected]>
1 parent 3b26e27 commit 8398f17

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

backend/sqlite/sqlite.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var migrationsFS embed.FS
3333

3434
func NewInMemoryBackend(opts ...option) *sqliteBackend {
3535
// Use a unique named in-memory database
36-
dsn := fmt.Sprintf("file:%s?mode=memory&cache=shared", uuid.NewString())
36+
dsn := fmt.Sprintf("file:%s?mode=memory&cache=shared&_txlock=immediate", uuid.NewString())
3737
b := newSqliteBackend(dsn, opts...)
3838

3939
b.db.SetConnMaxIdleTime(0)
@@ -52,7 +52,7 @@ func NewInMemoryBackend(opts ...option) *sqliteBackend {
5252
}
5353

5454
func NewSqliteBackend(path string, opts ...option) *sqliteBackend {
55-
return newSqliteBackend(fmt.Sprintf("file:%v", path), opts...)
55+
return newSqliteBackend(fmt.Sprintf("file:%v?_txlock=immediate", path), opts...)
5656
}
5757

5858
func newSqliteBackend(dsn string, opts ...option) *sqliteBackend {

0 commit comments

Comments
 (0)