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

Log the entries info when DbUpdateConcurrencyException occurs. #16995

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

maliming
Copy link
Member

@maliming maliming commented Jun 29, 2023

This lets us quickly see which entities have concurrency problems.

warn: Volo.Abp.EntityFrameworkCore.AbpDbContext[0]
      There is an entry which is not saved due to concurrency exception:
      City {Id: 27237527-605e-4652-a2a5-68e0e512da36} Deleted

```cs
fail: Microsoft.EntityFrameworkCore.Update[10000]
      An exception occurred in the database while saving changes for context type 'Volo.Abp.TestApp.EntityFrameworkCore.TestAppDbContext'.
      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 http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
         at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyExceptionAsync(RelationalDataReader reader, Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected, CancellationToken cancellationToken)

warn: Volo.Abp.EntityFrameworkCore.AbpDbContext[0]
      There is an entry which is not saved due to concurrency exception:
      City {Id: 27237527-605e-4652-a2a5-68e0e512da36} Deleted

```
@maliming maliming added this to the 7.4-preview milestone Jun 29, 2023
@maliming maliming requested a review from hikalkan June 29, 2023 09:23
@codecov
Copy link

codecov bot commented Jun 29, 2023

Codecov Report

Merging #16995 (5e1dfb1) into dev (e0655d8) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##              dev   #16995   +/-   ##
=======================================
  Coverage   53.14%   53.15%           
=======================================
  Files        2989     2989           
  Lines       92785    92797   +12     
=======================================
+ Hits        49312    49324   +12     
  Misses      43473    43473           
Impacted Files Coverage Δ
...kCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs 92.14% <100.00%> (+0.19%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@hikalkan hikalkan merged commit d6446a6 into dev Jul 12, 2023
4 checks passed
@hikalkan hikalkan deleted the concurrency-logger branch July 12, 2023 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants