Skip to content

Fix deadloop in case of NP circular dependencies #47933

Merged
pgayvallet merged 7 commits intoelastic:masterfrom
pgayvallet:kbn-44762-np-circular-deadloop
Oct 17, 2019
Merged

Fix deadloop in case of NP circular dependencies #47933
pgayvallet merged 7 commits intoelastic:masterfrom
pgayvallet:kbn-44762-np-circular-deadloop

Conversation

@pgayvallet
Copy link
Copy Markdown
Contributor

Summary

  • Fixes a bug causing RangeError: Maximum call stack size exceeded when NP plugins had circular dependencies within their required dependency graph. Now display the same, more explicit error message that when we encounter a cycle in the optional dependencies.
  • Changes the error message in case of NP cyclic dependencies for something more explicit

Fixes #44762

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
@pgayvallet pgayvallet added Feature:Plugins Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes labels Oct 11, 2019
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@pgayvallet pgayvallet marked this pull request as ready for review October 11, 2019 10:23
@pgayvallet pgayvallet requested a review from a team as a code owner October 11, 2019 10:23
@pgayvallet pgayvallet requested a review from joshdover October 11, 2019 10:24

await expect(pluginsSystem.setupPlugins(setupDeps)).rejects.toMatchInlineSnapshot(
`[Error: Topological ordering of plugins did not complete, these edges could not be ordered: [["some-id",{}]]]`
`[Error: Topological ordering of plugins did not complete, cyclic dependency detected between: ["some-id"]]`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a weird message for a missing required dependency case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this message is for cyclic dependencies, not missing ones.

Copy link
Copy Markdown
Contributor

@mshustov mshustov Oct 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but we test here.

`setupPlugins` throws plugin has missing required dependency` 

if we assume that we cannot have missing deps we should remove this test

Copy link
Copy Markdown
Contributor Author

@pgayvallet pgayvallet Oct 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize, you are actually right. The error can also be thrown in case of missing dependencies.

However, in real case usage, it will never occurs as PluginService#shouldEnablePlugin will return false and therefor not adding the plugin to the pluginSystem, so PluginSystem#getTopologicallySortedPluginNames will never be called with missing deps.

So not sure how what is the best thing to do here. Should I remove the unit test because it's testing a non-existing scenario, or should I put a more generic error message like these plugins have cyclic or missing dependencies: ${edgesLeft}

I think the second option is still better. @restrry wdyt ?


await expect(pluginsSystem.setupPlugins(setupDeps)).rejects.toMatchInlineSnapshot(
`[Error: Topological ordering of plugins did not complete, these edges could not be ordered: [["depends-on-1",{}],["depends-on-2",{}]]]`
`[Error: Topological ordering of plugins did not complete, cyclic dependency detected between: ["depends-on-1","depends-on-2"]]`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we guarantee that they have circular dependencies? Probably both have missing deps.

Copy link
Copy Markdown
Contributor Author

@pgayvallet pgayvallet Oct 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the pluginSystem sorting algorithm. Plugin with missing dependencies are already evicted at this point. Unsorted Kahn Graph is pretty much a cyclic dependency yes. (but I only changed the error message here)

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Copy link
Copy Markdown
Contributor

@mshustov mshustov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still wait for the test to be updated/removed. #47933 (comment)

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@pgayvallet pgayvallet merged commit 01604db into elastic:master Oct 17, 2019
@pgayvallet pgayvallet added v7.6.0 and removed v7.5.0 labels Oct 17, 2019
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request Oct 17, 2019
* fix deadloop in case of cyclic dependencies

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* better error message in case of cyclic plugin dependency

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* add createPlugin helper for readability

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* add more complex test on discover cyclic deps

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* better error message

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
pgayvallet added a commit that referenced this pull request Oct 17, 2019
* fix deadloop in case of cyclic dependencies

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* better error message in case of cyclic plugin dependency

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* add createPlugin helper for readability

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* add more complex test on discover cyclic deps

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>

* better error message

Signed-off-by: pgayvallet <pierre.gayvallet@elastic.co>
@nreese nreese mentioned this pull request Oct 18, 2019
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:New Platform Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v7.6.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kibana crashes with RangeError: Maximum call stack size exceeded if there is a circular dependency between NP plugins

4 participants