Code Monkey home page Code Monkey logo

Comments (3)

jbbarth avatar jbbarth commented on July 18, 2024

OK, here's what happened in our workflow (simplified):

from simpleflow import Workflow

class OurWorkflow(Workflow):
    def run(self, **context):
        # a first activity that needs preparation (partitionning for instance)
        preparation = self.submit(prepare_expensive_activity)
        if preparation.finished:
            for i in range(0,400):
                self.submit(foo)

        # many other activities
        for i in range(0, 800):
            self.submit(bar)

        # wait for everybody to finish..
        # ...

Now what happens when playing this workflow from the decider point of view:

  • replay 1:
    • 0 activity tasks open
    • preparation task is set to be scheduled,
    • 800 "bar" tasks are to be scheduled
    • => the decider sends a decision with 801 ScheduleActivityTask (in fact multiple decisions because of the 100-decision-tasks limit, but anyway)
    • => 801 activity tasks open
  • replay 2:
    • (imagine) preparation task is finished, which triggered a new decision task
    • 800 activity tasks open
    • simpleflow enters the first conditional, and will try to submit the 400 activity tasks
    • => BOOM

Moral of the story: we cannot rely on the open activity tasks counter unless we parse the whole workflow. We'd have to defer tasks submission after we know exactly all tasks and their status.

Even then, some constructs could make simpleflow fail very easily, for instance if we bypass a conditional where we entered before and where one or many tasks are submitted.

=> option 1 looks a bit complex and we won't be able to implement a fully reliable solution if people mess with future.finished conditionals.

from simpleflow.

jbbarth avatar jbbarth commented on July 18, 2024

Instead of relying on a naive counter, I think we could rely on an array of open activities (probably just their "activityId"), so we don't start from zero but from this list. When replaying the workflow:

  • start with the list of activities as seen in the history events
  • when scheduling an activity: if it's in the list, don't do anything, if not, add it
  • evaluate the length of the list as a replacement for the naive counter

This will protect against cases like the one described above (if done correctly). Now to plumb that together unless somebody has a better idea.

from simpleflow.

jbbarth avatar jbbarth commented on July 18, 2024

Option "6" (add a soft limit option) was added in fd22d8d and is available for simpleflow >= 0.10.2.

from simpleflow.

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.