CleanOrphanUploadFiles may skip records when using offset pagination
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
Direzione di ricerca
Start at the CleanOrphanUploadFiles entry point and trace its batch query and interaction with DeleteAndMoveFileRecord. Verify the cleanup continues scanning all records eligible at the start of the run, including the 1001-record reproduction case, without leaving an eligible record Available.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
CleanOrphanUploadFiles may skip some available file records during a cleanup run because it uses offset-based pagination while modifying the same result set being paginated.
The cleanup job queries file records with status = Available in batches of 1000. While processing a batch, orphan files are cleaned by DeleteAndMoveFileRecord, which changes their status from Available to Deleted.
Because those records no longer match the status = Available condition, the result set becomes smaller. However, the next iteration increments the page number and continues using an offset calculated from the new result set.
For example, if there are 1001 eligible orphan records:
- Page 1 queries the first 1000 records with
OFFSET 0. - Those 1000 records are changed from
AvailabletoDeleted. - Only 1
Availablerecord remains. - Page 2 queries with
OFFSET 1000. - The remaining record is skipped, so the query returns no records and the cleanup loop exits.
As a result, not all eligible orphan file records are guaranteed to be checked in a single cleanup run. The skipped records remain Available and may only be processed by a later cleanup run.
To Reproduce
Steps to reproduce the behavior:
-
Create 1001 file records with:
status = AvailableCreatedAtolder than 2 days- no revision or other object referencing the uploaded file
- corresponding uploaded files present on disk
-
Run
CleanOrphanUploadFiles. -
Query the remaining file records with
status = Available. -
Observe that at least one eligible orphan record remains unprocessed.
The issue comes from combining offset pagination with updates to the filtered result set:
First query:
OFFSET 0 LIMIT 1000
→ 1000 records are processed
→ their status changes from Available to Deleted
Remaining Available records:
1
Second query:
OFFSET 1000 LIMIT 1000
→ returns no records
→ cleanup exits
Expected behavior
CleanOrphanUploadFiles should scan all file records that are eligible for the current cleanup run, even when previously scanned records are changed from Available to Deleted.
No eligible record should be skipped because earlier records were removed from the Available result set during the same cleanup execution.
Screenshots
Not applicable.
Platform
- Device: N/A
- OS: Not OS-specific
- Browser and version: N/A
- Version: current
main(3b9f1370612e690a0b7f230f05e688930db4c6d3) - Deployment method: Source
- Lingua principale
- Go
- Stelle
- 15.7k
- Fork
- 1.4k
- Merge medio
- 1g 20h
- PR unite (30g)
- 6
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/answer
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Hardening: cap the invite_user list size in UpdateQuestionInviteUser to bound notification fan-out Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Gravatar hash is computed from the un-lowercased email, so mixed-case accounts render an identicon Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
Tutte le issue di apache/answer
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
acceptance-tests phase-coding schema-coverage testing triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100