Legacy preview migration looks up filecache rows by path_hash without storage condition

オープン 初心者向け
#67,536 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
backend, databases

調査の方向性

lib/private/Preview/Storage/LocalPreviewStorage.php の LocalPreviewStorage::fetchFilecacheByPathHashes() を読み、そのクエリを #58403 で deleteFolder() に追加されたストレージ条件と比較してください。appdata のプレビューのルートストレージ ID をどのように取得できるか確認し、移行に関連するテストを調べてください。このストレージの行に検索対象が限定され、回帰がテストでカバーされれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug feature: previews and thumbnails performance 🚀
Bug description

During the migration of legacy previews, LocalPreviewStorage::fetchFilecacheByPathHashes() selects rows with only a path_hash IN (…) condition across all shards:

https://github.com/nextcloud/server/blob/3a68340a6c806a18cdd0d9667a3b9ec5f096b135/lib/private/Preview/Storage/LocalPreviewStorage.php#L346-L357

There is no index on path_hash alone (only (storage, path_hash)), so every chunk of up to 1000 hashes is a full scan of oc_filecache. On large instances this makes the migration very slow and puts heavy load on the database. The same problem was fixed for deleteFolder() in #58403 by adding the storage condition.

Steps to reproduce

Found by code reading.

  1. Instance with a large oc_filecache and legacy previews in appdata_*/preview.
  2. Run the preview migration and watch the slow query log: SELECT … FROM oc_filecache WHERE path_hash IN (…) without storage.
Expected behavior

The query is restricted to the storage that holds the appdata previews (the root storage id), so the fs_storage_path_hash index is used.

Nextcloud version

master

主要言語
PHP
スター
37.6k
フォーク
5.4k
平均マージ
1日 20時間
マージ済み PR(30日)
605

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nextcloud/server のほかの issue

nextcloud/server の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。