OrleansContrib/Orleans.Providers.MongoDB

AbortTransaction cannot be called when no transaction started

xelanrok opened this issue · 5 comments

Hi!
I tried to setup mongodb provider for clustering. Version of the provider is 3.8.0.
I have local empty MongoDB(without database "orleans").

Silo startup:
UseMongoDBClustering(m => { m.DatabaseName = "orleans"; m.Strategy = MongoDBMembershipStrategy.Muiltiple; }) .UseMongoDBClient("mongodb://localhost:27017")
But I got error
image

Text stack trace
info: Orleans.Runtime.SiloLifecycleSubject[100452] Orleans.Runtime.Silo started in stage RuntimeGrainServices (8000) in 71.1576 Milliseconds fail: Orleans.Providers.MongoDB.Membership.MongoMembershipTable[900200] MongoMembershipTable.ReadAll failed. Exception=AbortTransaction cannot be called when no transaction started. System.InvalidOperationException: AbortTransaction cannot be called when no transaction started. at MongoDB.Driver.Core.Bindings.CoreSession.EnsureAbortTransactionCanBeCalled(String methodName) at MongoDB.Driver.Core.Bindings.CoreSession.AbortTransactionAsync(CancellationToken cancellationToken) at Orleans.Providers.MongoDB.Membership.Store.Multiple.MultipleMembershipCollection.ReadAll(String deploymentId) at Orleans.Providers.MongoDB.Membership.MongoMembershipTable.DoAndLog[T](String actionName, Func1 action)
fail: Orleans.Providers.MongoDB.Membership.MongoMembershipTable[900200]
MongoMembershipTable.ReadAll failed. Exception=AbortTransaction cannot be called when no transaction started.
System.InvalidOperationException: AbortTransaction cannot be called when no transaction started.
at MongoDB.Driver.Core.Bindings.CoreSession.EnsureAbortTransactionCanBeCalled(String methodName)
at MongoDB.Driver.Core.Bindings.CoreSession.AbortTransactionAsync(CancellationToken cancellationToken)
at Orleans.Providers.MongoDB.Membership.Store.Multiple.MultipleMembershipCollection.ReadAll(String deploymentId)
at Orleans.Providers.MongoDB.Membership.MongoMembershipTable.DoAndLog[T](String actionName, Func1 action)

When I switch strategy to SingleDocument all works good. The trouble happens only with multiple strategy.

There is this method WithTransactionAsync, we should use that here I think.

Thanks for reporting @xelanrok, I'm looking into this.

I haven't been able to replicate the issue but I've refactored the code to use WithTransaction as it appears to be the safer implementation.

@SebastianStehle can you please fix the pipeline or grant me permissions to do so?

Done, but you are a package owner already, so you can just create a new key and replace the one here in the repository.