-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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][TaskManager] fix limited concurrency starvation in mget task claimer #187809
Merged
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2b0c750
some starting changes
pmuellr e7d505f
close, I think
pmuellr 0d00243
fix jest test
pmuellr 1bde8b7
merge main and fix conflicts
pmuellr 1331959
merge main and fix conflicts
pmuellr 450acb3
add test for claimSort()
pmuellr 7a0d574
merge main and fix conflicts
pmuellr ae2a46c
merge main and fix conflicts
pmuellr fa7f630
Merge branch 'main' into 184937-mget-fix-concurrency
elasticmachine 88a4f29
merge main and fix conflicts
pmuellr 842d402
changes from PR review
pmuellr 4b357c1
Copy search jest tests
mikecote f13d557
Merge branch 'main' into 184937-mget-fix-concurrency
elasticmachine b2a00c5
Merge branch 'main' into 184937-mget-fix-concurrency
elasticmachine 48806ca
Add size multiplier for limited concurrency tasks
mikecote 426a306
Merge with main
mikecote File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
x-pack/plugins/task_manager/server/task_claimers/lib/task_selector_by_capacity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { ConcreteTaskInstance } from '../../task'; | ||
import { isLimited, TaskClaimingBatches } from '../../queries/task_claiming'; | ||
|
||
// given a list of tasks and capacity info, select the tasks that meet capacity | ||
export function selectTasksByCapacity( | ||
tasks: ConcreteTaskInstance[], | ||
batches: TaskClaimingBatches | ||
): ConcreteTaskInstance[] { | ||
// create a map of task type - concurrency | ||
const limitedBatches = batches.filter(isLimited); | ||
const limitedMap = new Map<string, number>(); | ||
for (const limitedBatch of limitedBatches) { | ||
const { tasksTypes, concurrency } = limitedBatch; | ||
limitedMap.set(tasksTypes, concurrency); | ||
} | ||
|
||
// apply the limited concurrency | ||
const result: ConcreteTaskInstance[] = []; | ||
for (const task of tasks) { | ||
const concurrency = limitedMap.get(task.taskType); | ||
if (concurrency == null) { | ||
result.push(task); | ||
continue; | ||
} | ||
|
||
if (concurrency > 0) { | ||
result.push(task); | ||
limitedMap.set(task.taskType, concurrency - 1); | ||
} | ||
} | ||
|
||
return result; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 noticed a few lingering references to search-related things regarding tasks running too many attempts. I believe this got resolved in #152841; though not sure if that applies to recurring tasks. @mikecote @ymao1 ??? In any case, this function was no longer being used, so figured I might as well delete it.
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.
Yea I don't think we enforced anything with max attempts for recurring task types.
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.
+1 shouldn't be used for recurring tasks, only ad-hoc (one time) tasks