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

Aperta Adatta ai principianti
#67,536 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend, databases

Direzione di ricerca

Leggi LocalPreviewStorage::fetchFilecacheByPathHashes() in lib/private/Preview/Storage/LocalPreviewStorage.php e confronta la sua query con la condizione di archiviazione aggiunta per deleteFolder() in #58403. Verifica come è disponibile l’ID dello storage radice delle anteprime appdata ed esamina i test correlati della migrazione. Il lavoro è concluso quando la ricerca limita le righe a quello storage e la regressione è coperta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
PHP
Stelle
37.6k
Fork
5.4k
Merge medio
1g 20h
PR unite (30g)
605

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nextcloud/server

Tutte le issue di nextcloud/server

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.