Scheduled publish fails when multiple pages are published - Umbraco 8.6.1
See original GitHub issueScheduled publishing can fail when publishing multiple pages at the same time.
Umbraco version
I am seeing this issue on Umbraco version: 8.6.1
Reproduction
If you set multiple pages (in testing approx. 10-20 seems do it) to have the same scheduled publish date, then when that date arrives not all items will be published. and scope errors (below) will be reported in the log.
Specifics
It looks like its an issue with the Scope while running in a background task, but i am at a loss to see what it should be doing 😞
Steps to reproduce
- New Umbraco Install - (With standard starter key, SQLCE DB)
- Schedule the individual pages in the starter kit to publish at the same time (takes about 5-10 mins to do, so pick a time-date that gives you time to go through the site).
- Wait for publish
- Look through logs. should see the errors below:
Expected result
All pages should be published.
Actual result
Some pages are published, but the background process stops at some point with an error:
System.AggregateException: Exceptions were thrown by listed actions. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Umbraco.Core.Scoping.Scope.<>c__DisplayClass71_0.<RobustExit>b__2() in D:\a\1\s\src\Umbraco.Core\Scoping\Scope.cs:line 437
at Umbraco.Core.Scoping.Scope.TryFinally(Int32 index, Action[] actions) in D:\a\1\s\src\Umbraco.Core\Scoping\Scope.cs:line 472
at Umbraco.Core.Scoping.Scope.TryFinally(Int32 index, Action[] actions) in D:\a\1\s\src\Umbraco.Core\Scoping\Scope.cs:line 476
at Umbraco.Core.Scoping.Scope.TryFinally(Int32 index, Action[] actions) in D:\a\1\s\src\Umbraco.Core\Scoping\Scope.cs:line 476
at Umbraco.Core.Scoping.Scope.RobustExit(Boolean completed, Boolean onException) in D:\a\1\s\src\Umbraco.Core\Scoping\Scope.cs:line 420
at Umbraco.Core.Scoping.Scope.DisposeLastScope() in D:\a\1\s\src\Umbraco.Core\Scoping\Scope.cs:line 400
at Umbraco.Core.Scoping.Scope.Dispose() in D:\a\1\s\src\Umbraco.Core\Scoping\Scope.cs:line 363
at Umbraco.Core.Services.Implement.UserService.GetUserById(Int32 id) in D:\a\1\s\src\Umbraco.Core\Services\Implement\UserService.cs:line 714
at Umbraco.Core.Services.Implement.UserService.GetProfileById(Int32 id) in D:\a\1\s\src\Umbraco.Core\Services\Implement\UserService.cs:line 670
at Umbraco.Core.ContentExtensions.GetWriterProfile(IContent content, IUserService userService) in D:\a\1\s\src\Umbraco.Core\ContentExtensions.cs:line 262
at Umbraco.Examine.ContentValueSetBuilder.<GetValueSets>d__3.MoveNext() in D:\a\1\s\src\Umbraco.Examine\ContentValueSetBuilder.cs:line 43
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.GroupedEnumerable`3.GetEnumerator()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
at Umbraco.Examine.UmbracoContentIndex.PerformIndexItems(IEnumerable`1 values, Action`1 onComplete) in D:\a\1\s\src\Umbraco.Examine\UmbracoContentIndex.cs:line 87
at Examine.Providers.BaseIndexProvider.IndexItems(IEnumerable`1 values) in C:\projects\examine-qvx04\src\Examine\Providers\BaseIndexProvider.cs:line 76
N.B for the above this error goes through the UserService - but I have also seen it in the PublicAccess service - I think DisposeLastScope is the issue?
before this error - there will usually be two scope warnings…
Missed "ScopeContext" Object "4c4688a1"
e.g
–
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Yep! that is exactly why this is happening. It’s the exact same issue. Any background task that is performing any DB interaction with the services must use an explicit Scope, else an ambient CallContext scope will be used which will have problems if there is multi-threading going on in that CallContext.
In this case its while examine is indexing things and it calls into the ValueSetBuilder. In cases where the user’s cache is expired it will make a DB query to get the user but in certain situations this will cause problems because the value set builder wasn’t using an explicit Scope. This is fixed in https://github.com/umbraco/Umbraco-CMS/pull/7994 along with a small perf enhancement.
Hello I’m also facing this issue when content is published and replicated to front end instances. Can it be resolved if we rebuild examine indexes?