Git Product home page Git Product logo

Comments (6)

cenkalti avatar cenkalti commented on May 27, 2024

I agree that downtime and pause/resume are different cases.

Adding this feature requires a change in data model that I am not comfortable with it. I think this problem can be solved outside Dalga.

What about this?

  • For pausing the job, DELETE the job and possibly save it somewhere else.
  • For resuming the job, POST the job again.

from dalga.

tooolbox avatar tooolbox commented on May 27, 2024

Hm, I see. It does complicate things for me, what with storing data in two places and therefore building a distributed transaction with Dalga. Let me review this and get back to you.

from dalga.

tooolbox avatar tooolbox commented on May 27, 2024

Hey @cenkalti, so now that I have added ISO8601 support and some key retry features (more to come, though) I took another look at the pause/resume functionality.

Assuming that #13 lands, and with what I have in #14 so far, (i.e. the next_sched column) it looks like this feature could be implemented by making the next_run column nullable. To pause the job, make next_run null and none of the instances will pick it up.

For resumption, it depends on the FixedIntervals setting:

  • If FixedIntervals is false, next_run is set to the value of next_sched. (This means that if next_sched is in the past, the job would run immediately.)
  • If FixedIntervals is true, both next_run and next_sched are moved shifted forward by interval until they're in the future.

If we don't want to make next_run nullable then a flag column of some kind could be used to exclude the row from the Front() query. Anyway, this is roughly what I'm thinking and I wanted to get your input.


(Note that I wrote most of this last night, before I saw your comments on #13, I'm going to go read them now.)

from dalga.

cenkalti avatar cenkalti commented on May 27, 2024

Sounds good. Making the next_run column nullable can work. I prefer this method instead of adding a separate boolean column.

We should also handle the case where job is paused while it is running. execute method may update the next_run field. We may need to add a WHERE clause to the SQL that updates the next_run field.

A suggestion about the terminology, maybe we can call it disable/enable instead of pause/resume. You decide.

from dalga.

tooolbox avatar tooolbox commented on May 27, 2024

Sounds good. Making the next_run column nullable can work. I prefer this method instead of adding a separate boolean column.

Okay, fantastic.

We should also handle the case where job is paused while it is running. execute method may update the next_run field. We may need to add a WHERE clause to the SQL that updates the next_run field.

...Huh. That is a very good point. I guess when it finishes it should update next_sched but if next_run has been NULL'd it doesn't update. Possibly to avoid 2 queries we could use CASE, so in UpdateNextRun() you have something like UPDATE jobs SET next_sched=?, next_run=CASE next_run IS NULL THEN NULL ELSE ? END, instance_id=NULL, location=? WHERE path = ? AND body = ?. I'm not 100% sure that will work, would need to try it out.

But yeah, we should account for that for sure.

A suggestion about the terminology, maybe we can call it disable/enable instead of pause/resume. You decide.

I agree. Now that I think of it, pause/resume sounds like it relates to an instance of the job running, which could be misleading. So we'll do enable/disable.

from dalga.

tooolbox avatar tooolbox commented on May 27, 2024

This is my next item, to follow #18

from dalga.

Related Issues (14)

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.