Skip to content

[ML] Prevent get datafeeds stats API returning an error when local tasks are slow to stop#104352

Open
aishwarysingh7754 wants to merge 1 commit intoelastic:mainfrom
aishwarysingh7754:aishwarybranch
Open

[ML] Prevent get datafeeds stats API returning an error when local tasks are slow to stop#104352
aishwarysingh7754 wants to merge 1 commit intoelastic:mainfrom
aishwarysingh7754:aishwarybranch

Conversation

@aishwarysingh7754
Copy link

@aishwarysingh7754 aishwarysingh7754 commented Jan 14, 2024

To solve this issue, I modified the fromResponses method in the Response class to handle duplicate keys more gracefully. The solution involved:

Grouping the running states by datafeedId.
Sorting the running states within each group based on creation time in descending order.
Keeping only the state for the most recent task (the first element after sorting) for each datafeedId.

Fixes #104160

@elasticsearchmachine elasticsearchmachine added v8.13.0 needs:triage Requires assignment of a team area label external-contributor Pull request authored by a developer outside the Elasticsearch team labels Jan 14, 2024
@pxsalehi pxsalehi added :ml Machine learning and removed needs:triage Requires assignment of a team area label labels Jan 16, 2024
@elasticsearchmachine elasticsearchmachine added the Team:ML Meta label for the ML team label Jan 16, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

@droberts195 droberts195 self-assigned this Jan 16, 2024
@droberts195 droberts195 changed the title GetDatafeedRunningStateAction can fail if multiple local datafeed tasks exist #104160 Jan 16, 2024
@droberts195
Copy link

droberts195 commented Jan 16, 2024

Thanks for the contribution @aishwarysingh7754.

Please could you push an extra file to your branch, called docs/changelog/104352.yaml and containing this:

pr: 104352
summary: Prevent get datafeeds stats API returning an error when local tasks are slow to stop
area: Machine Learning
type: bug
issues:
 - 104160

Also, you'll find that our automatic code formatter won't like the formatting changes you've made. We use an automatic code formatter because although nobody 100% likes the way it lays out the code it avoids all arguments about the best layout and avoids needless churn from people changing the layout.

To auto-format this change please run ./gradlew :x-pack:plugin:ml:spotlessApply from the top level of the repo. Then you'll be able to see what it changed and commit the changed file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug external-contributor Pull request authored by a developer outside the Elasticsearch team :ml Machine learning Team:ML Meta label for the ML team v9.4.0

6 participants