-
-
Notifications
You must be signed in to change notification settings - Fork 835
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
AnyConcreteTypeNotAlreadyRegisteredSource concurrency issue #1073
Comments
What's the use case for creating so many containers? Standard apps have just one. Can this be demonstrated with a more common use case? |
Also, we need to see TestFoo. The stack trace here doesn't come from the repro. |
As I can see this issue occurs because
Thank you for the fast repsonse. It is just a test example. Because this issue is a concurrent issue it is not occurs regularly. So I invoke the same code multiple times to reproduce the issue.
It is available in the first message:
|
Sorry. I updated it. |
I can suggest the following solution. We can use
|
Ok, we'll have to look into this, reproduce with your code, and check out the fix. Unfortunately you've caught us in the middle of updating things post-Autofac-5.0 release (eg the other 20+ integration packages) so it'll be a bit before we get here. If you'd like it faster, you could...
|
@tillig Thank you. Actually, I'm using 4.9.4 now. I read this document: https://github.com/autofac/Autofac/blob/develop/CONTRIBUTING.md And it looks like I can create PR to the develop branch only. So this fix will be available in 5.x only. Am I correct? |
That's correct. We don't back-port fixes or features. |
Ok. Thank you. It looks like most of the logic was migrated from |
@MaratFaskhiev Could you post 'before' and 'after' numbers here from the |
@ilabutin Here it is:
Before: After:
Before: After: |
Reopening issue after noticing test failure during CI build. |
We may have to return the original and safest locking approach. See this comment for benchmarks. |
That sucks since we get nailed on perf constantly, but I don't immediately see a better way. I come up with random, complicated stuff like keeping a separate "count" of the implementations that could be used instead of the Any call but then I realized that whole check in that line with the Any needs to be atomic, which is what locks do. Darn. |
…Info until the implementations changes
…nInfo until the implementations changes
…nInfo until the implementations changes
I was wondering why |
I can see what @weelink has done in the PR but worry that we will just keep moving the threading problem from one place to another, leaving behind a trail of obscure fixes that could be easily broken. The PR with the caching may be good for performance but from a safety perspective I think the original locking needs to come back. |
Hello,
Please check the code below:
It fails with the following exception:
I checked Autofac 4.9.4. And the same issue occurs for the 5.0.0.
The text was updated successfully, but these errors were encountered: