-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[task manager] do not sort tasks to be claimed by score if no pinned tasks #80692
[task manager] do not sort tasks to be claimed by score if no pinned tasks #80692
Conversation
It would be nice to add some kind of "load" functional test for this. That could test 2 things:
The first is tough, as I've only managed to see this in one case with ~100K tasks queued to run. And if we use the default poll interval and worker size, we can only run about 10 workers every 3 seconds (can't remember if we poll earlier if there are workers finishing before the poll interval goes off). Perhaps we need a script to do an ad-hoc test we can run over the course of a few hours. The second should be easier, I think. Queue up a bunch of tasks (say 100), then do a runNow(), and it should fire within 2 * the next poll interval (I think). [edit: we already have some here] |
@@ -278,6 +279,12 @@ export class TaskStore { | |||
) | |||
); | |||
|
|||
// the sort should use score first, but only if there are pinned tasks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment about score being lower for old tasks and that that is the opposite to what TM actually needs, so whenever score is used TM is likely to pick up newer expired tasks rather than the older ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add more explanation - but it's not entirely clear to me that the score IS strictly lower for older tasks - I didn't actually go down the rabbit hole to figure out how the scores were calculated :-). That would be my guess as well - that older docs score lower - but sometimes things actually worked out fairly well, so I think there may be more to it than just that. I've been assuming the score is basically a random number at this point, except for the pinned tasks that will score better ...
LG but we should definitely test this, at least at unit level. |
Yup, was planning a jest test, not quite sure how to build a test for this that can run as a function test though. |
…tasks resolves: elastic#80371 Previously, when claiming tasks, we were always sorting the tasks to claim by the score and then by the time they should be run. We sort by score to capture `runNow()` tasks, also referred to internally as "pinned" tasks in the update by query. The change in this PR is to only sort by score if there are pinned tasks, and to not sort by score at all if there aren't any.
d2930d4
to
d641462
Compare
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
…tasks (elastic#80692) resolves: elastic#80371 Previously, when claiming tasks, we were always sorting the tasks to claim by the score and then by the time they should be run. We sort by score to capture `runNow()` tasks, also referred to internally as "pinned" tasks in the update by query. The change in this PR is to only sort by score if there are pinned tasks, and to not sort by score at all if there aren't any.
…tasks (elastic#80692) resolves: elastic#80371 Previously, when claiming tasks, we were always sorting the tasks to claim by the score and then by the time they should be run. We sort by score to capture `runNow()` tasks, also referred to internally as "pinned" tasks in the update by query. The change in this PR is to only sort by score if there are pinned tasks, and to not sort by score at all if there aren't any. # Conflicts: # x-pack/plugins/task_manager/server/task_store.test.ts
…tasks (#80692) (#81495) resolves: #80371 Previously, when claiming tasks, we were always sorting the tasks to claim by the score and then by the time they should be run. We sort by score to capture `runNow()` tasks, also referred to internally as "pinned" tasks in the update by query. The change in this PR is to only sort by score if there are pinned tasks, and to not sort by score at all if there aren't any.
…pinned tasks (#80692) (#81497) resolves: #80371 Previously, when claiming tasks, we were always sorting the tasks to claim by the score and then by the time they should be run. We sort by score to capture `runNow()` tasks, also referred to internally as "pinned" tasks in the update by query. The change in this PR is to only sort by score if there are pinned tasks, and to not sort by score at all if there aren't any. Also had to fix type check error after fixing a. merge conflict during the backport:
resolves: #80371
Previously, when claiming tasks, we were always sorting the tasks to claim by
the score and then by the time they should be run. We sort by score to
capture
runNow()
tasks, also referred to internally as "pinned" tasksin the update by query.
The change in this PR is to only sort by score if there are pinned tasks, and
to not sort by score at all if there aren't any.