Skip to content

fix(core): handle parameter limits in files metadata deletion#62331

Open
gitedmond wants to merge 1 commit into
nextcloud:masterfrom
gitedmond:fix/db-parameter-limits
Open

fix(core): handle parameter limits in files metadata deletion#62331
gitedmond wants to merge 1 commit into
nextcloud:masterfrom
gitedmond:fix/db-parameter-limits

Conversation

@gitedmond

@gitedmond gitedmond commented Jul 19, 2026

Copy link
Copy Markdown

Refactor dropMetadataForFiles and dropIndexForFiles to chunk by 500 and wrap in database transactions to avoid query parameter limit errors on Oracle and PostgreSQL.

Assisted-by: Antigravity:Gemini-3.5-Flash

Summary

Refactor dropMetadataForFiles and dropIndexForFiles to chunk by 500 and wrap in database transactions to avoid query parameter limit errors on Oracle and PostgreSQL.

It looks like there was already some chunking logic set up here, but it was accidentally passing the original huge file id array instead of the chunked one. This pr just swaps that variable out so chunking actually works and wraps the loop in a transaction to keep the db happy.

Changes

  • Corrected variable references: Changed the query builder parameter binder inside the loops to use the chunked $chunk variable instead of the original $fileIds array.
  • Set safe chunk size of 500 to prevent queries from exceeding database parameter limits.
  • Wrapped loops in transaction blocks (beginTransaction / commit / rollBack) to optimize performance and prevent inconsistency on failure.
  • Added unit tests verifying chunking logic and transaction handling in tests/lib/FilesMetadata/FilesMetadataManagerTest.php.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits (Note: You must run git commit --amend -s on the branch to add your DCO signature)
  • Tests (unit, integration, api and/or acceptance) are included
  • Screenshots before/after for front-end changes
  • Documentation (manuals or wiki) has been updated or is not required
  • Backports requested where applicable (ex: critical bugfixes)
  • Labels added where applicable (ex: bug/enhancement, 3. to review, feature component)
  • Milestone added for target branch/version (ex: 32.x for stable32)

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Refactor dropMetadataForFiles and dropIndexForFiles to chunk by 500 and wrap in database transactions to avoid query parameter limit errors on Oracle and PostgreSQL.

Assisted-by: Antigravity:Gemini-3.5-Flash
Signed-off-by: Edmond <edmnd@users.noreply.github.com>
@gitedmond
gitedmond force-pushed the fix/db-parameter-limits branch from a56d71c to 48551eb Compare July 19, 2026 18:38
@gitedmond
gitedmond marked this pull request as ready for review July 19, 2026 18:42
@gitedmond
gitedmond requested a review from a team as a code owner July 19, 2026 18:42
@gitedmond
gitedmond requested review from come-nc, icewind1991, leftybournes and salmart-dev and removed request for a team July 19, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: files:scan creates oversized files_metadata DELETE query and causes severe resource usage

2 participants