Skip to content

Startup work and enqueued work that defines a new transaction scope can restore a completed ambient transaction #34

Description

@rars

Reproduction:

var actor = CreateActor(ActorCreateOptions.None);
await actor.Start();

var result = await actor.Enqueue(async () =>
            {
                using (var scope = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled))
                {
                    await Task.Delay(200);
                } // Restores ambient transaction which should be null

                if (Transaction.Current != null) /* <-- this line will actually fail because the ambient transaction that's restored is marked as completed so throws an InvalidOperationException */
                {
                    Console.WriteLine("Ambient transaction found!");
                }

                return 1;
            });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions