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

[Discover]Fix infinite loop cause discover hang #8082

Merged
merged 3 commits into from
Sep 10, 2024

Conversation

Hailong-am
Copy link
Collaborator

@Hailong-am Hailong-am commented Sep 9, 2024

Description

Fix an infinite loop cause discover hang.

const handleIndexPattern = async () => {
if (isQueryEnhancementEnabled && query?.dataset) {
const pattern = await data.indexPatterns.get(query.dataset.id);
if (isMounted && pattern) {
setIndexPattern(pattern);
}
} else if (!isQueryEnhancementEnabled) {
if (!indexPatternIdFromState) {
const indexPatternList = await data.indexPatterns.getCache();
const newId = getIndexPatternId(
'',
indexPatternList || [],
uiSettings.get('defaultIndex')
);
if (isMounted) {
store!.dispatch(updateIndexPattern(newId));
handleIndexPattern();
}
} else {

From the url below, we can see indexPattern is empty string. Based on the logic above,
http://localhost:5601/app/data-explorer/discover#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'',view:discover))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))

If newId is empty, indexPatternIdFromState will be empty string, when line 64 handleIndexPattern(); execute, it will go to same condition path and have infinite loop.

Issues Resolved

#7626

Screenshot

Testing the changes

Changelog

  • fix: [Discover]Fix infinite loop cause discover hang

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 60.58%. Comparing base (dfc7def) to head (e81204f).
Report is 72 commits behind head on main.

Files with missing lines Patch % Lines
...ication/view_components/utils/use_index_pattern.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8082      +/-   ##
==========================================
- Coverage   60.58%   60.58%   -0.01%     
==========================================
  Files        3738     3738              
  Lines       88670    88670              
  Branches    13782    13782              
==========================================
- Hits        53725    53723       -2     
- Misses      31661    31662       +1     
- Partials     3284     3285       +1     
Flag Coverage Δ
Linux_1 28.76% <0.00%> (ø)
Linux_2 56.27% <ø> (ø)
Linux_3 37.51% <0.00%> (-0.01%) ⬇️
Linux_4 29.61% <ø> (ø)
Windows_1 28.77% <0.00%> (ø)
Windows_2 56.22% <ø> (ø)
Windows_3 37.51% <0.00%> (ø)
Windows_4 29.61% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@abbyhu2000 abbyhu2000 merged commit 5aaa00c into opensearch-project:main Sep 10, 2024
76 of 77 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 10, 2024
* fix infinit loop cause discovery hang

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* Changeset file for PR #8082 created/updated

---------

Signed-off-by: Hailong Cui <ihailong@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 5aaa00c)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 10, 2024
* fix infinit loop cause discovery hang

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* Changeset file for PR #8082 created/updated

---------

Signed-off-by: Hailong Cui <ihailong@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 5aaa00c)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ruanyl pushed a commit that referenced this pull request Sep 10, 2024
* fix infinit loop cause discovery hang



* Changeset file for PR #8082 created/updated

---------



(cherry picked from commit 5aaa00c)

Signed-off-by: Hailong Cui <ihailong@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
ruanyl pushed a commit that referenced this pull request Sep 10, 2024
* fix infinit loop cause discovery hang



* Changeset file for PR #8082 created/updated

---------



(cherry picked from commit 5aaa00c)

Signed-off-by: Hailong Cui <ihailong@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants