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.
Yes, 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, but the downside is the lack of support for performing this as an atomic operation. That being said, this issue is no longer present in Elsa 3, so odds are that if we back port that logic to Elsa 2, the issue goes away.
from elsa-core.
Related Issues (20)
- [ENH] HOT 1
- [BUG]when publish workflow RouteExtensions path is null throw exception System.NullReferenceException:“Object reference not set to an instance of an object.”
- [BUG] System.NullReferenceException: 'Object reference not set to an instance of an object.'
- [BUG] Can´t save CodeActivity from example. Error "..must bind to an object property or field on deserialization." HOT 1
- [BUG] `Array.Sort()` Not Working as Expected on `ExpandoObject` Fields
- [BUG] Exception when saving workflow execution logs after running alterations when using MongoDb storage HOT 3
- [BUG] `Variable` and `Input` Do Not Work for Custom `IWorkflowProvider` Implementation HOT 3
- [FEAT] Add JS Functions and Activities for Encoding/Decoding Bytes and Base64
- [BUG] workflow die when i use activity Elsa.Delay in elsa 3
- [BUG] Error when Set Variable from Json data HOT 2
- [BUG] Remote Login default from elsa 3 and add custom login page
- [BUG] Revert Variable Accessors Returning Copy Instead of Reference
- [DOC] <Parallel execution of activities>how to use this feature?
- [FEAT] Bookmarks- Custom Payload Comparison
- Garbage Elsa, you haven't helped solve so many problems for so long. What else are you doing with open source? HOT 5
- MongoDB: Bulk Write Operation Error with '$type' Field in Elsa Workflows HOT 1
- [BUG] Collection serialization 3.2.0rc5 HOT 2
- [BUG]Memory usage cannot be reduced
- [BUG] Disappear Activity Elsa V3 HOT 1
- [BUG] NullReferenceException When Parsing a HttpResponse without content-type 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.