-
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
Fix SO export sorting algorithm #142078
Fix SO export sorting algorithm #142078
Conversation
traversed.add(objectId); | ||
if (objectRefs.length) { | ||
includeObjects(objectRefs); |
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.
This is the significant change of the PR, the rest of the diff in this file is just minor enhancement/cleanup.
Previously, we were removing the current object from the 'path' when we're done traversing the children, causing the algo to eventually traverse the whole tree again if the same object is encountered in the tree of another node from a higher level.
Once a object has been traversed once, we now keep it in the path
list (renamed to traversed
as it better reflect its role now), avoiding the full traversal again later.
test('should not fail on large graph of objects', () => { | ||
// create an object that references all objects with a higher `index` up to `depth`. | ||
const createComplexNode = (index: number, depth: number): SavedObject => { |
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.
Tried it without the fix, and the test does timeout.
const firstMockHits = generateHits(1000, { sort: ['a', 'b'] }); | ||
const secondMockHits = generateHits(500); | ||
const secondMockHits = generateHits(500, { idPrefix: 'second-hit-' }); |
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.
This test was generating multiple pages of SOs with duplicate ids. The fix performed in this PR also has the impact of removing duplicates from top level / initial objects. Note that this will never occur in production given we are removing duplicates from the top level exported objects anyway.
Pinging @elastic/kibana-core (Team:Core) |
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.
🎉
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
* Fix SO export sorting algorithm * improve var name * adapt another unit test Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit 4cdd74d)
* Fix SO export sorting algorithm * improve var name * adapt another unit test Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit 4cdd74d)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
* Fix SO export sorting algorithm * improve var name * adapt another unit test Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit 4cdd74d) Co-authored-by: Pierre Gayvallet <[email protected]>
Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync. |
* Fix SO export sorting algorithm * improve var name * adapt another unit test Co-authored-by: Kibana Machine <[email protected]>
* Fix SO export sorting algorithm (#142078) * Fix SO export sorting algorithm * improve var name * adapt another unit test Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit 4cdd74d) * fix import for 7.x Co-authored-by: Pierre Gayvallet <[email protected]>
Summary
Fix #142055
Release note
Fix a bug causing the savedObjects 'export' and 'copy to space' features to sometimes cause Kibana to crash for very complex graphs of objects.