Closed garpunkal closed 5 years ago
@garpunkal I've not been able to reproduce this issue so far.
Can I check if you have recompiled your code against the upgrade Ditto assembly? or was it a drop in the /bin folder update? (just thinking if there's a scenario I'm not considering here)
This has happened to me too. Refreshing the page usually seems to fix it (though a coworker mentioned he needed to restart IIS). Here's the processor it originates from (at least, this was the latest one):
// Namespaces.
using Archetype.Models;
using Contexts;
using Our.Umbraco.Ditto;
using Rhythm.Umbraco.Archetype;
using System;
using System.Linq;
using Types;
using Utilities;
/// <summary>
/// This processor returns a collection of links.
/// </summary>
[AttributeUsage(validOn: AttributeTargets.Property, AllowMultiple = true)]
[DittoProcessorMetaData(ContextType = typeof(ContentDataContext))]
public class LinksAttribute : UmbracoPropertyAttribute
{
#region Methods
/// <summary>
/// Returns the links.
/// </summary>
/// <returns>
/// The links.
/// </returns>
public override object ProcessValue()
{
var casted = Context as ContentDataContext;
var currentPage = casted?.Page;
var currentNode = casted?.DataContent;
var archetype = Value as ArchetypeModel;
var fieldsets = archetype?.EnabledFieldsets();
if (fieldsets == null)
{
return Enumerable.Empty<Link>();
}
var links = fieldsets.Select(x => LinkUtility.GetLink(x, currentPage, currentNode)).ToList();
return links;
}
#endregion
}
And here's a stack trace (with some details modified to protect the innocent):
Thanks @Nicholas-Westby.
I'm curious whether your code was recompiled against the upgrade Ditto assembly? or was it a drop in the /bin folder update?
Hi @leekelleher,
I'm not sure what you mean exactly, but I have a general idea. Ditto is installed with NuGet into a single project in my Visual Studio solution (which contains two projects, one for the web application and one for all the C# code). When I view the NuGet packages installed for the entire solution and filter by "ditto", this is what shows up:
Does that answer your question?
Also, it's Ditto 0.12.0 (in case you were wondering about the version number).
Cool, thanks @Nicholas-Westby, I can assume your code got recompiled against upgraded Ditto.
Hmmm, I've still not been able to reproduce this on my local environment yet. I'll investigate further.
Thanks, @leekelleher. FYI, I've only seen this error a few times. Usually on my local when developing in Visual Studio, IIRC. Though my coworker just saw it on production with IIS.
We're also getting this error since upgrading to 0.12.0.
It's random, but usually happens on application start / on the first request to the application.
Sometimes it resolves itself, other times not.
Here's the relevant part of the stack trace:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type)
at Our.Umbraco.Ditto.DittoProcessorRegistry.<GetPostProcessorAttributes>d__14.MoveNext()
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at Our.Umbraco.Ditto.DittoTypeInfo.Create(Type type) at Our.Umbraco.Ditto.DittoTypeInfoCache.GetOrAdd(Type type)
at Our.Umbraco.Ditto.PublishedContentExtensions.As(IPublishedContent content, Type type, CultureInfo culture, Object instance, IEnumerable`1 processorContexts, Action`1 onConverting, Action`1 onConverted, DittoChainContext chainContext)
at Our.Umbraco.Ditto.PublishedContentExtensions.As[T](IPublishedContent content, CultureInfo culture, T instance, IEnumerable`1 processorContexts, Action`1 onConverting, Action`1 onConverted, DittoChainContext chainContext)
Let me know if you require more information.
Cheers, Dan.
I still haven't been able to reproduce this issue yet, but working through the codebase, I think I may have identified the bug. I've patched it up in 44129a6344da81433f9438013d1018726c8135eb. If one of you could give it a test, that'd be much appreciated.
Umbraco & NuGet packages are available on the CI build page: https://ci.appveyor.com/project/UMCO/umbraco-ditto/build/0.12.1.20/artifacts
If all good, I'll get a patch release out. Thanks!
Is it possible you could push this change to a pre-release version on NuGet?
@drachele You could try the MyGet feed (it contains the latest builds): https://www.myget.org/feed/umbraco-packages/package/nuget/Our.Umbraco.Ditto
Testing this will be difficult, as the issue only seems to happen very seldomly. I suppose I could test it by making sure it doesn't break anything.
Hi @leekelleher
I've pulled the 0.12.1-alpha-000021 version into our site and it all seems to work without any issues.
Not seeing that error occur anywhere either which is a good sign!
When do you think you could release 0.12.1 to the main NuGet feed?
Cheers, Dan.
Thanks for the feedback @drachele! We've been pretty blind on this issue, (since I still haven't been able to reproduce it).
We'll look schedule a release of v0.12.1 soon, (probably next week, as my client workload is heavy this week).
Closing this ticket off. v0.12.1 has been released.
If this issue rears its head in future, let's open a new ticket.
Great, thanks @leekelleher , will upgrade now and let you know how it goes...
We just applied the 0.12.1-alpha-000021 patch to our QA site and we are still getting this issue. We are going to try with v0.12.1 now and will report back.
Thanks @seb-rogers. Although v0.12.1 is the same codebase as the v0.12.1-alpha-000021 build, so I expect you'll get the same result.
Let us know either way. I'm pretty much flying blind on this one (since not being able to reproduce it).
After releasing v0.12.1 the issue is still there, however we have narrowed it down a little. It is only happening on first load of a template after a release and when that template is loaded in 2 separate browsers at the same time.
Thanks @seb-rogers, useful info. I hadn't considered the concurrency issue (I briefly chatted with @tristanjthompson about it last night). I've been able to reproduce the bug now.
Re-opening this ticket.
@tristanjthompson @seb-rogers I've added a patch, see PR #241 for details. I was able to reproduce the bug before, since my patch, it no longer throws the error.
Ship it! 😃
@drachele You say it like it's a 2 minute job, haha 😆 There's a fair amount of love that goes into every release, takes time.
It helps me more if someone could verify that the fix works for them: https://ci.appveyor.com/project/UMCO/umbraco-ditto/build/0.12.2.29/artifacts ❤️ 👍
If you could push it to the MyGet feed, I can pull it into my site and try and reproduce (again).
@drachele The MyGet feed only has packages that are built from the 'develop' branch, my patch is in a PR, (since I'm not 100% that my code isn't gonna break something). BUT the PR is build and the AppVeyor CI does support a custom NuGet feed, if that works for you? Here it is... https://ci.appveyor.com/nuget/umbraco-ditto-qq37it3txy7g
@leekelleher Okay great, will give that a go and report back shortly.
@leekelleher I've pulled your patched version in our (rather large and complex) site.
Site is working fine, and I'm unable to reproduce the issue using the steps outlined above.
Things I've done to try and reproduce:
Is there anything else you would like me to try to reproduce the issue?
@drachele Cool, thanks for testing it out! Those are the scenarios that I was able to reproduce the original bug with, not sure what else to try, so sounds fine to me. Cheers.
Spoke with @tristanjthompson (via Slack) and his team are testing it out too.
Thanks @leekelleher! The way we could easily replicate is to clean the solution, do a build and then open the same page in our site concurrently in several tabs. With the patch applied, I'm no longer getting the error! However, if I have debug=true
in my web.config, I'm getting a couple of different errors on initial page load - sometimes to do with MiniProfiler
, but one to do with converting;
Unable to cast object of type 'Dyson.Careers.Models.CallToActionModel[]' to type 'System.Collections.Generic.IEnumerable`1[Umbraco.Core.Models.IPublishedContent]'.
That particular property/Ditto attribute is on a model class which is attached the main view model.
However, with debug=false
(which is what it will be when it's live), I never get any exceptions.
Hmm, only getting the MiniProfiler error in there now - maybe the casting is a red herring and to do with our specific implementation. I'm not that worried about it as it won't happen on live either way. I'll have a look into whether I can track down where the MiniProfiler error is coming from
Sorry to push and I know the answer is likely "when I have a free second" but any idea when this will be released ?
@SimonHartfield I'm back from holiday now, but the follow up (from others) on this patch was that it caused errors with MiniProfiler. Are you - or others - experiencing this too? (I assume not)
@leekelleher - I had this when I used the latest patch, however, with debug mode disabled (as it usually is on production) it doesn't happen. Personally, I'd say that the patch version is better than the current one as it shouldn't cause issues on production (assuming debug is switched off) and will only occur in dev during startup under certain circumstances (which is what's happening at the moment)...so without going to the effort of refactoring all the usages of MiniProfiler to be threadsafe (which is what I assume the issue is!), this might be a good first step to resolve the problem if that's the only thing people have noticed? What does everyone else think?
Thanks @tristanjthompson.
I have been considering removing all the MiniProfiler timers from Ditto, at one time I thought they were a big performance bottleneck, but could never prove it.
I guess an approach is to do a point release with this patch, and prepare for any MiniProfiler issues? If that's good with everyone else on this ticket? (Since I can't reproduce the issue myself)
Heads up that I'm going to release v0.12.2 today.
I'm not 100% convinced that this fixes the underlying concurrency issue, but I'm unable to reproduce it on my test sites, so it's better than it was. The reason I flag this is that if there are any issues (specifically for anyone involved in this thread), then I'd really appreciate your collaboration on working towards a fix. Thanks!
Having been suffering with this exact issue, I can confirm that having updated to 0.12.2 has fixed it for me.
Again, I was able to reproduce by restarting my app and loading both sites in a multi site setup in separate tabs simultaneously.
Thanks @leekelleher !
Hi,
We've started to see this exception being raised on application startup and first render. If you reload the browser window, the exception doesn't trigger:
Exception / StackTrace
``` at Our.Umbraco.Ditto.DittoProcessorAttribute..ctor() at Jaywing.Web.Models.Processors.UrlOrRedirectUrlAttribute..ctor(Boolean absoluteUrl) in \Models\Processors\UrlOrRedirectUrlAttribute.cs:line 11 at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs) at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType) at System.Attribute.InternalGetCustomAttributes(PropertyInfo element, Type type, Boolean inherit) at Our.Umbraco.Ditto.DittoTypeInfo.Create(Type type) at Our.Umbraco.Ditto.DittoTypeInfoCache.GetOrAdd(Type type) at Our.Umbraco.Ditto.PublishedContentExtensions.As(IPublishedContent content, Type type, CultureInfo culture, Object instance, IEnumerable1 processorContexts, Action1 onConverting, Action1 onConverted, DittoChainContext chainContext) at Our.Umbraco.Ditto.RecursiveDittoAttribute.ProcessValue() at Our.Umbraco.Ditto.DittoCacheableAttribute.GetCacheItem[TOuputType](DittoCacheContext cacheContext, Func1 refresher) at Our.Umbraco.Ditto.PublishedContentExtensions.DoGetProcessedValue(IPublishedContent content, DittoTypePropertyInfo mappableProperty, DittoProcessorContext baseProcessorContext, DittoChainContext chainContext) at Our.Umbraco.Ditto.PublishedContentExtensions.GetProcessedValue(IPublishedContent content, CultureInfo culture, DittoTypeInfo config, DittoTypePropertyInfo mappableProperty, Object instance, DittoChainContext chainContext) at Our.Umbraco.Ditto.PublishedContentExtensions.ConvertContent(IPublishedContent content, DittoTypeInfo config, CultureInfo culture, Object instance, Action1 onConverting, Action1 onConverted, DittoChainContext chainContext) at Our.Umbraco.Ditto.PublishedContentExtensions.As(IPublishedContent content, Type type, CultureInfo culture, Object instance, IEnumerable1 processorContexts, Action1 onConverting, Action1 onConverted, DittoChainContext chainContext) at Our.Umbraco.Ditto.PublishedContentExtensions.As[T](IPublishedContent content, CultureInfo culture, T instance, IEnumerable1 processorContexts, Action1 onConverting, Action1 onConverted, DittoChainContext chainContext) at Our.Umbraco.Ditto.DittoViewModel1.get_View() at ASP._Page_Views_Partials_Header_cshtml.Execute() in Views\Partials\Header.cshtml:line 4 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) at Umbraco.Web.CacheHelperExtensions.CachedPartialView(CacheHelper cacheHelper, HtmlHelper htmlHelper, String partialViewName, Object model, Int32 cachedSeconds, String cacheKey, ViewDataDictionary viewData) at Umbraco.Web.HtmlHelperRenderExtensions.CachedPartial(HtmlHelper htmlHelper, String partialViewName, Object model, Int32 cachedSeconds, Boolean cacheByPage, Boolean cacheByMember, ViewDataDictionary viewData, Func3 contextualKeyBuilder) at ASP._Page_Views_Master_cshtml.Execute() in Views\Master.cshtml:line 33 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.WebPages.WebPageBase.<>c__DisplayClass3.I'm using a very simple processor:
Any help would be great.