-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
XLocalizer.DB database concurrency problem #28
Comments
I have no evidence, but I have a sneaky feeling it might be something to do with: https://github.com/LazZiya/XLocalizer.DB/blob/master/XLocalizer.DB/EF/EFDbResourceProvider.cs#L41 var culture = CultureInfo.CurrentCulture.Name; I normally use |
Hi @morgrowe I'm fine thanks, hope you are fine too :) Before I deep dive into the details, do you have below settings as described in XLocalizer.DB docs:
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")),
ServiceLifetime.Transient,
ServiceLifetime.Transient); tldr;As you already know, the DbContext is not thread safe, and it is registered as a scoped service. On the other hand, all localization services Since we cannot change the life cycle of localization services, the only solution was to register the There are some drawback of this implementation, but it should not affect Best practicesHere you can find more about Best, |
Hi Ziya I'm very good thanks. Glad to hear you're well, too. Here's the registration of my var connectionString = "MyConnectionString";
var migrationsAssembly = typeof(ManagerDbContext).Assembly.FullName;
services.AddDbContext<ManagerDbContext>(options =>
{
options.UseSqlServer(connectionString, b => b.MigrationsAssembly(migrationsAssembly));
}
, ServiceLifetime.Transient
ServiceLifetime.Transient); And here are my .AddXDbLocalizer<ManagerDbContext, DummyTranslator, AppLocalizationResource>((opts) =>
{
opts.AutoTranslate = false;
opts.LocalizeDefaultCulture = true;
}); I think I was using Thanks for the link to the pros and cons of using a Transient Your suggestion of having two DbContexts is a welcome one. Despite having multiple Thanks |
So For the issue, it will take some time, I can't promise to bring a solution in a short time, but the above recommendations would help to avoid the problem :) |
Ok, I will enable Many thanks for agreeing to launch an investigation. In the meantime, I'll share any exceptions relating to this issue with you should they pop up again over the next few days. :) Thank you very much |
Thank you too for your cooperation :) Best, |
Hi Ziya I didn't have much time to do development this week, but I did get two exceptions relating to this issue yesterday afternoon. They happened a couple of milliseconds after each other like the other ones. These occurred after setting Cheers |
Hi Ziya Hope you're well. I can't believe almost a year has passed since I brought this up. We're still getting the exception (even in Release mode running on IIS). Did you have a chance to look into this? Thanks |
Hi Morgan I am fine thanks, hope you also fine. Yea time is passing fast! also projects are growing rapidly... Any PR are welcome :) Best regards, |
Hi Ziya Ok, no worries. I had a look into this a couple of months ago, but I couldn't find a solution. I will have another look. If I fix it, I'll do a pull request. Thanks |
I have the same problem when using Arabic! |
Hi Ziya
Hope you're well.
I've been having intermittent issues for the past couple of months with EF complaining about two instances of a DbContext being used at the same time. I recently looked at the logs to try and figure out what's going on and it seems in all cases XLocalizer.DB is involved. The exception I'm referring to is:
I may be misinterpreting the stack trace, but the exception seems to occur within:
every time I see it in my logs.
I've attached a couple of stack traces in case that helps. It's worth noting that this doesn't happen all the time. It's hard to reproduce, but it seems to happen when I excessively refresh a page that uses the
localize-content
tag helper somewhere on it.If I can provide anymore information or provide additional stack traces, please let me know.
Thanks
Morgan
In application 1:
st-1.txt
st-2.txt
st-3.txt
st-4.txt
st-5.txt
st-6.txt
In application 2:
other-app-st-1.txt
The text was updated successfully, but these errors were encountered: