Disposal exception inside CreateExecutionStrategy().ExecuteInTransaction

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Unknown
    • 9.0.4, 8.3.4
    • Affects Version/s: 8.3.3
    • Component/s: None
    • None
    • None
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      I have a generic code where we execute passed lambda on the DbContext. DbContext can be either postgres and mongo. For postgres we had to use `CreateExecutionStrategy().ExecuteInTransaction` pattern. It seems to work correctly on mongo as well, but under the hood we always have an exception like this:

      fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
                                            An unhandled exception has occurred while executing the request.
                                            System.InvalidOperationException: Can not Dispose MongoTransaction cbf3f23f-ead8-4c52-ad3d-9c5abb3485ff because it is Active.
                                               at MongoDB.EntityFrameworkCore.Storage.MongoTransaction.AssertCorrectState(String action, TransactionState[] validStates)
                                               at MongoDB.EntityFrameworkCore.Storage.MongoTransaction.DisposeAsync()
                                               at System.Runtime.CompilerServices.ConfiguredAsyncDisposable.DisposeAsync()
                                               at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.<>c__DisplayClass24_0`2.<<ExecuteInTransactionAsync>b__0>d.MoveNext()
                                            --- End of stack trace from previous location --- 

      Creating transaction object directly works without this exception, it only throws when using the execution strategy.

      I think this is not really that critical since the rollback itself seems to work correctly, but the exception can brake some flows that assume proper support for this execution strategy

            Assignee:
            Damien Guard
            Reporter:
            Jakub Syty
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: