ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Unknown
    • 10.1.0, 11.0.0, 9.2.0, 8.5.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Dotnet Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      When SaveChanges detects an optimistic concurrency conflict, the provider throws DbUpdateConcurrencyException from MongoDatabaseWrapper.AssertWritesApplied without logging EF Core's CoreEventId.OptimisticConcurrencyException event, and without running ISaveChangesInterceptor.ThrowingConcurrencyException / ThrowingConcurrencyExceptionAsync. EF's relational, InMemory and Cosmos providers do both: they log the event at Debug level on the Microsoft.EntityFrameworkCore.Update category just before throwing, and the same call gives interceptors a chance to observe or suppress the exception.

      The conflict itself is detected correctly.

      Fix

      Log the event through the context's update logger, using the sync or async CoreLoggerExtensions variant to match the save. If an interceptor suppresses the exception, SaveChanges returns normally and carries on with the rest of the save; the operations that did not apply are counted as applied, as the relational providers count them.

      Exception type, message and behaviour are unchanged for anyone without an interceptor that overrides ThrowingConcurrencyException. DbContext.SaveChanges does not also log SaveChangesFailed for a DbUpdateConcurrencyException, so there is no double logging. The exception text holds only the collection namespace and counts, never entity values or keys.

      Ported from ajcvickers/mongo-efcore-provider#110.

            Assignee:
            Arthur Vickers
            Reporter:
            Arthur Vickers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: