Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): add new task-batching plugin #495

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

DrRebus
Copy link
Contributor

@DrRebus DrRebus commented Nov 30, 2023

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    A new feature: a task batching plugin.

  • What is the current behavior? (You can also link to an open issue here)
    The only way of batching tasks so far is to use a subtask plugin with the foreach feature, which dynamically adds a new step per subtask. This approach isn't efficient DB-wise, because everytime a step is updated, the whole step tree (a JSON formatted string) gets updated, triggering an UPDATE in the database. These UPDATEs create new bigger-and-bigger rows and delete the previous ones, bloating the DB and requiring a stronger VACUUM.

  • What is the new behavior (if this is a feature change)?
    The task-batching plugin spawns child tasks as independent tasks that wake the parent once completed. Since the parent task no longer embed its children, no hard link exists between them, but they're linked via:

  • the ParentTaskID tag, the public ID of the parent task, allowing the child to wake its parent.
  • the BatchID property, the public ID of the batch the task belongs two.
  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    Nope.

  • Other information:
    This plugin doesn't yet aggregate results of the children tasks. It'll come in a subsequent version.
    Contrary to what's been discussed, when using sub batches (sub_batch_size > 0), children tasks don't always wake their parent when they're done. Instead, the last task in the sub batch will wake the parent. That way, we limit even more the amount of UPDATEs made. The downside is that we have to wait for the whole sub batch to be done before spawning more tasks in the batch.

@DrRebus DrRebus changed the title feat(plugin): Added new task-batching plugin. feat(plugin): Add new task-batching plugin. Nov 30, 2023
@DrRebus DrRebus force-pushed the dev/rtordjma/task-batch-plugin branch 2 times, most recently from d7f70c1 to 9b076b1 Compare December 6, 2023 09:34
@DrRebus DrRebus force-pushed the dev/rtordjma/task-batch-plugin branch from fa28ad3 to 08c3af2 Compare December 12, 2023 16:49
@DrRebus DrRebus force-pushed the dev/rtordjma/task-batch-plugin branch from e980730 to ddfde5b Compare December 21, 2023 09:31
floriancazals
floriancazals previously approved these changes Dec 23, 2023
@DrRebus DrRebus force-pushed the dev/rtordjma/task-batch-plugin branch 2 times, most recently from fc87e13 to 63bd3e6 Compare July 24, 2024 08:11
|----------------------|-------------------------------------------|
| `batch_id` | The public identifier of the batch |
| `remaining_tasks` | How many tasks still need to complete |
| `tasks_started` | How many tasks were started so far |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be interesting to add the number of tasks done, and failed.

@DrRebus DrRebus force-pushed the dev/rtordjma/task-batch-plugin branch 3 times, most recently from 877b552 to 14d3a71 Compare October 25, 2024 13:39
wI2L
wI2L previously approved these changes Oct 25, 2024
@DrRebus DrRebus force-pushed the dev/rtordjma/task-batch-plugin branch 2 times, most recently from f8c4a01 to da58b0e Compare October 25, 2024 13:59
@ovh-cds
Copy link
Collaborator

ovh-cds commented Oct 25, 2024

CDS Report test#1912.0 ✘
*

  • golangci-lint ✘
  • unit-test and integration-tests ✔

Added a task-batching plugin that creates X tasks of the same template and waits until all of them are in a final state.
Moved batch-creation code to the engine package and made the POST batch handler use it.
Exposed final tasks' states to be used by the batch plugin.

Signed-off-by: Ruben Tordjman <[email protected]>
@DrRebus DrRebus force-pushed the dev/rtordjma/task-batch-plugin branch from da58b0e to e02edf6 Compare October 25, 2024 14:16
@ovh-cds
Copy link
Collaborator

ovh-cds commented Oct 25, 2024

CDS Report package#1913.0 ✘

  • Stage 1
    • Docker build ✘

@wI2L wI2L self-requested a review October 25, 2024 14:36
@wI2L wI2L changed the title feat(plugin): Add new task-batching plugin. feat(plugin): add new task-batching plugin Oct 28, 2024
@wI2L wI2L merged commit dd6039e into ovh:master Oct 28, 2024
3 checks passed
@DrRebus DrRebus deleted the dev/rtordjma/task-batch-plugin branch April 4, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants