OrleansContrib / Orleans.Providers.MongoDB

A MongoDb implementation of the Orleans Providers: Membership, Storage and Reminders.
MIT License
105 stars 44 forks source link

AbortTransaction cannot be called when no transaction started #119

Closed xelanrok closed 1 year ago

xelanrok commented 1 year ago

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.

SebastianStehle commented 1 year ago

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

wassim-k commented 1 year ago

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

wassim-k commented 1 year ago

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.

wassim-k commented 1 year ago

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

SebastianStehle commented 1 year ago

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