SQLite: Basic Auth login fails with 'database is locked' (503) - token invalidation reads before writing inside a deferred transaction, busy_timeout cannot apply
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- php, sqlite
調査の方向性
Start at OC\User\Session::createSessionToken, where atomic() wraps invalidateToken and generateToken, then follow PublicKeyTokenProvider::invalidateToken into PublicKeyTokenMapper::invalidate and the preceding getToken read. Read how Doctrine transactions and retries are handled around this call, and look for existing RetryableException retry patterns in the codebase. Reproduce with two SQLite connections, one writing and one doing Basic Auth login; done means the login no longer returns 503 under concurrent writes and the auth-token tests still pass.
索引モデルが issue の本文から書いたものです。
説明
Bug description
On SQLite instances (journal_mode WAL, the default), a request with Basic Auth (WebDAV, OCS, login) can fail hard with 500/503 when another connection writes concurrently. Observed on 33.0.x and 35.0.3 (CI, PHP 8.3), identical stack on both:
SQLSTATE[HY000]: General error: 5 database is locked
PublicKeyTokenMapper::invalidate (DELETE FROM oc_authtoken)
<- PublicKeyTokenProvider::invalidateToken
<- OC\User\Session::createSessionToken (TTransactional::atomic)
<- OCA\DAV\Connector\Sabre\Auth::validateUserPass -> Sabre ServiceUnavailable (503)
Analysis: createSessionToken wraps invalidateToken + generateToken in atomic(), which opens a deferred transaction. invalidateToken first SELECTs the token (mapper->getToken) and then DELETEs it. In WAL mode, upgrading a read snapshot to a write fails immediately with SQLITE_BUSY when another connection committed since the snapshot was taken; SQLite does not consult the busy handler in this case, so PDO's default 60 s busy timeout (and any dbdriveroptions timeout) cannot help. The error reached the client within about one second while a concurrent request committed a small UPDATE on an app table.
Steps to reproduce
- Nextcloud on SQLite, two clients.
- Client A issues short writes in a loop (any app table).
- Client B logs in repeatedly with Basic Auth (e.g. WebDAV MKCOL without a session cookie).
- Occasionally B receives 503, nextcloud.log shows the stack above.
Expected behavior
The login either waits or retries; a transient SQLite lock should not surface as a failed request. Suggestion: retry the whole atomic() block on Doctrine RetryableException (like other retry-on-lock spots), or avoid the read-before-write by moving mapper->getToken out of the write transaction so the first statement in the transaction is the write.
Environment
- Nextcloud Server: 35.0.3 (also on 33.0.x)
- Database: SQLite (journal_mode WAL)
- PHP: 8.3
- Install method: CI test instance; the mechanism applies to any SQLite install
Analysis assisted by AI; verified against server source and logs.
- 主要言語
- PHP
- スター
- 37.6k
- フォーク
- 5.4k
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 625
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/server のほかの issue
-
[Bug]: Axios Update Needed対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン0. Needs triage 35-feedback bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
34-feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: GET /js/../<anything> returns 500 (NotPermittedException from JsController::getJs) instead of 404対応中かも @lazerg が 7 日前に担当しました。 オープン35-feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Dashboard widgets registered via OCA.Dashboard.register() sometimes never mount (spinner forever) – Vue 3 non-deep `callbacks` watcher race対応中かも @lazerg が 7 日前に担当しました。 オープン35-feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
nextcloud/server の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Fix routes for adminオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
area: tests area: user refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
nplhse/collaborative-ivena-statistics#1845 ·
メンテナーはふだん 1 日以内に返信
-
[Sync EN] filesystem: document the ValueError of fgets(), file_get_contents(), and touch() (#6167)オープンsync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 2 日以内に返信