elsa-core: The `EntityFrameworkStore.DeleteManyAsync` throws error with database other than SQLite since Elsa 2.9
Hi there, after upgrade to Elsa 2.9.0, some error happens.
- Unable Bulk delete workflow instances.
- Unable publish workflow definitions.
- The CleanupHostedService Failed to perform cleanup.
It may caused by #3286
System.InvalidOperationException: The entity type 'string' was not found. Ensure that the entity type has been added to the model.
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.GetOrCreateEntry(Object entity)
at Microsoft.EntityFrameworkCore.DbContext.EntryWithoutDetectChanges[TEntity](TEntity entity)
at Microsoft.EntityFrameworkCore.DbContext.Remove[TEntity](TEntity entity)
at Elsa.Persistence.EntityFramework.Core.Extensions.QueryableBulkExtensions.BatchDeleteWithWorkAroundAsync[T](IQueryable`1 queryable, DbContext elsaContext, CancellationToken cancellationToken)
at Elsa.Persistence.EntityFramework.Core.Stores.EntityFrameworkWorkflowInstanceStore.<>c__DisplayClass5_0.<<DeleteManyByIdsAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Elsa.Persistence.EntityFramework.Core.Stores.EntityFrameworkStore`2.DoWork(Func`2 work, CancellationToken cancellationToken)
at Elsa.Persistence.EntityFramework.Core.Stores.EntityFrameworkStore`2.DoWork(Func`2 work, CancellationToken cancellationToken)
at Elsa.Persistence.EntityFramework.Core.Stores.EntityFrameworkWorkflowInstanceStore.DeleteManyByIdsAsync(IEnumerable`1 ids, CancellationToken cancellationToken)
at Elsa.Persistence.EntityFramework.Core.Stores.EntityFrameworkWorkflowInstanceStore.DeleteManyAsync(ISpecification`1 specification, CancellationToken cancellationToken)
at Elsa.Persistence.Decorators.EventPublishingWorkflowInstanceStore.DeleteManyAsync(ISpecification`1 specification, CancellationToken cancellationToken)
at Elsa.Retention.Jobs.CleanupJob.DeleteManyAsync(ICollection`1 workflowInstanceIds, CancellationToken cancellationToken)
at Elsa.Retention.Jobs.CleanupJob.ExecuteAsync(CancellationToken cancellationToken)
at Elsa.Retention.HostedServices.CleanupHostedService.ExecuteAsync(CancellationToken stoppingToken)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 18 (11 by maintainers)
Hello , I think this should be fix with #3345. Indeed , I’ve seen during my test the issue when we don’t use the default database name. And because the notion of schéma is not the same for MySQL , we can remove the schéma name from dbcontext when we use MySQL to avoid this issue.
@sfmskywalker With the latest preview from myget, we getting the following error. Our database is not named Elsa, is the
Elsa.a accidental missed hardcoded database name in the query?Microsoft.EntityFrameworkCore.Database.Command[20102] Failed executing DbCommand (0ms) [Parameters=[@p0='?' (Size = 4000)], CommandType='Text', CommandTimeout='30'] DELETE FROM Elsa.Triggers WHERE ``WorkflowDefinitionId`` = @p0Unhandled exception. MySqlConnector.MySqlException (0x80004005): DELETE command denied to user 'elsa_workflow'@'rt1-worker3-221cd339-4qchr.k8s.local.net' for table 'Triggers'