Giter Site home page Giter Site logo

Comments (4)

glime-ai avatar glime-ai commented on June 9, 2024

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.

sfmskywalker avatar sfmskywalker commented on June 9, 2024

Elsa 3 has mastered this logic flawlessly. You might consider backporting the logic from there and submitting a pull request.

from elsa-core.

alessandro-gandolfi-ors avatar alessandro-gandolfi-ors commented on June 9, 2024

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.

sfmskywalker avatar sfmskywalker commented on June 9, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.