question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The `EntityFrameworkStore.DeleteManyAsync` throws error with database other than SQLite since Elsa 2.9

See original GitHub issue

Hi there, after upgrade to Elsa 2.9.0, some error happens.

  1. Unable Bulk delete workflow instances.
  2. Unable publish workflow definitions.
  3. 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)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:18 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
jdevillardcommented, Oct 14, 2022

@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`` = @p0

Unhandled exception. MySqlConnector.MySqlException (0x80004005): DELETE command denied to user 'elsa_workflow'@'rt1-worker3-221cd339-4qchr.k8s.local.net' for table 'Triggers'

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.

1reaction
johnwccommented, Oct 14, 2022

@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`` = @p0

Unhandled exception. MySqlConnector.MySqlException (0x80004005): DELETE command denied to user 'elsa_workflow'@'rt1-worker3-221cd339-4qchr.k8s.local.net' for table 'Triggers'

Read more comments on GitHub >

github_iconTop Results From Across the Web

UseMySql() with autoRunMigrations = true would cause ...
This project runs without issue when the database "workflow" does not exist. And the db appears after the app starts.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found