Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition in FillerManager.cs GetFiller(PropertyInfo propertyInfo) #132

Open
sandimschuh opened this issue Nov 27, 2017 · 4 comments
Open

Comments

@sandimschuh
Copy link

When executing in parallel (unit testing) I get following Exception:

Result StackTrace:
----- Inner Stack Trace #1 (System.ArgumentException) -----
at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object key)
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
at GenFu.FillerManager.GetFiller(PropertyInfo propertyInfo) in C:\james\code\GenFu\src\GenFu\FillerManager.cs:line 165
at GenFu.GenFu.SetPropertyValue(Object instance, PropertyInfo property) in C:\james\code\GenFu\src\GenFu\GenFu.cs:line 111
at GenFu.GenFu.New(Object instance) in C:\james\code\GenFu\src\GenFu\GenFu.cs:line 53
at GenFu.GenFu.BuildList(Type type, Int32 itemCount) in C:\james\code\GenFu\src\GenFu\GenFu.cs:line 101
at GenFu.GenFu.ListOf[T](Int32 itemCount) in C:\james\code\GenFu\src\GenFu\GenFu.cs:line 89
----- Inner Stack Trace #2 (Xunit.Sdk.TestClassException) -----
Result Message:
System.AggregateException : One or more errors occurred. (An item with the same key has already been added. Key: System.Nullable1[System.Int64]) ---- System.ArgumentException : An item with the same key has already been added. Key: System.Nullable1[System.Int64]

@sandimschuh
Copy link
Author

Fixed this temporarily on my site by wrapping entire body of GetFilter() into a lock(){...} block.

@dpaquette
Copy link
Collaborator

We used to get this on the GenFu unit tests. Our workaround for the time being was to disable parallel tests

@marcoregueira
Copy link
Contributor

marcoregueira commented Nov 30, 2017

Please check PR #133.

@marcoregueira
Copy link
Contributor

Hi @dpaquette. I've got some tests failing randomly because of the problem listed in this issue. I'd rather prefer not disabling the parallel tests. Running them in parallel increases my confidence in the whole system and is more performant.

The provided PR #133 solves this issue and is more performant than just a lock because it uses reader and writer locks. Had you the opportunity to check it out?

@lvmajor lvmajor mentioned this issue Jan 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants