Base solution for your next web application

Activities of "rickfrankel"

Hi,

We run in a load balanced environment for our app servers in production. PeriodicBackgroundWorkers don't appear to play nicely in this environment.

As they are in memory scheduled jobs they clash with each other quite often.

For example we get this error in our production logs a lot. We also re-wrote the ExpiredAuditLogDeleterWorker to be a hangfirejob.

Is there any recommendation or plans on how we can easily remove/convert these background jobs into hangfire jobs which will only run on one server and not have concurrency issues like most of the non hangfire run periodic workers do?

Thanks Rick

2024-05-15T08:35:27.585+10:00 - (null) - (null) - b1c4f22152a4 - Abp.Authorization.Users.UserTokenExpirationWorker2[[XXXX.MultiTenancy.Tenant, XXXX.Core, Version=13.1.0.1574, Culture=neutral, PublicKeyToken=null],[XXXX.Authorization.Users.User, XXXX.Core, Version=13.1.0.1574, Culture=neutral, PublicKeyToken=null]] - Abp.Domain.Uow.AbpDbConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions. ---> Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions. at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyException(RelationalDataReader reader, Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected) at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.Consume(RelationalDataReader reader) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable1 commandBatches, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList1 entriesToSave) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(StateManager stateManager, Boolean acceptAllChangesOnSuccess) at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges() --- End of inner exception stack trace --- at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges() at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChanges() at Abp.Domain.Uow.UnitOfWorkBase.Complete() at Abp.Authorization.Users.UserTokenExpirationWorker2.DoWork() at Abp.Threading.BackgroundWorkers.PeriodicBackgroundWorkerBase.Timer_Elapsed(Object sender, EventArgs e) Abp.Domain.Uow.AbpDbConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions. ---> Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions. at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyException(RelationalDataReader reader, Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected) at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.Consume(RelationalDataReader reader) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable1 commandBatches, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList1 entriesToSave) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(StateManager stateManager, Boolean acceptAllChangesOnSuccess) at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges() --- End of inner exception stack trace --- at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges() at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.SaveChanges() at Abp.Domain.Uow.UnitOfWorkBase.Complete() at Abp.Authorization.Users.UserTokenExpirationWorker`2.DoWork() at Abp.Threading.BackgroundWorkers.PeriodicBackgroundWorkerBase.Timer_Elapsed(Object sender, EventArgs e)

I have confirmed that 13.1.0 and the latest preview VS works again.

Thank you :) We're still going through our full round of testing and updates to our project to 13.1.0. Will let you know if we find anything else. I'm watching that github issue now.

Thanks. Understood :)

Thanks.

We've worked around KTCard for now. However for anyone who stumbles on this support ticket at a later date.

Please note the following issue with v13.1.0, which is a problem if you are using features and redis caching.

https://support.aspnetzero.com/QA/Questions/11899/Feature-Management-Not-Working-When-Redis-Cache-Enabled-In-v1310

I've also added a third item to the list above we are still working on.

https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft?pivots=dotnet-9-0#non-public-property-setters-and-getters

You can either mark it as [JsonInclude] or you need to remove the private setter.

Can you also please search the rest of the code for where this could be an issue. An urgent hotfix would be greatly appreciated as 13.1.0 is currently broken with features and redis.

Thanks Rick

The issue is the private setter on the TenantFeatureCacheItem FeatureValues property.

If I remove the private setter and make it public then System.Text.Json can deserialize it correctly to the object required.

With the private setter it does not work.

Further debugging has found this is a problem due to the updates to the serialization as well.

See this fiddle to show the issue. https://dotnetfiddle.net/SoyH6m

Hi,

  1. Downloaded a new and empty v13.1.0 solution from the website.
  2. Run the angular front end (no changes just a yarn install).
  3. Open the backend solution and enable Redis (uncomment lines 105-109 in XXXWebCoreModule.cs)
  4. Run the backend
  5. Login to the site
  6. Go to tenants
  7. And edit the features on the Default tenant.
  8. Enable the [Test tenant scope feature]
  9. Click Save
  10. Open the edit features on the Default tenant modal again
  11. The feature is not enabled.
  12. You can do this over and over and it won't enable the feature in the UI or in the actual code.

HOWEVER the feature is enabled in the DB and in Redis itself. It's just that when you get that feature back from redis it won't be set to true for some reason.

We've tried debugging the aspnetboilerplate to find where this goes wrong and we couldn't narrow it down.

Thanks Rick

Thanks ismcagdas.

That works. Was trying to avoid it and stick to native metronic. Does that mean most of the metronic things that rely on native bootstrap won't work?

Showing 1 to 10 of 121 entries