Comments (4)
The issue you're describing seems to be related to a concurrency problem in the Elsa Workflow definitions update process. The error message indicates that there is an attempt to insert a duplicate key row into the WorkflowDefinitions
table, which violates the unique index constraint IX_WorkflowDefinition_DefinitionId_VersionId
.
This kind of problem can occur when the operation to update the IsLatest
flag and the creation of a new draft are not atomic, and an exception occurs between these two operations. If the IsLatest
flag is set to false for the current latest version, but the new draft is not created due to an exception, you end up in a state where there is no "latest" version, which causes subsequent operations to fail.
As for why transactions are not used, it's hard to say without more context. Transactions are a common way to ensure atomicity of operations, so their absence might be an oversight or a design decision based on other factors such as performance considerations or the underlying database support for transactions.
To address this issue, you mentioned a pull request (PR #3752) that inverts the order of operations for Elsa 3. Backporting such changes to Elsa 2 could indeed help to mitigate the issue by ensuring that the new draft is created before the IsLatest
flag is updated. However, the best solution would be to wrap these operations in a transaction to ensure that either both operations succeed or neither does, maintaining database consistency.
If you are experiencing this issue frequently, it might be worth raising it on the Elsa GitHub repository as a bug or enhancement request, if you haven't already. The maintainers of the project would be best placed to explain the design decisions and potentially address the issue in a future release.
In the meantime, as a workaround, you might consider manually handling the transaction in your code when updating workflow definitions, if the Elsa API allows for it.
from elsa-core.
Elsa 3 has mastered this logic flawlessly. You might consider backporting the logic from there and submitting a pull request.
from elsa-core.
I'm asking my boss if I can spend time working on it, it would help us but there is already the idea to migrate to elsa 3 in the future...
Meanwhile, could you elaborate a bit on why those operations are not atomic?
from elsa-core.
Absolutely, the abstraction of the persistence layer—encompassing EF Core, MongoDB, Dapper, and possible third-party implementations—makes handling this from the application layer quite practical. Given the smooth operation with Elsa 3 and workflow publications, there hasn't been a pressing need to alter this method. Nevertheless, I'm very interested in any suggestions for integrating this logic within a transaction that's compatible across all persistence providers. Your insights on achieving this would be greatly appreciated.
from elsa-core.
Related Issues (20)
- [ENH] Include dropdown when using a nullable enum in an activity input HOT 2
- [BUG] Race Condition in WorkflowDefinitionActivity Causing Execution Failures HOT 1
- [BUG] ResumeWorkflowAsync at ActivityNodeId losing Input values between activities HOT 3
- Unable to Open Workflow Instance View Screen in Customized Elsa UI HOT 3
- Workflow instance viewer activity badges don't update after resuming workflow for a suspended HttpEndpoint activity HOT 1
- [BUG] InvalidOperationException: No service for type 'Elsa.Api.Client.Resources.Package.Contracts.IPackageApi' has been registered. HOT 2
- [DOC] Blocking activities has incorrect code examples HOT 2
- Elsa 3.1.3 Http end point using dispatch workflow not waiting for child workflow completion even though 'Wait for completion' set true HOT 1
- Elsa runs the same workflow multiple times with Azure ServiceBus HOT 2
- Can Chinese be supported HOT 1
- [BUG] FlowJoin Activity Throws NullReferenceException Without Previous Forks
- [PERF] Workflow Graph Loading Enhancement HOT 1
- [PERF] Remove Caching Decorator for Bookmarks to Reduce Service Bus Message Load HOT 1
- [FEAT] "ScheduleActivity" to "Completed" activity instance. HOT 1
- [BUG] Serialization error when 'MessageReceived' activity is used in workflow HOT 5
- [ENH] In stress testing, there were some task have not been started. HOT 2
- [ENH] Add "Code" Field to Fault Activity to Indicate Error Code HOT 1
- [BUG]In the api "elsa/api/workflow-instances/{instance_id}" result,"JSON.workflowState.activityExecutionContexts" is empty? HOT 1
- [BUG]Why the "ActivityExecuted" Implement Can't get the "Completed" status of Container activity HOT 1
- [BUG]Why the "ActivityExecuted" Implement Can't get the "Completed" status of Container activity? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elsa-core.