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

[ResponseOps][Task Manager] unrecognized tasks are not updated when mget task claimer is used #192686

Closed
2 tasks
pmuellr opened this issue Sep 12, 2024 · 2 comments · Fixed by #199057
Closed
2 tasks
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Task Manager Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)

Comments

@pmuellr
Copy link
Member

pmuellr commented Sep 12, 2024

As part of the recent changes to x-pack/plugins/task_manager/server/task_claimers/strategy_mget.ts, we removed the code that marks tasks with removedTypes to Unrecognized.

You can see that code in a previous version of the module:

// separate update for removed tasks; shouldn't happen often, so unlikely
// a performance concern, and keeps the rest of the logic simpler
let removedCount = 0;
if (removedTasks.length > 0) {
const tasksToRemove = Array.from(removedTasks);
for (const task of tasksToRemove) {
task.status = TaskStatus.Unrecognized;
}
// don't worry too much about errors, we'll get them next time
try {
const removeResults = await taskStore.bulkUpdate(tasksToRemove, {
validate: false,
excludeLargeFields: true,
});
for (const removeResult of removeResults) {
if (isOk(removeResult)) {
removedCount++;
} else {
const { id, type, error } = removeResult.error;
logger.warn(
`Error updating task ${id}:${type} to mark as unrecognized during claim: ${error.message}`,
logMeta
);
}
}
} catch (err) {
logger.warn(`Error updating tasks to mark as unrecognized during claim: ${err}`, logMeta);
}
}

Current thinking is that task manager should have a recurring task running, that can perform these updates. Task Manager's first recurring background task? \o/

These updates are not critical, they are more cleanliness, so we don't need to put the system through a lot of stress, often. Maybe once an hour, do a few thousand?

In theory we won't have version/OCC issues here, as TM will not be otherwise claiming these tasks.

Definition of Done

  • Tasks part of the removedTypes convert to Unrecognized
  • Tests
@pmuellr pmuellr added bug Fixes for quality problems that affect the customer experience Feature:Task Manager Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Sep 12, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@mikecote
Copy link
Contributor

I was able to get the functionality by doing the following within the mget claim strategy

      OneOfTaskTypes(
        'task.taskType',
        claimPartitions.unlimitedTypes.concat(Array.from(removedTypes))
      ),

This will merge in this PR => #196399 but it would be nice to have this part of a background task instead.

@ymao1 ymao1 self-assigned this Nov 1, 2024
@ymao1 ymao1 closed this as completed in be949d6 Nov 11, 2024
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Nov 11, 2024
…ask types as `unrecognized` (elastic#199057)

Resolves elastic#192686

## Summary

Creates a background task to search for removed task types and mark them
as unrecognized. Removes the current logic that does this during the
task claim cycle for both task claim strategies.

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit be949d6)
tkajtoch pushed a commit to tkajtoch/kibana that referenced this issue Nov 12, 2024
…ask types as `unrecognized` (elastic#199057)

Resolves elastic#192686

## Summary

Creates a background task to search for removed task types and mark them
as unrecognized. Removes the current logic that does this during the
task claim cycle for both task claim strategies.

---------

Co-authored-by: kibanamachine <[email protected]>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this issue Nov 18, 2024
…ask types as `unrecognized` (elastic#199057)

Resolves elastic#192686

## Summary

Creates a background task to search for removed task types and mark them
as unrecognized. Removes the current logic that does this during the
task claim cycle for both task claim strategies.

---------

Co-authored-by: kibanamachine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Task Manager Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)
Projects
None yet
4 participants