question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example: How to create a multi-step job

See original GitHub issue

Add an example on how to create a multi-step job.

Two possible solutions:

  • Maintain state in task_data, update and reschedule
  • ~Schedule the next step at the very end of the current step using the SchedulerClient (not guaranteed atomic)~
  • Schedule next step in the CompletionHandler

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
kagkarlssoncommented, Apr 6, 2022

I may have been a bit quick to answer here:

Could you expand on why the second option (scheduling the next task at the end of the step) is not atomic? Doesn’t saving the newly scheduled task happen in the same transaction as completing/deleting the current one?

Answer:

The CompletionHandler is currently not transactional as it up until now only have had a single jdbc-statement. Might be needed to better support multistep-jobs.

For the second option (in the description), the next step is actually scheduled at the very end of the ExecutionHandler. The CompletionHAndler will run after the full ExecutionHandler has run. If we put it at the very end of the ExecutionHandler there may be some edge-cases. The one I can think of is:

  • Execution A runs. Schedules execution B at the very end of its ExecutionHandler. Complete of execution A fail due to db/network-problems. Execution B remains scheduled and runs. Execution A is discovered as “dead” since it completion failed and the lock remained. Execution A is “revived” (depends on DeadExecutionHandler, customizable) and runs again after execution B have already run, and may actually schedule a new Execution B. To prevent you could for example make sure that a second Execution B will have no effect (make idempotent or similar)
0reactions
kagkarlssoncommented, Sep 13, 2022

Merged a PR enabling scheduling the next step in the CompletionHandler, safely. See JobChainingUsingSeparateTasksMain.java

I have also fixed so that immediateExecution works for scheduling that happens in the CompletionHandler, so enableImmediateExecution() will cause anything scheduled to now() (or before) to run directly, bypassing the pollingInterval.

I think what remains for these use-cases is reliably scheduling two or more new executions in a CompletionHandler. It is probably a niche use-case, but would be nice to support. Requires transactional CompletionHandlers.

(The changes mentioned are not yet release, but will be soon)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Example: Creating a multi-page job application form
Create 3 new pages: Page A, Page B, and Page C. · From the Assets pane, select Forms to list the existing form...
Read more >
9 Best Multi Step Form Examples for Your Inspiration [By ...
Why use multi step forms? Example 1: HomeAdvisor — Plumbing, HVAC, and Service Businesses; Example 2: Pest Control Allentown Pa — Pest Control...
Read more >
10 Best Multi Step Form Examples And Why They Work
10 Best Multi Step Form Examples And Why They Work · 10 – “Post a job?”, by Khoros · 9 – “2 steps...
Read more >
Create a Multi-Step SQL Server Agent Job (T-SQL)
In this article, I'll show you how to create a job with multiple steps. Example. When you create a SQL Server Agent job...
Read more >
How to Write a Multistep MapReduce Job Using the mrjob ...
For more, check out Michael Manoochehri's Addison-Wesley Data Series book "Data Just Right: Introduction to Large-Scale Data & Analytics at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found