Skip to content

sporadic event which corrupts ProcessStorage #210

@nossssssss

Description

@nossssssss

We started getting issue where as a result of some event RequiredIf validators start failing for all users due to underlying exception in ExpressiveAnnotations.MvcUnobtrusive.Caching.ProcessStorage.GetOrAdd. What triggers this is not clear at the moment.
The only way to get out of this issue is by resetting Application Pool which will reset ExpressiveAnnotations cache.
Exception is this
Collection was modified; enumeration operation may not execute.
and below is a full stack

Here is how RequiredIf attribute looks like
[RequiredIf("InspectionStatusCode == CompanyA.Model.Notification.INSPECTION_STATUS_CODE1 || InspectionStatusCode == CompanyA.Model.Notification.INSPECTION_STATUS_CODE2 || InspectionStatusCode == CompanyA.Model.Notification.INSPECTION_STATUS_CODE3", ErrorMessage = "Inspection Date is required.")]

STATUS_CODE1, STATUS_CODE2, STATUS_CODE3 are string constants

---------------
Type : System.ComponentModel.DataAnnotations.ValidationException, System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Message : RequiredIfValidator: validation applied to InspectionDate field failed.
Source : ExpressiveAnnotations.MvcUnobtrusive
Help link : 
ValidationAttribute : 
ValidationResult : RequiredIfValidator: validation applied to InspectionDate field failed.
Value : 
Data : System.Collections.ListDictionaryInternal
TargetSite : Void .ctor(System.Web.Mvc.ModelMetadata, System.Web.Mvc.ControllerContext, T)
HResult : -2146233088
Stack Trace :    at ExpressiveAnnotations.MvcUnobtrusive.Validators.ExpressiveValidator`1..ctor(ModelMetadata metadata, ControllerContext context, T attribute)
   at ExpressiveAnnotations.MvcUnobtrusive.Validators.RequiredIfValidator..ctor(ModelMetadata metadata, ControllerContext context, RequiredIfAttribute attribute)

	Inner Exception
	---------------
	Type : System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
	Message : Collection was modified; enumeration operation may not execute.
	Source : mscorlib
	Help link : 
	Data : System.Collections.ListDictionaryInternal
	TargetSite : Void ThrowInvalidOperationException(System.ExceptionResource)
	HResult : -2146233079
	Stack Trace :    at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
	   at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()
	   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
	   at ExpressiveAnnotations.Analysis.Parser.GetConsts()
	   at ExpressiveAnnotations.MvcUnobtrusive.Validators.ExpressiveValidator`1.<>c__DisplayClass0_1.<.ctor>b__1(Parser parser)
	   at ExpressiveAnnotations.Attributes.ExpressiveAttribute.Compile(Type validationContextType, Action`1 action, Boolean force)
	   at ExpressiveAnnotations.MvcUnobtrusive.Validators.ExpressiveValidator`1.<>c__DisplayClass0_0.<.ctor>b__0(String _)
	   at ExpressiveAnnotations.MvcUnobtrusive.Caching.ProcessStorage`2.<>c__DisplayClass1_1.<GetOrAdd>b__1()
	   at System.Lazy`1.CreateValue()
	--- End of stack trace from previous location where exception was thrown ---
	   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
	   at System.Lazy`1.get_Value()
	   at ExpressiveAnnotations.MvcUnobtrusive.Caching.ProcessStorage`2.GetOrAdd(TKey key, Func`2 valueFactory)
	   at ExpressiveAnnotations.MvcUnobtrusive.Validators.ExpressiveValidator`1..ctor(ModelMetadata metadata, ControllerContext context, T attribute)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions