Conversation
…to avoid exceeding SQL Server's 2100 parameter limit.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a SQL Server “too many parameters” failure during URL segment/alias cache rebuilds by batching deletion of obsolete rows in the document URL repositories, and adds an integration test to reproduce the high-parameter scenario on LocalDb.
Changes:
- Batch
DELETE ... WHERE id IN (...)operations inDocumentUrlRepository.Save()andDocumentUrlAliasRepository.Save()usingInGroupsOf(Constants.Sql.MaxParameterCount). - Add an explicit integration test that creates >2000 stale URL rows to validate the batching fix (reproducible on SQL Server/LocalDb).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/Umbraco.Tests.Integration/Umbraco.Core/Services/DocumentUrlServiceTests.cs | Adds an [Explicit] integration test that sets up >2000 obsolete URL rows and asserts Save() does not throw and leaves only the new invariant rows. |
| src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentUrlRepository.cs | Batches deletion of obsolete umbracoDocumentUrl rows to avoid exceeding SQL Server parameter limits. |
| src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentUrlAliasRepository.cs | Batches deletion of obsolete umbracoDocumentUrlAlias rows to avoid exceeding SQL Server parameter limits. |
tests/Umbraco.Tests.Integration/Umbraco.Core/Services/DocumentUrlServiceTests.cs
Outdated
Show resolved
Hide resolved
tests/Umbraco.Tests.Integration/Umbraco.Core/Services/DocumentUrlServiceTests.cs
Outdated
Show resolved
Hide resolved
…L Server migration path.
Migaroez
approved these changes
Apr 3, 2026
Contributor
Migaroez
left a comment
There was a problem hiding this comment.
Code changes look good.
Test proves that the repository behind the service can handle more than Constants.Sql.MaxParameterCount of items at once.
Tested on SQL server with repo changes and without. Without fails, with succeeds.
AndyButland
added a commit
that referenced
this pull request
Apr 3, 2026
… avoid SQL Server parameter limit (closes #22339) (#22340) * Batch delete in DocumentUrlRepository and DocumentUrlAliasRepository to avoid exceeding SQL Server's 2100 parameter limit. * Address code review feedback. * Remove the unnecessary trigger rebuild on startup statement in the SQL Server migration path.
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.
Description
#22339 has shown an issue for large sites with a lot of languages in migrating to 17.3.
We have an existing operation that removes records from the
umbracoDocumentUrltable identified by Ids, that wasn't protected by the usual "groups of" pattern to avoid exceeding the SQL parameter count. This is exercised in a migration for 17.3 introduced in #21558 and fails if the number of document/language records to remove exceeds the 2100 limit.To fix I've applied the usual pattern of batch the delete of obsolete URL segment records in
DocumentUrlRepository.Save()andDocumentUrlAliasRepository.Save()usingInGroupsOf(Constants.Sql.MaxParameterCount).Add an explicit integration test that creates a scenario (110 documents × 10 languages = 2200 stale rows) to verify the fix. The test is marked
[Explicit]as it takes 10+ seconds to run.In addition, there's a bug in the migration itself that was triggering a full rebuild for both SQL Server and SQLite, but the former was a mistake and doing unnecessary work (as the data is already correct following the migration).
Testing
To test I've verified the test fails on SQL Server (LocalDb) without the fix (
SqlExceptionerror 8003: too many parameters) and passes with the fix in place.