-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[ML] Single metric viewer: Fix race condition when changing jobs. #45420
[ML] Single metric viewer: Fix race condition when changing jobs. #45420
Conversation
Pinging @elastic/ml-ui |
💔 Build Failed |
} | ||
|
||
function showFlyout() { | ||
function showFlyout(setSkipRefresh = true) { |
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.
Wouldn't it be more intuitive to have setSkipRefresh = false
and then send in true
when we want to set 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.
My intention was to have it default to true
because it is the default behaviour and therefore in the usual cases where it's used and e.g. passed on as a prop like onClose={closeFlyout}
doesn't need wrapping in another callback and no code change to set it to true. The only time we need it to be false
is inside applySelection
where we call closeFlyout
directly and can easily pass on the flag.
x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js
Show resolved
Hide resolved
💔 Build Failed |
With these first couple of commits I can no longer produce the original issues (focus chart blank, or wrong entity dropdowns, when switching jobs). But I now see a new issue where the focus chart is blank after changing the end time of a job. Here an example using gallery data. This happens even with refresh turned off: |
…bana into ml-fix-job-selection-refresh
@peteharverson I addressed the issue you're seeing in ffcccbc, please have another look. |
💔 Build Failed |
@peteharverson b0eddb5 has a fix for the issue where applying the same job with job selector wouldn't update the time range. |
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.
Left a comment about getting a blank page when navigating to the single metric viewer with a farequote job.
💔 Build Failed |
@alvarezmelissa87 @peteharverson 0dbd337 fixes the rendering loop with blank page you found. |
💔 Build Failed |
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.
Tested the latest edit, and confirm it fixes the previous issue I was seeing with the infinite loop for multi metric jobs. LGTM!
💔 Build Failed |
💔 Build Failed |
Tested the latest changes and wasn't able to reproduce any of the previous issues. Thank you @walterra 🙌 |
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
…bana into ml-fix-job-selection-refresh
💚 Build Succeeded |
…astic#45420) Fixes a race condition where changing jobs in Single Metric Viewer could result in the focus chart being empty. Applying the job change would cause two events to be triggered which would cause the Single Metric Viewer to refresh twice: The updated time range would be triggered via timefilter, the updated jobs via the globalState listener. This PR solves the problem by setting a global flag skipRefresh which allows us to skip updating single metric viewer and only update again once both the new time range and jobs are set. The PR also adds some checks to avoid unnecessary updates in d3 code triggered by React render calls.
…astic#45420) Fixes a race condition where changing jobs in Single Metric Viewer could result in the focus chart being empty. Applying the job change would cause two events to be triggered which would cause the Single Metric Viewer to refresh twice: The updated time range would be triggered via timefilter, the updated jobs via the globalState listener. This PR solves the problem by setting a global flag skipRefresh which allows us to skip updating single metric viewer and only update again once both the new time range and jobs are set. The PR also adds some checks to avoid unnecessary updates in d3 code triggered by React render calls.
…5420) (#45643) Fixes a race condition where changing jobs in Single Metric Viewer could result in the focus chart being empty. Applying the job change would cause two events to be triggered which would cause the Single Metric Viewer to refresh twice: The updated time range would be triggered via timefilter, the updated jobs via the globalState listener. This PR solves the problem by setting a global flag skipRefresh which allows us to skip updating single metric viewer and only update again once both the new time range and jobs are set. The PR also adds some checks to avoid unnecessary updates in d3 code triggered by React render calls.
…5420) (#45644) Fixes a race condition where changing jobs in Single Metric Viewer could result in the focus chart being empty. Applying the job change would cause two events to be triggered which would cause the Single Metric Viewer to refresh twice: The updated time range would be triggered via timefilter, the updated jobs via the globalState listener. This PR solves the problem by setting a global flag skipRefresh which allows us to skip updating single metric viewer and only update again once both the new time range and jobs are set. The PR also adds some checks to avoid unnecessary updates in d3 code triggered by React render calls.
Summary
Part of #42909.
Fixes a race condition where changing jobs in Single Metric Viewer could result in the focus chart being empty.
Applying the job change would cause two events to be triggered which would cause the Single Metric Viewer to refresh twice: The updated time range would be triggered via
timefilter
, the updated jobs via theglobalState
listener.This PR solves the problem by setting a global flag
skipRefresh
which allows us to skip updating single metric viewer and only update again once both the new time range and jobs are set. The PR also adds some checks to avoid unnecessary updates ind3
code triggered by React render calls.I'm not sure polluting the
globalState
with this flag is the best approach but it allowed me to implement the fix for7.4
with the least code changes. For7.5
maybe we can find a better solution, for example using an observable that keeps track of it.Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n supportDocumentation was added for features that require explanation or tutorialsUnit or functional tests were updated or added to match the most common scenarioslegacy code covered by manual testsThis was checked for keyboard-only and screenreader accessibilityFor maintainers