-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Closed
Labels
sqliteIssues and PRs related to the SQLite subsystem.Issues and PRs related to the SQLite subsystem.
Description
Multiprocess use of sqlite database sometimes fails with "database is locked"
We are using https://github.com/nxtedition/nxt-undici/blob/main/lib/sqlite-cache-store.js but have the same problem with https://github.com/nodejs/undici/blob/main/lib/cache/sqlite-cache-store.js.
Basically we have a cluster nodejs service which is using the undici http cache. The queries are not super complicated or doing anything exotic.
It's unclear when/how/why this occurs and what to do about it. Might be a normal thing but in that case we should document it.
Refs: nodejs/undici#4124
this.#getValuesQuery = this.#db.prepare(`
SELECT
id,
body,
deleteAt,
statusCode,
statusMessage,
headers,
etag,
cacheControlDirectives,
vary,
cachedAt,
staleAt
FROM cacheInterceptorV${VERSION}
WHERE
url = ?
AND method = ?
AND start <= ?
ORDER BY
deleteAt ASC
`)
this.#insertValueQuery = this.#db.prepare(`
INSERT INTO cacheInterceptorV${VERSION} (
url,
method,
body,
start,
end,
deleteAt,
statusCode,
statusMessage,
headers,
etag,
cacheControlDirectives,
vary,
cachedAt,
staleAt
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`)
this.#deleteExpiredValuesQuery = this.#db.prepare(
`DELETE FROM cacheInterceptorV${VERSION} WHERE deleteAt <= ?`,
)
Metadata
Metadata
Assignees
Labels
sqliteIssues and PRs related to the SQLite subsystem.Issues and PRs related to the SQLite subsystem.