8000 A second operation started on this context before a previous operation completed · Issue #219 · elsa-workflows/elsa-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
A second operation started on this context before a previous operation completed #219
Closed
@martin-indexeb

Description

@martin-indexeb

Hi, not sure if this is something I have set up wrong, but I'm trying to test Elsa with the dashboard and designer and have used SQL Server as the EF provider. After successfully adding a couple of workflows I now get the 'second operation' error when trying to view the workflows list. Here's the stack trace:

System.AggregateException: One or more errors occurred. (A second operation started on this context before a previous operation completed. This is usually caused by different threads using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913.)
 ---> System.InvalidOperationException: A second operation started on this context before a previous operation completed. This is usually caused by different threads using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913.
  at Microsoft.EntityFrameworkCore.Internal.ConcurrencyDetector.EnterCriticalSection()
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
   at Elsa.Persistence.EntityFrameworkCore.Services.EntityFrameworkCoreWorkflowInstanceStore.ListByDefinitionAsync(String definitionId, CancellationToken cancellationToken)
   at Elsa.Extensions.AsyncEnumerableExtensions.ToListAsync[T](Task`1 task)
   at Elsa.Dashboard.Areas.Elsa.Controllers.WorkflowDefinitionController.CreateWorkflowDefinitionListItemModelAsync(WorkflowDefinitionVersion workflowDefinition, CancellationToken cancellationToken)
   at Elsa.Dashboard.Areas.Elsa.Controllers.WorkflowDefinitionController.<>c__DisplayClass7_0.<<Index>b__0>d.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Elsa.Dashboard.Areas.Elsa.Controllers.WorkflowDefinitionController.<>c.<Index>b__7_1(Task`1 x)
   at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
   at System.Linq.Lookup`2.Create(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`2.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Elsa.Dashboard.Areas.Elsa.Controllers.WorkflowDefinitionController.Index(CancellationToken cancellationToken)
   at lambda_method(Closure , Object )
   at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Elsa.Activities.Http.Middleware.RequestHandlerMiddleware`1.InvokeAsync(HttpContext httpContext, THandler handler)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

I've stepped through the WorkflowDefinitionController.Index task and this line run's okay:

var workflows = await workflowDefinitionStore.ListAsync(
                VersionOptions.LatestOrPublished,
                cancellationToken
            );

but then it errors out on the subsequent call:

var workflowModelTasks = workflows.Select(
                    async x => await CreateWorkflowDefinitionListItemModelAsync(x, cancellationToken)
                )
                .ToList();

Which, as you can see from the stack trace is getting as far as EntityFrameworkCoreWorkflowInstanceStore.ListByDefinitionAsync for the next call to the dbContext which throws the error.

Has anyone got any thoughts on what's causing this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0