ERROR: A concurrent update was performed on this collection and corrupted its state

Hi All,

We have recently upgraded from U13 to U17. Overall, our upgrade has been successful, but we are seeing intermittent issues where our public Umbraco site fails on all requests after what I can only assume is a race condition.

What we are seeing is that immediately after an app pool refresh, or app pool restart we occasionally see a concurrent update error, and once we see it once, then all subsequent requests will show the same error, until we refresh/restart the app pool again.

I don’t even know where to start with debugging into this, partly because it’s intermittent, and partly because I can’t tell what collection is becoming corrupt… But mainly I guess because I don’t know what I’m doing…

The full exception is as below:

An unhandled exception was thrown by the application.“,”@l":“Error”,“@x”:“System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection’s state is no longer correct.
at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.LanguageRepository.GetDefault()
at Umbraco.Cms.Core.Services.LanguageService.GetDefaultIsoCodeAsync()
at Umbraco.Cms.Core.Services.LocalizationService.GetDefaultLanguageIsoCode()
at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<b__0>d.MoveNext()
— End of stack trace from previous location —
at Umbraco.Cms.Web.Common.Middleware.PreviewAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<b__0>d.MoveNext()
— End of stack trace from previous location —
at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestLoggingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<b__0>d.MoveNext()
— End of stack trace from previous location —
at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
at Umbraco.Cms.Api.Management.Middleware.BackOfficeAuthorizationInitializationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<b__0>d.MoveNext()
— End of stack trace from previous location —
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)
at ILMAG.Website.Middleware.LogSessionId.InvokeAsync(HttpContext context) in D:\a\1\s\ILMAG.Website\Middleware\LogSessionId.cs:line 27
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at ILMAG.Website.Middleware.RedirectInTest.InvokeAsync(HttpContext context) in D:\a\1\s\ILMAG.Website\Middleware\RedirectInTest.cs:line 28
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
at NWebsec.AspNetCore.Middleware.Middleware.CspMiddleware.Invoke(HttpContext context)
at NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.Invoke(HttpContext context)
at NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()”,“@tr”:“1782bffb115bd97f3e92ae53460c8173”,“@sp”:“c920d62a6c7b60c3”,“ConnectionId”:“3098476548731183075”,“TraceIdentifier”:“40001fe4-0001-2b00-b63f-84710c7967bb”,“EventId”:{“Id”:2,“Name”:“ApplicationError”},“SourceContext”:“Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer”,“RequestId”:“40001fe4-0001-2b00-b63f-84710c7967bb”,“RequestPath”:“/meet-and-greet/gatwick/”,“ProcessId”:15312,“ProcessName”:“w3wp”,“ThreadId”:19,“ApplicationId”:“07342b4f13ccc4e43c455af8d8ea7b955f43e454”,“MachineName”:“WEB2-EC2AMAZ-HP”,“Log4NetLevel”:“ERROR”}

Please let me know if I can provide any further info that might make it easier to track this down…

Thanks,

Chris

Hi Chris, I’ve been getting the same issue with a fresh U17 site. I’ve also had the same issue but with different error messages. Hope someone is able to find the issue and release a fix.

What version of 17 ? This looks like this previously reported issue which advised 17.2 may fix

Hi Richard,

I upgraded to 17.2 and the issue has not resurfaced since. It’s hard to say with 100% confidence since I wasn’t able to reproduce the issue on demand, but I’d suggest trying the 17.2.x upgrade

Cheers,

Chris