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

MongoDb provider does not support stand-alone servers after v3.6.5 #1130

Open
brettwinters opened this issue Jan 9, 2023 · 3 comments
Open

Comments

@brettwinters
Copy link

Hi @viktorshevchenko210

After #1079 is merged (release v3.7.0) WorkflowCore.Persistence.MongoDB does not allow stand alone MongoDb servers due to addition of transaction support.

Issue in this file : workflow-core/src/providers/WorkflowCore.Persistence.MongoDB/Services/MongoPersistenceProvider.cs for method public async Task PersistWorkflow(WorkflowInstance workflow, List<EventSubscription> subscriptions, CancellationToken cancellationToken = default)

Reproduce:

Persist workflow which contains more than one subscriptions so that if (subscriptions == null || subscriptions.Count < 1) is not true.

Result

The line session.StartTransaction() in below method throws:

public async Task PersistWorkflow(WorkflowInstance workflow, List<EventSubscription> subscriptions, CancellationToken cancellationToken = default)
        {
            if (subscriptions == null || subscriptions.Count < 1)
            {
                await PersistWorkflow(workflow, cancellationToken);
                return;
            }

            using (var session = await _database.Client.StartSessionAsync(cancellationToken: cancellationToken))
            {
                session.StartTransaction(); //<---- this throws
                await PersistWorkflow(workflow, cancellationToken);
                await EventSubscriptions.InsertManyAsync(subscriptions, cancellationToken: cancellationToken);
                await session.CommitTransactionAsync(cancellationToken);
            }
        }

The exception:

System.NotSupportedException: Standalone servers do not support transactions.
   at MongoDB.Driver.Core.Bindings.CoreSession.EnsureTransactionsAreSupported()
   at MongoDB.Driver.Core.Bindings.CoreSession.EnsureStartTransactionCanBeCalled()
   at MongoDB.Driver.Core.Bindings.CoreSession.StartTransaction(TransactionOptions transactionOptions)
   at MongoDB.Driver.Core.Bindings.WrappingCoreSession.StartTransaction(TransactionOptions transactionOptions)
   at MongoDB.Driver.Core.Bindings.WrappingCoreSession.StartTransaction(TransactionOptions transactionOptions)
   at MongoDB.Driver.ClientSessionHandle.StartTransaction(TransactionOptions transactionOptions)
@danielgerlag
Copy link
Owner

@glucaci

@glucaci
Copy link
Collaborator

glucaci commented Jan 27, 2023

You can convert your standalone server to a replica set. how-to

Also if you need it in tests please take a look to the WorkflowCore.Tests.MongoDB

@brettwinters
Copy link
Author

Yeah that's what I did for my local MongoDB instance for testing. I guess leave it as it is and maybe add a comment in the docs that you'll need a cluster or replica set for working-core to work on MongoDB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants