fix(files): chunk filecache IN queries to respect Oracle's 1000-element limit#60958
Draft
miaulalala wants to merge 2 commits into
Draft
fix(files): chunk filecache IN queries to respect Oracle's 1000-element limit#60958miaulalala wants to merge 2 commits into
miaulalala wants to merge 2 commits into
Conversation
…nt limit Oracle raises ORA-01795 when an IN list exceeds 1000 elements. Both getByFileIds and getByFileIdsInStorage passed the full input array directly into an IN clause with no upper bound, so any caller supplying more than 1000 file IDs would get a hard DB error on Oracle. files_sharing/Updater collects all of a user's share node IDs without limiting the count before calling getByFileIdsInStorage, making this a realistic failure path for power users. Chunk both methods at 1000 and merge results, keeping the method signatures and return types identical. Add an early return for empty input to avoid issuing a vacuous IN query. Assisted-by: ClaudeCode:claude-sonnet-4-6 Signed-off-by: Anna Larch <anna@nextcloud.com>
getByFileIds now chunks internally, so the array_chunk loop in SetupManager::setupForPath was doing a double chunk. Replace with a direct call. Assisted-by: ClaudeCode:claude-sonnet-4-6 Signed-off-by: Anna Larch <anna@nextcloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Oracle raises ORA-01795 when an IN list exceeds 1000 elements.
getByFileIdsandgetByFileIdsInStorageinFileAccesspassed the full input array directly into a single IN clause with no upper bound.files_sharing/Updater::move()collects all of a user's share node IDs across user, group, and room share types — without capping the count — before callinggetByFileIdsInStorage. This is a realistic failure path for power users on Oracle.Both methods are now chunked at 1000 elements per query with results merged, and an early return for empty input avoids issuing a vacuous IN query. Method signatures and return types are unchanged.
As a follow-up, the manual
array_chunkloop inSetupManager::setupForPaththat pre-chunked before callinggetByFileIdsis removed — it is now redundant since the method handles chunking itself.TODO
Checklist
stable32)AI (if applicable)
Assisted-by: ClaudeCode:claude-sonnet-4-6