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

Related Properties has updated with no changes when save Main object AbpDbConcurrencyException #21835

Open
1 task done
cmonzon44 opened this issue Jan 6, 2025 · 3 comments
Labels

Comments

@cmonzon44
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Description

After migrating from version 5.1.3 to version 8.3.2, we are experimenting many concurrency control errors in our production environment (due to higher load).
We noticed that when we retrieve an entity from database with IRepository... and its related data from the database (.Incude), saving the entity causes all the related entities retrieved from the database to also be modified (checked with LastModification property). Since all of them have the "concurrency stamp" attribute, they are competing for priority when saving to the database.

99% of our entities has FullAuditedAggregateRoot inherits.

Before exception we find a several warnings logs, like:

Message: There is an entry which is not saved due to concurrency exception: Deposit {Id: 3} Modified
Security Level: Warning

image

After warning log, an exception has been thrown:
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. 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.

image

Reproduction Steps

IQueryable<ActivityReport> query = await this.ActivityReportRepository.GetQueryableAsync();

IQueryable<ActivityReport> query = query
    .Include(x => x.OriginDeposit)
    .Include(x => x.DestinationDeposit)
    .Where(x => x.State == ActivityReportState.Finished);

var report = await query.FirstOrDefaultAsync();

report.Number = 1234;

await this.ActivityReportRepository.UpdateAsync(report);

// After saving, our Origin and Destination desposits has been updated and "LastModificationTime", "LastModifierId" 
// was refreshed and new ConcurrencyStamp was generated in Deposits entities.

Expected behavior

No response

Actual behavior

No response

Regression?

No response

Known Workarounds

No response

Version

8.3.2

User Interface

Angular

Database Provider

EF Core (Default)

Tiered or separate authentication server

None (Default)

Operation System

Linux

Other information

No response

@cmonzon44 cmonzon44 added the bug label Jan 6, 2025
@maliming
Copy link
Member

maliming commented Jan 7, 2025

hi

Can you share a simple project?

@cmonzon44
Copy link
Author

Yes, sure.

We create two examples, with diferents parent classes , Dogs-Owners (FullAuditedEntity) and Order-Location (FullAuditedAggregateRoot)

Please verify database records after requests, you can see the LastModificationTime changes.
We made comments above de updates methods in the appservices (DogAppService and LocationAppService)
Example: https://we.tl/t-QWXLaDpJ4o

@cmonzon44
Copy link
Author

Maybe this "bug" has been introduced after this issue here, #18701 ? Because our team create severals solution downgrading version by version and before 8.2.0 doesn't happens and the PR of 18707 was merged to 8.2.0....

Another mistake, we found if we add an optional parameter to repository.UpdateAsync(entity, **true**), the behavior (reported above) doesn't occur.

We are planning to downgrade our production version to 8.1.5 or inspect our solution (isn't small) and add missing autosave parameters and set it true...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants