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

Saved Object Migrations fail when a plugin is disabled #56731

Closed
rudolf opened this issue Feb 4, 2020 · 3 comments
Closed

Saved Object Migrations fail when a plugin is disabled #56731

rudolf opened this issue Feb 4, 2020 · 3 comments
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Saved Objects project:ResilientSavedObjectMigrations Reduce Kibana upgrade failures by making saved object migrations more resilient Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@rudolf
Copy link
Contributor

rudolf commented Feb 4, 2020

When Saved Object migrations run they update the Saved Object with a migrationVersion property like:

migrationVersion: {
  dashboard: '7.1.1',
  space: '6.6.0',
}

However, if a plugin that previously migrated data is later disabled, Saved Object Migrations will throw the following exception and Kibana will refuse to start.

Error: Document "default" has property "space" which belongs to a more recent version of Kibana (6.6.0).
at props.find.p (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:249:27)\n at Array.find

Note: disabling a plugin won't trigger a migration to run. But if there's other objects that are outdated these will trigger the migration to run which will then fail on the disabled plugin's migration.

I.e. disabling the spaces plugin, and running a version of Kibana which has a dashboard migration > 7.1.1 will trigger a migration, and then throw when attempting to migrate the above mentioned document.

This could also happen when importing Saved Objects.

Caused by:

// We verify that the version is not greater than the version supported by Kibana.
// If we didn't, this would cause an infinite loop, as we'd be unable to migrate the property
// but it would continue to show up as unmigrated.
// If we have a docVersion and the latestVersion is smaller than it or does not exist,
// we are dealing with a document that belongs to a future Kibana / plugin version.
if (docVersion && (!latestVersion || Semver.gt(docVersion, latestVersion))) {
throw Boom.badData(
`Document "${doc.id}" has property "${p}" which belongs to a more recent` +
` version of Kibana (${docVersion}).`,
doc
);
}

@rudolf rudolf added bug Fixes for quality problems that affect the customer experience Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:Saved Objects labels Feb 4, 2020
@elasticmachine
Copy link
Contributor

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

@pgayvallet
Copy link
Contributor

As discussed via slack, we should only use the migrationVersions of type that are known of the migrator. That way a disabled plugin would just not run it's associated migrations until re-enabled.

@rudolf rudolf added the project:ResilientSavedObjectMigrations Reduce Kibana upgrade failures by making saved object migrations more resilient label Nov 27, 2020
@rudolf
Copy link
Contributor Author

rudolf commented Nov 27, 2020

This will probably be fixed by #78413 since we will no longer read-transform-write every document. Instead we search for outdated documents and only update these, so if a plugin is disabled it's documents will no longer show up as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Saved Objects project:ResilientSavedObjectMigrations Reduce Kibana upgrade failures by making saved object migrations more resilient Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

3 participants