HybridCache: Optimize content type change cache rebuild to resolve SQL timeouts#21207
HybridCache: Optimize content type change cache rebuild to resolve SQL timeouts#21207
Conversation
…g timeouts and lock contention if a long-running document type save operation is running when the first distributed job is requested.
… small but not insignficant speed optimization.
…lightweight query Use GetMediaKeysByContentTypeKeys to fetch only media keys instead of loading full ContentCacheNode objects. This matches the same optimization applied to DocumentCacheService. Also refactors Rebuild() to reuse RebuildMemoryCacheByContentTypeAsync for the memory cache clearing step. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR optimizes HybridCache's content type change cache rebuild process to prevent SQL timeouts on sites with large amounts of content. The primary improvements include fixing database scope completion in the distributed job service, implementing parallel serialization during cache rebuilds, using lightweight queries for memory cache invalidation, and ensuring composed properties are included in rebuilt cache entries.
Key Changes:
- Fixed scope completion bug in DistributedJobService that could cause lock contention
- Optimized cache rebuild with parallel processing and direct SQL queries instead of entity hydration
- Added lightweight query methods to avoid loading serialized data when only keys are needed
- Ensured property aliases from compositions are included in cache rebuild
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Umbraco.Infrastructure/Services/Implement/DistributedJobService.cs | Fixes scope completion when no job is found and adds debug logging |
| src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs | Updates to use lightweight queries for memory cache invalidation |
| src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs | Updates to use lightweight queries and consolidates rebuild logic |
| src/Umbraco.PublishedCache.HybridCache/Services/MemberCacheService.cs | Adds Rebuild method implementation |
| src/Umbraco.PublishedCache.HybridCache/Services/IMemberCacheService.cs | Adds Rebuild method to interface |
| src/Umbraco.PublishedCache.HybridCache/Persistence/IDatabaseCacheRepository.cs | Adds new lightweight query methods for keys |
| src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs | Major refactoring to use direct SQL queries with parallel processing instead of entity hydration |
| src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj | Adds InternalsVisibleTo for HybridCache project |
| tests/Umbraco.Tests.Integration/Umbraco.PublishedCache.HybridCache/DocumentCacheServiceTests.cs | New integration tests for document cache rebuild |
| tests/Umbraco.Tests.Integration/Umbraco.PublishedCache.HybridCache/MediaCacheServiceTests.cs | New integration tests for media cache rebuild including composition tests |
| tests/Umbraco.Tests.Integration/Umbraco.PublishedCache.HybridCache/MemberCacheServiceTests.cs | New integration tests for member cache rebuild |
src/Umbraco.PublishedCache.HybridCache/Services/MemberCacheService.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.PublishedCache.HybridCache/Services/MemberCacheService.cs
Outdated
Show resolved
Hide resolved
tests/Umbraco.Tests.Integration/Umbraco.PublishedCache.HybridCache/MediaCacheServiceTests.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ack serialization.
…o v17/bugfix/sql-timeouts-on-doc-type-save # Conflicts: # src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs # src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs
|
I asked Claude for an analysis of the data access changes as compared to the current, repository based approach. OLD APPROACH: Repository-BasedThe previous implementation used 1. Full Entity Hydration
2. SQL Generated (inefficient pattern) -- Complex base query with many JOINs
SELECT * FROM umbracoNode n
INNER JOIN umbracoContent c ON n.nodeId = c.nodeId
INNER JOIN umbracoContentVersion cv ON n.nodeId = cv.nodeId AND cv.Current = 1
INNER JOIN cmsDocument d ON n.nodeId = d.nodeId
LEFT JOIN cmsContentType ctype ON c.contentTypeId = ctype.nodeId
LEFT JOIN umbracoContentVersion pcv ON n.nodeId = pcv.nodeId -- published version
LEFT JOIN ContentVersionCultureVariationDto ccv ...
WHERE n.nodeObjectType = @documentType
ORDER BY n.path
OFFSET @offset ROWS FETCH NEXT @pageSize ROWS ONLY
-- Then SEPARATE query for properties using WHERE IN (expensive):
SELECT * FROM cmsPropertyData
WHERE versionId IN (@v1, @v2, @v3, ...) -- INDEX SCAN!The NEW APPROACH: Direct SQL Queries1. Dependency Removal (DatabaseCacheRepository.cs lines 24-40) // OLD - Three repository dependencies:
private readonly IDocumentRepository _documentRepository;
private readonly IMediaRepository _mediaRepository;
private readonly IMemberRepository _memberRepository;
// NEW - No repository dependencies, direct SQL queries only2. Lightweight Key Queries (lines 232-304) // GetDocumentKeysWithPublishedStatus - Only fetches key + published flag
SELECT n.uniqueId, nu.published
FROM cmsContentNu nu
INNER JOIN umbracoNode n ON nu.nodeId = n.nodeId
INNER JOIN umbracoContent c ON n.nodeId = c.nodeId
INNER JOIN umbracoNode ct ON c.contentTypeId = ct.nodeId
WHERE n.nodeObjectType = @document
AND ct.uniqueId IN (@contentTypeKeys)
// GetMediaKeysByContentTypeKeys - Only fetches keys
SELECT n.uniqueId FROM cmsContentNu nu ...3. Optimized Rebuild Pattern (lines 363-518) Pre-fetches lookup data once: Dictionary<int, byte> contentTypeVariations = GetContentTypeVariations(contentTypeIds);
Dictionary<short, string> languageMap = GetLanguageMap();
Dictionary<int, List<PropertyTypeInfo>> propertyInfoByContentType = GetPropertyInfoByContentType(contentTypeIds);Paged ID query: SELECT nodeId FROM umbracoNode n
INNER JOIN umbracoContent c ON n.nodeId = c.nodeId
WHERE n.nodeObjectType = @document
ORDER BY n.path
-- With paging4. Efficient JOIN-Based Property Query (lines 453-468) -- NEW: JOIN through nodeId → versionId path
SELECT pd.versionId, pd.languageId, pd.segment, pd.intValue, pd.decimalValue,
pd.dateValue, pd.varcharValue, pd.textValue, pt.alias AS PropertyAlias
FROM cmsPropertyData pd
INNER JOIN cmsPropertyType pt ON pd.propertyTypeId = pt.id
INNER JOIN umbracoContentVersion cv ON pd.versionId = cv.id
WHERE cv.nodeId IN (@n1, @n2, @n3, ...) -- More efficient query planThe key difference: 5. Parallel Serialization (lines 386-399) var items = contentDtos
.AsParallel()
.WithDegreeOfParallelism(Environment.ProcessorCount)
.SelectMany(content => BuildCacheDtosForDocument(...))
.ToList();Summary of Speed Improvements
Safe Simplifications Made
|
# Conflicts: # src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs # src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs
Migaroez
left a comment
There was a problem hiding this comment.
I had a concern about the parralelism, but after digging deeper it seems like all the functions that are called are pure functions.
I am wondering whether we should add a comment to BuildCacheDtosForDocument that it is being used in a parallel path so that if any changes are being made to it, people don't forget to keep it pure.
Updated [Umbraco.Cms](https://github.com/umbraco/Umbraco-CMS) from 17.1.0 to 17.2.0. <details> <summary>Release notes</summary> _Sourced from [Umbraco.Cms's releases](https://github.com/umbraco/Umbraco-CMS/releases)._ ## 17.2.0 ## What's Changed Since 17.2.0-rc2 ### 📦 Dependencies * build(deps): bumps @umbraco-ui/uui to 1.17.0 by @iOvergaard in umbraco/Umbraco-CMS#21765 **Full Changelog**: umbraco/Umbraco-CMS@release-17.2.0-rc2...release-17.2.0 ## What's Changed Since 17.2.0-rc ### 🐛 Bug Fixes * Block Workspace: rename root-tab to 'generic' by @nielslyngsoe in umbraco/Umbraco-CMS#21699 * Block Workspace: Tabs navigation, Cherry-pick from #21672 by @nielslyngsoe in umbraco/Umbraco-CMS#21693 **Full Changelog**: umbraco/Umbraco-CMS@release-17.2.0-rc...release-17.2.0-rc2 ## What's Changed Since the Last Release (17.1.0) ### 🙌 Notable Changes * User group: add description to user group (closes #14986) by @NguyenThuyLan in umbraco/Umbraco-CMS#21057 * Content Types: Root properties by @nielslyngsoe in umbraco/Umbraco-CMS#21500 ### 📦 Dependencies * Storybook: Bumps storybook from 9.0.14 to 10.1.10 by @dependabot[bot] in umbraco/Umbraco-CMS#21208 * Bump qs from 6.14.0 to 6.14.1 in /src/Umbraco.Web.UI.Client in the npm_and_yarn group across 1 directory by @dependabot[bot] in umbraco/Umbraco-CMS#21270 * Bump the npm_and_yarn group across 2 directories with 1 update by @dependabot[bot] in umbraco/Umbraco-CMS#21403 * Dependencies: Bumps login dependencies to latest by @iOvergaard in umbraco/Umbraco-CMS#21539 * Tiptap RTE: Upgraded to latest v3.x by @leekelleher in umbraco/Umbraco-CMS#21493 * Dependencies: Bumps @umbraco-ui/uui to 1.17.0-rc.4 by @iOvergaard in umbraco/Umbraco-CMS#21538 * build(deps): bumps @umbraco-ui/uui to 1.17.0-rc.5 by @iOvergaard in umbraco/Umbraco-CMS#21569 * Dependencies: Update Microsoft packages to 10.0.1 and pin vulnerable transitive dependencies (closes #21122) by @AndyButland in umbraco/Umbraco-CMS#21285 * Dependencies: Bump to latest minor/patch versions by @AndyButland in umbraco/Umbraco-CMS#21540 ### 🚀 New Features * Markdown Conversion: Remove hard dependency on deprecated library and replace with `IMarkdownToHtmlConverter` abstraction (closes #21238 and #19500) by @AndyButland in umbraco/Umbraco-CMS#21242 * UI: Refactor breadcrumb URLs to use Path Constants by @iOvergaard in umbraco/Umbraco-CMS#21179 * Tree Navigation: Add visual indicators for items with restricted access by @iOvergaard in umbraco/Umbraco-CMS#21365 * Recycle Bin: Adds `emptyRecycleBin` collection action kind for Documents and Media by @leekelleher in umbraco/Umbraco-CMS#21482 * Tiptap RTE: Adds link (`umbLink`) support to `styleMenu` API by @leekelleher in umbraco/Umbraco-CMS#21494 * Rollback: Add toggle for diff display (closes #18518) by @AndyButland in umbraco/Umbraco-CMS#21426 * Dictionary: Add configurable value search functionality by @Nis-Knowit in umbraco/Umbraco-CMS#21200 ### 🚤 Performance * Performance: Embeds the API of selected extra conditions by @nielslyngsoe in umbraco/Umbraco-CMS#21188 * Performance: Bundle Js Libs by @nielslyngsoe in umbraco/Umbraco-CMS#21187 * Performance: Embed Store API in Manifests to lower number of network request by @madsrasmussen in umbraco/Umbraco-CMS#21191 * Performance: Avoid database lookup in `UserIdKeyResolver` for super-user by @AndyButland in umbraco/Umbraco-CMS#21281 * Performance: Only flush ID/Key map in `ContentCacheRefresher` on content deletion by @AndyButland in umbraco/Umbraco-CMS#21283 * Performance: Optimize refresh of hybrid cache for a document by retrieving draft and published in single query by @AndyButland in umbraco/Umbraco-CMS#21407 * Backoffice Performance: Inline entry point modules to reduce JS chunk count by @madsrasmussen in umbraco/Umbraco-CMS#21380 * HybridCache: Optimize content type change cache rebuild to resolve SQL timeouts by @AndyButland in umbraco/Umbraco-CMS#21207 ... (truncated) ## 17.2.0-rc2 ## What's Changed Since 17.2.0-rc ### 🐛 Bug Fixes * Block Workspace: rename root-tab to 'generic' by @nielslyngsoe in umbraco/Umbraco-CMS#21699 * Block Workspace: Tabs navigation, Cherry-pick from #21672 by @nielslyngsoe in umbraco/Umbraco-CMS#21693 **Full Changelog**: umbraco/Umbraco-CMS@release-17.2.0-rc...release-17.2.0-rc2 ## What's Changed Since the Last Release (17.1.0) ### 🙌 Notable Changes * User group: add description to user group (closes #14986) by @NguyenThuyLan in umbraco/Umbraco-CMS#21057 * Content Types: Root properties by @nielslyngsoe in umbraco/Umbraco-CMS#21500 ### 📦 Dependencies * Storybook: Bumps storybook from 9.0.14 to 10.1.10 by @dependabot[bot] in umbraco/Umbraco-CMS#21208 * Bump qs from 6.14.0 to 6.14.1 in /src/Umbraco.Web.UI.Client in the npm_and_yarn group across 1 directory by @dependabot[bot] in umbraco/Umbraco-CMS#21270 * Bump the npm_and_yarn group across 2 directories with 1 update by @dependabot[bot] in umbraco/Umbraco-CMS#21403 * Dependencies: Bumps login dependencies to latest by @iOvergaard in umbraco/Umbraco-CMS#21539 * Tiptap RTE: Upgraded to latest v3.x by @leekelleher in umbraco/Umbraco-CMS#21493 * Dependencies: Bumps @umbraco-ui/uui to 1.17.0-rc.4 by @iOvergaard in umbraco/Umbraco-CMS#21538 * build(deps): bumps @umbraco-ui/uui to 1.17.0-rc.5 by @iOvergaard in umbraco/Umbraco-CMS#21569 * Dependencies: Update Microsoft packages to 10.0.1 and pin vulnerable transitive dependencies (closes #21122) by @AndyButland in umbraco/Umbraco-CMS#21285 * Dependencies: Bump to latest minor/patch versions by @AndyButland in umbraco/Umbraco-CMS#21540 ### 🚀 New Features * Markdown Conversion: Remove hard dependency on deprecated library and replace with `IMarkdownToHtmlConverter` abstraction (closes #21238 and #19500) by @AndyButland in umbraco/Umbraco-CMS#21242 * UI: Refactor breadcrumb URLs to use Path Constants by @iOvergaard in umbraco/Umbraco-CMS#21179 * Tree Navigation: Add visual indicators for items with restricted access by @iOvergaard in umbraco/Umbraco-CMS#21365 * Recycle Bin: Adds `emptyRecycleBin` collection action kind for Documents and Media by @leekelleher in umbraco/Umbraco-CMS#21482 * Tiptap RTE: Adds link (`umbLink`) support to `styleMenu` API by @leekelleher in umbraco/Umbraco-CMS#21494 * Rollback: Add toggle for diff display (closes #18518) by @AndyButland in umbraco/Umbraco-CMS#21426 * Dictionary: Add configurable value search functionality by @Nis-Knowit in umbraco/Umbraco-CMS#21200 ### 🚤 Performance * Performance: Embeds the API of selected extra conditions by @nielslyngsoe in umbraco/Umbraco-CMS#21188 * Performance: Bundle Js Libs by @nielslyngsoe in umbraco/Umbraco-CMS#21187 * Performance: Embed Store API in Manifests to lower number of network request by @madsrasmussen in umbraco/Umbraco-CMS#21191 * Performance: Avoid database lookup in `UserIdKeyResolver` for super-user by @AndyButland in umbraco/Umbraco-CMS#21281 * Performance: Only flush ID/Key map in `ContentCacheRefresher` on content deletion by @AndyButland in umbraco/Umbraco-CMS#21283 * Performance: Optimize refresh of hybrid cache for a document by retrieving draft and published in single query by @AndyButland in umbraco/Umbraco-CMS#21407 * Backoffice Performance: Inline entry point modules to reduce JS chunk count by @madsrasmussen in umbraco/Umbraco-CMS#21380 * HybridCache: Optimize content type change cache rebuild to resolve SQL timeouts by @AndyButland in umbraco/Umbraco-CMS#21207 * Backoffice Performance: Use import maps to save requests by @nielslyngsoe in umbraco/Umbraco-CMS#21363 * Document URL Cache: Ensure URLs are rebuilt after upgrade and prevent duplicate initialization (closes #21337) by @AndyButland in umbraco/Umbraco-CMS#21379 * Performance: Fix thread safety and optimize cache updates in `PublishStatusService` after content changes by @AndyButland in umbraco/Umbraco-CMS#21415 * Tiptap RTE: Optimize `umb-input-tiptap` initialization and rendering by @leekelleher in umbraco/Umbraco-CMS#21070 * Routing: Add `DocumentUrlAliasService` for optimized URL alias lookups (closes #21383) by @AndyButland in umbraco/Umbraco-CMS#21396 * Performance: Optimize property retrieval and authorization checks in collection views (closes #21367) by @AndyButland in umbraco/Umbraco-CMS#21470 ... (truncated) ## 17.2.0-rc ## What's Changed ### 🙌 Notable Changes * User group: add description to user group (closes #14986) by @NguyenThuyLan in umbraco/Umbraco-CMS#21057 * Content Types: Root properties by @nielslyngsoe in umbraco/Umbraco-CMS#21500 ### 📦 Dependencies * Storybook: Bumps storybook from 9.0.14 to 10.1.10 by @dependabot[bot] in umbraco/Umbraco-CMS#21208 * Bump qs from 6.14.0 to 6.14.1 in /src/Umbraco.Web.UI.Client in the npm_and_yarn group across 1 directory by @dependabot[bot] in umbraco/Umbraco-CMS#21270 * Bump the npm_and_yarn group across 2 directories with 1 update by @dependabot[bot] in umbraco/Umbraco-CMS#21403 * Dependencies: Bumps login dependencies to latest by @iOvergaard in umbraco/Umbraco-CMS#21539 * Tiptap RTE: Upgraded to latest v3.x by @leekelleher in umbraco/Umbraco-CMS#21493 * Dependencies: Bumps @umbraco-ui/uui to 1.17.0-rc.4 by @iOvergaard in umbraco/Umbraco-CMS#21538 * build(deps): bumps @umbraco-ui/uui to 1.17.0-rc.5 by @iOvergaard in umbraco/Umbraco-CMS#21569 * Dependencies: Update Microsoft packages to 10.0.1 and pin vulnerable transitive dependencies (closes #21122) by @AndyButland in umbraco/Umbraco-CMS#21285 * Dependencies: Bump to latest minor/patch versions by @AndyButland in umbraco/Umbraco-CMS#21540 ### 🚀 New Features * Markdown Conversion: Remove hard dependency on deprecated library and replace with `IMarkdownToHtmlConverter` abstraction (closes #21238 and #19500) by @AndyButland in umbraco/Umbraco-CMS#21242 * UI: Refactor breadcrumb URLs to use Path Constants by @iOvergaard in umbraco/Umbraco-CMS#21179 * Tree Navigation: Add visual indicators for items with restricted access by @iOvergaard in umbraco/Umbraco-CMS#21365 * Recycle Bin: Adds `emptyRecycleBin` collection action kind for Documents and Media by @leekelleher in umbraco/Umbraco-CMS#21482 * Tiptap RTE: Adds link (`umbLink`) support to `styleMenu` API by @leekelleher in umbraco/Umbraco-CMS#21494 * Rollback: Add toggle for diff display (closes #18518) by @AndyButland in umbraco/Umbraco-CMS#21426 * Dictionary: Add configurable value search functionality by @Nis-Knowit in umbraco/Umbraco-CMS#21200 ### 🚤 Performance * Performance: Embeds the API of selected extra conditions by @nielslyngsoe in umbraco/Umbraco-CMS#21188 * Performance: Bundle Js Libs by @nielslyngsoe in umbraco/Umbraco-CMS#21187 * Performance: Embed Store API in Manifests to lower number of network request by @madsrasmussen in umbraco/Umbraco-CMS#21191 * Performance: Avoid database lookup in `UserIdKeyResolver` for super-user by @AndyButland in umbraco/Umbraco-CMS#21281 * Performance: Only flush ID/Key map in `ContentCacheRefresher` on content deletion by @AndyButland in umbraco/Umbraco-CMS#21283 * Performance: Optimize refresh of hybrid cache for a document by retrieving draft and published in single query by @AndyButland in umbraco/Umbraco-CMS#21407 * Backoffice Performance: Inline entry point modules to reduce JS chunk count by @madsrasmussen in umbraco/Umbraco-CMS#21380 * HybridCache: Optimize content type change cache rebuild to resolve SQL timeouts by @AndyButland in umbraco/Umbraco-CMS#21207 * Backoffice Performance: Use import maps to save requests by @nielslyngsoe in umbraco/Umbraco-CMS#21363 * Document URL Cache: Ensure URLs are rebuilt after upgrade and prevent duplicate initialization (closes #21337) by @AndyButland in umbraco/Umbraco-CMS#21379 * Performance: Fix thread safety and optimize cache updates in `PublishStatusService` after content changes by @AndyButland in umbraco/Umbraco-CMS#21415 * Tiptap RTE: Optimize `umb-input-tiptap` initialization and rendering by @leekelleher in umbraco/Umbraco-CMS#21070 * Routing: Add `DocumentUrlAliasService` for optimized URL alias lookups (closes #21383) by @AndyButland in umbraco/Umbraco-CMS#21396 * Performance: Optimize property retrieval and authorization checks in collection views (closes #21367) by @AndyButland in umbraco/Umbraco-CMS#21470 ### 🧪 Testing * E2E: QA Replaced unreliable Thread.Sleep(500) with a counter/gate pattern that ensures both transactions are initialized before releasing them to compete for locks by @andr317c in umbraco/Umbraco-CMS#21165 * E2E QA: Updated integration test that was missing directory setup by @andr317c in umbraco/Umbraco-CMS#21167 * E2E: QA Added acceptance tests for removing a not-found content picker by @nhudinh0309 in umbraco/Umbraco-CMS#21177 * E2E: QA Fixed failing tests for the current user profile by @nhudinh0309 in umbraco/Umbraco-CMS#21214 * Upgrade MSW from 1.3.5 to 2.12.4 by @madsrasmussen in umbraco/Umbraco-CMS#21096 * E2E: QA Added acceptance tests for rendering content with invariant blocks by @nhudinh0309 in umbraco/Umbraco-CMS#21180 * E2E: QA Added acceptance tests for content delivery API by @nhudinh0309 in umbraco/Umbraco-CMS#21095 ... (truncated) Commits viewable in [compare view](umbraco/Umbraco-CMS@release-17.1.0...release-17.2.0). </details> Updated [Umbraco.Cms.Persistence.Sqlite](https://github.com/umbraco/Umbraco-CMS) from 17.1.0 to 17.2.0. <details> <summary>Release notes</summary> _Sourced from [Umbraco.Cms.Persistence.Sqlite's releases](https://github.com/umbraco/Umbraco-CMS/releases)._ ## 17.2.0 ## What's Changed Since 17.2.0-rc2 ### 📦 Dependencies * build(deps): bumps @umbraco-ui/uui to 1.17.0 by @iOvergaard in umbraco/Umbraco-CMS#21765 **Full Changelog**: umbraco/Umbraco-CMS@release-17.2.0-rc2...release-17.2.0 ## What's Changed Since 17.2.0-rc ### 🐛 Bug Fixes * Block Workspace: rename root-tab to 'generic' by @nielslyngsoe in umbraco/Umbraco-CMS#21699 * Block Workspace: Tabs navigation, Cherry-pick from #21672 by @nielslyngsoe in umbraco/Umbraco-CMS#21693 **Full Changelog**: umbraco/Umbraco-CMS@release-17.2.0-rc...release-17.2.0-rc2 ## What's Changed Since the Last Release (17.1.0) ### 🙌 Notable Changes * User group: add description to user group (closes #14986) by @NguyenThuyLan in umbraco/Umbraco-CMS#21057 * Content Types: Root properties by @nielslyngsoe in umbraco/Umbraco-CMS#21500 ### 📦 Dependencies * Storybook: Bumps storybook from 9.0.14 to 10.1.10 by @dependabot[bot] in umbraco/Umbraco-CMS#21208 * Bump qs from 6.14.0 to 6.14.1 in /src/Umbraco.Web.UI.Client in the npm_and_yarn group across 1 directory by @dependabot[bot] in umbraco/Umbraco-CMS#21270 * Bump the npm_and_yarn group across 2 directories with 1 update by @dependabot[bot] in umbraco/Umbraco-CMS#21403 * Dependencies: Bumps login dependencies to latest by @iOvergaard in umbraco/Umbraco-CMS#21539 * Tiptap RTE: Upgraded to latest v3.x by @leekelleher in umbraco/Umbraco-CMS#21493 * Dependencies: Bumps @umbraco-ui/uui to 1.17.0-rc.4 by @iOvergaard in umbraco/Umbraco-CMS#21538 * build(deps): bumps @umbraco-ui/uui to 1.17.0-rc.5 by @iOvergaard in umbraco/Umbraco-CMS#21569 * Dependencies: Update Microsoft packages to 10.0.1 and pin vulnerable transitive dependencies (closes #21122) by @AndyButland in umbraco/Umbraco-CMS#21285 * Dependencies: Bump to latest minor/patch versions by @AndyButland in umbraco/Umbraco-CMS#21540 ### 🚀 New Features * Markdown Conversion: Remove hard dependency on deprecated library and replace with `IMarkdownToHtmlConverter` abstraction (closes #21238 and #19500) by @AndyButland in umbraco/Umbraco-CMS#21242 * UI: Refactor breadcrumb URLs to use Path Constants by @iOvergaard in umbraco/Umbraco-CMS#21179 * Tree Navigation: Add visual indicators for items with restricted access by @iOvergaard in umbraco/Umbraco-CMS#21365 * Recycle Bin: Adds `emptyRecycleBin` collection action kind for Documents and Media by @leekelleher in umbraco/Umbraco-CMS#21482 * Tiptap RTE: Adds link (`umbLink`) support to `styleMenu` API by @leekelleher in umbraco/Umbraco-CMS#21494 * Rollback: Add toggle for diff display (closes #18518) by @AndyButland in umbraco/Umbraco-CMS#21426 * Dictionary: Add configurable value search functionality by @Nis-Knowit in umbraco/Umbraco-CMS#21200 ### 🚤 Performance * Performance: Embeds the API of selected extra conditions by @nielslyngsoe in umbraco/Umbraco-CMS#21188 * Performance: Bundle Js Libs by @nielslyngsoe in umbraco/Umbraco-CMS#21187 * Performance: Embed Store API in Manifests to lower number of network request by @madsrasmussen in umbraco/Umbraco-CMS#21191 * Performance: Avoid database lookup in `UserIdKeyResolver` for super-user by @AndyButland in umbraco/Umbraco-CMS#21281 * Performance: Only flush ID/Key map in `ContentCacheRefresher` on content deletion by @AndyButland in umbraco/Umbraco-CMS#21283 * Performance: Optimize refresh of hybrid cache for a document by retrieving draft and published in single query by @AndyButland in umbraco/Umbraco-CMS#21407 * Backoffice Performance: Inline entry point modules to reduce JS chunk count by @madsrasmussen in umbraco/Umbraco-CMS#21380 * HybridCache: Optimize content type change cache rebuild to resolve SQL timeouts by @AndyButland in umbraco/Umbraco-CMS#21207 ... (truncated) ## 17.2.0-rc2 ## What's Changed Since 17.2.0-rc ### 🐛 Bug Fixes * Block Workspace: rename root-tab to 'generic' by @nielslyngsoe in umbraco/Umbraco-CMS#21699 * Block Workspace: Tabs navigation, Cherry-pick from #21672 by @nielslyngsoe in umbraco/Umbraco-CMS#21693 **Full Changelog**: umbraco/Umbraco-CMS@release-17.2.0-rc...release-17.2.0-rc2 ## What's Changed Since the Last Release (17.1.0) ### 🙌 Notable Changes * User group: add description to user group (closes #14986) by @NguyenThuyLan in umbraco/Umbraco-CMS#21057 * Content Types: Root properties by @nielslyngsoe in umbraco/Umbraco-CMS#21500 ### 📦 Dependencies * Storybook: Bumps storybook from 9.0.14 to 10.1.10 by @dependabot[bot] in umbraco/Umbraco-CMS#21208 * Bump qs from 6.14.0 to 6.14.1 in /src/Umbraco.Web.UI.Client in the npm_and_yarn group across 1 directory by @dependabot[bot] in umbraco/Umbraco-CMS#21270 * Bump the npm_and_yarn group across 2 directories with 1 update by @dependabot[bot] in umbraco/Umbraco-CMS#21403 * Dependencies: Bumps login dependencies to latest by @iOvergaard in umbraco/Umbraco-CMS#21539 * Tiptap RTE: Upgraded to latest v3.x by @leekelleher in umbraco/Umbraco-CMS#21493 * Dependencies: Bumps @umbraco-ui/uui to 1.17.0-rc.4 by @iOvergaard in umbraco/Umbraco-CMS#21538 * build(deps): bumps @umbraco-ui/uui to 1.17.0-rc.5 by @iOvergaard in umbraco/Umbraco-CMS#21569 * Dependencies: Update Microsoft packages to 10.0.1 and pin vulnerable transitive dependencies (closes #21122) by @AndyButland in umbraco/Umbraco-CMS#21285 * Dependencies: Bump to latest minor/patch versions by @AndyButland in umbraco/Umbraco-CMS#21540 ### 🚀 New Features * Markdown Conversion: Remove hard dependency on deprecated library and replace with `IMarkdownToHtmlConverter` abstraction (closes #21238 and #19500) by @AndyButland in umbraco/Umbraco-CMS#21242 * UI: Refactor breadcrumb URLs to use Path Constants by @iOvergaard in umbraco/Umbraco-CMS#21179 * Tree Navigation: Add visual indicators for items with restricted access by @iOvergaard in umbraco/Umbraco-CMS#21365 * Recycle Bin: Adds `emptyRecycleBin` collection action kind for Documents and Media by @leekelleher in umbraco/Umbraco-CMS#21482 * Tiptap RTE: Adds link (`umbLink`) support to `styleMenu` API by @leekelleher in umbraco/Umbraco-CMS#21494 * Rollback: Add toggle for diff display (closes #18518) by @AndyButland in umbraco/Umbraco-CMS#21426 * Dictionary: Add configurable value search functionality by @Nis-Knowit in umbraco/Umbraco-CMS#21200 ### 🚤 Performance * Performance: Embeds the API of selected extra conditions by @nielslyngsoe in umbraco/Umbraco-CMS#21188 * Performance: Bundle Js Libs by @nielslyngsoe in umbraco/Umbraco-CMS#21187 * Performance: Embed Store API in Manifests to lower number of network request by @madsrasmussen in umbraco/Umbraco-CMS#21191 * Performance: Avoid database lookup in `UserIdKeyResolver` for super-user by @AndyButland in umbraco/Umbraco-CMS#21281 * Performance: Only flush ID/Key map in `ContentCacheRefresher` on content deletion by @AndyButland in umbraco/Umbraco-CMS#21283 * Performance: Optimize refresh of hybrid cache for a document by retrieving draft and published in single query by @AndyButland in umbraco/Umbraco-CMS#21407 * Backoffice Performance: Inline entry point modules to reduce JS chunk count by @madsrasmussen in umbraco/Umbraco-CMS#21380 * HybridCache: Optimize content type change cache rebuild to resolve SQL timeouts by @AndyButland in umbraco/Umbraco-CMS#21207 * Backoffice Performance: Use import maps to save requests by @nielslyngsoe in umbraco/Umbraco-CMS#21363 * Document URL Cache: Ensure URLs are rebuilt after upgrade and prevent duplicate initialization (closes #21337) by @AndyButland in umbraco/Umbraco-CMS#21379 * Performance: Fix thread safety and optimize cache updates in `PublishStatusService` after content changes by @AndyButland in umbraco/Umbraco-CMS#21415 * Tiptap RTE: Optimize `umb-input-tiptap` initialization and rendering by @leekelleher in umbraco/Umbraco-CMS#21070 * Routing: Add `DocumentUrlAliasService` for optimized URL alias lookups (closes #21383) by @AndyButland in umbraco/Umbraco-CMS#21396 * Performance: Optimize property retrieval and authorization checks in collection views (closes #21367) by @AndyButland in umbraco/Umbraco-CMS#21470 ... (truncated) ## 17.2.0-rc ## What's Changed ### 🙌 Notable Changes * User group: add description to user group (closes #14986) by @NguyenThuyLan in umbraco/Umbraco-CMS#21057 * Content Types: Root properties by @nielslyngsoe in umbraco/Umbraco-CMS#21500 ### 📦 Dependencies * Storybook: Bumps storybook from 9.0.14 to 10.1.10 by @dependabot[bot] in umbraco/Umbraco-CMS#21208 * Bump qs from 6.14.0 to 6.14.1 in /src/Umbraco.Web.UI.Client in the npm_and_yarn group across 1 directory by @dependabot[bot] in umbraco/Umbraco-CMS#21270 * Bump the npm_and_yarn group across 2 directories with 1 update by @dependabot[bot] in umbraco/Umbraco-CMS#21403 * Dependencies: Bumps login dependencies to latest by @iOvergaard in umbraco/Umbraco-CMS#21539 * Tiptap RTE: Upgraded to latest v3.x by @leekelleher in umbraco/Umbraco-CMS#21493 * Dependencies: Bumps @umbraco-ui/uui to 1.17.0-rc.4 by @iOvergaard in umbraco/Umbraco-CMS#21538 * build(deps): bumps @umbraco-ui/uui to 1.17.0-rc.5 by @iOvergaard in umbraco/Umbraco-CMS#21569 * Dependencies: Update Microsoft packages to 10.0.1 and pin vulnerable transitive dependencies (closes #21122) by @AndyButland in umbraco/Umbraco-CMS#21285 * Dependencies: Bump to latest minor/patch versions by @AndyButland in umbraco/Umbraco-CMS#21540 ### 🚀 New Features * Markdown Conversion: Remove hard dependency on deprecated library and replace with `IMarkdownToHtmlConverter` abstraction (closes #21238 and #19500) by @AndyButland in umbraco/Umbraco-CMS#21242 * UI: Refactor breadcrumb URLs to use Path Constants by @iOvergaard in umbraco/Umbraco-CMS#21179 * Tree Navigation: Add visual indicators for items with restricted access by @iOvergaard in umbraco/Umbraco-CMS#21365 * Recycle Bin: Adds `emptyRecycleBin` collection action kind for Documents and Media by @leekelleher in umbraco/Umbraco-CMS#21482 * Tiptap RTE: Adds link (`umbLink`) support to `styleMenu` API by @leekelleher in umbraco/Umbraco-CMS#21494 * Rollback: Add toggle for diff display (closes #18518) by @AndyButland in umbraco/Umbraco-CMS#21426 * Dictionary: Add configurable value search functionality by @Nis-Knowit in umbraco/Umbraco-CMS#21200 ### 🚤 Performance * Performance: Embeds the API of selected extra conditions by @nielslyngsoe in umbraco/Umbraco-CMS#21188 * Performance: Bundle Js Libs by @nielslyngsoe in umbraco/Umbraco-CMS#21187 * Performance: Embed Store API in Manifests to lower number of network request by @madsrasmussen in umbraco/Umbraco-CMS#21191 * Performance: Avoid database lookup in `UserIdKeyResolver` for super-user by @AndyButland in umbraco/Umbraco-CMS#21281 * Performance: Only flush ID/Key map in `ContentCacheRefresher` on content deletion by @AndyButland in umbraco/Umbraco-CMS#21283 * Performance: Optimize refresh of hybrid cache for a document by retrieving draft and published in single query by @AndyButland in umbraco/Umbraco-CMS#21407 * Backoffice Performance: Inline entry point modules to reduce JS chunk count by @madsrasmussen in umbraco/Umbraco-CMS#21380 * HybridCache: Optimize content type change cache rebuild to resolve SQL timeouts by @AndyButland in umbraco/Umbraco-CMS#21207 * Backoffice Performance: Use import maps to save requests by @nielslyngsoe in umbraco/Umbraco-CMS#21363 * Document URL Cache: Ensure URLs are rebuilt after upgrade and prevent duplicate initialization (closes #21337) by @AndyButland in umbraco/Umbraco-CMS#21379 * Performance: Fix thread safety and optimize cache updates in `PublishStatusService` after content changes by @AndyButland in umbraco/Umbraco-CMS#21415 * Tiptap RTE: Optimize `umb-input-tiptap` initialization and rendering by @leekelleher in umbraco/Umbraco-CMS#21070 * Routing: Add `DocumentUrlAliasService` for optimized URL alias lookups (closes #21383) by @AndyButland in umbraco/Umbraco-CMS#21396 * Performance: Optimize property retrieval and authorization checks in collection views (closes #21367) by @AndyButland in umbraco/Umbraco-CMS#21470 ### 🧪 Testing * E2E: QA Replaced unreliable Thread.Sleep(500) with a counter/gate pattern that ensures both transactions are initialized before releasing them to compete for locks by @andr317c in umbraco/Umbraco-CMS#21165 * E2E QA: Updated integration test that was missing directory setup by @andr317c in umbraco/Umbraco-CMS#21167 * E2E: QA Added acceptance tests for removing a not-found content picker by @nhudinh0309 in umbraco/Umbraco-CMS#21177 * E2E: QA Fixed failing tests for the current user profile by @nhudinh0309 in umbraco/Umbraco-CMS#21214 * Upgrade MSW from 1.3.5 to 2.12.4 by @madsrasmussen in umbraco/Umbraco-CMS#21096 * E2E: QA Added acceptance tests for rendering content with invariant blocks by @nhudinh0309 in umbraco/Umbraco-CMS#21180 * E2E: QA Added acceptance tests for content delivery API by @nhudinh0309 in umbraco/Umbraco-CMS#21095 ... (truncated) Commits viewable in [compare view](umbraco/Umbraco-CMS@release-17.1.0...release-17.2.0). </details> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Summary
This PR addresses SQL timeout issues that can occur when saving document types with large amounts of existing content. The issue manifests as database lock contention during the cache rebuild process.
Changes included:
ContentCacheNodeobjects when only keys are neededGetDocumentKeysWithPublishedStatusfor documentsGetMediaKeysByContentTypeKeysfor mediaDocumentCacheService,MediaCacheService, andMemberCacheServiceto use these optimized methodsIContent/IMedia/IMemberobjects that we don't fully need, and replacing with dedicated SQL to get just the data we require.DatabaseCacheRepository.Rebuild()covering documents, media, and members including composition scenarios, to verify that the optimizations don't change the behaviour.Performance impact:
I've been testing with a database containing around 70,000 nodes in two languages, that second-line support use as a sample database for a large site. There's one document type that almost every node depends on, so changing this causes the database cache to be rebuilt for all practically all the content.
The other benefit is that I'm no longer seeing locking issues and timeouts as were previously found (with both the current and partial implementation). To get these to run to completion with the older implementations, I often needed to disable distributed jobs and examine indexing.
Testing
I've added various integration tests to verify that the optimisation in behaviour doesn't impact the functionality. These all pass on
main(with the one exception of property order in the JSON serialization, which I don't believe matters).Manual checks would include making sure on save of a document type (e.g. to remove a property) that an existing rendered document continues to have existing properties displayed and the removed one not.