diff --git a/libpod/sqlite_state.go b/libpod/sqlite_state.go index 9082e736e5..7b9244913e 100644 --- a/libpod/sqlite_state.go +++ b/libpod/sqlite_state.go @@ -45,7 +45,7 @@ func NewSqliteState(runtime *Runtime) (_ State, defErr error) { return nil, fmt.Errorf("creating root directory: %w", err) } - conn, err := sql.Open("sqlite3", filepath.Join(basePath, "db.sql?_loc=auto")) + conn, err := sql.Open("sqlite3", filepath.Join(basePath, "db.sql?_loc=auto&cache=shared")) if err != nil { return nil, fmt.Errorf("initializing sqlite database: %w", err) } @@ -57,6 +57,9 @@ func NewSqliteState(runtime *Runtime) (_ State, defErr error) { } }() + // Necessary to avoid database locked errors. + conn.SetMaxOpenConns(1) + state.conn = conn if err := state.conn.Ping(); err != nil {