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

Corrupt Saved Object documents can cause a migration every time Kibana starts up #65612

Closed
rudolf opened this issue May 7, 2020 · 3 comments · Fixed by #91465
Closed

Corrupt Saved Object documents can cause a migration every time Kibana starts up #65612

rudolf opened this issue May 7, 2020 · 3 comments · Fixed by #91465
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Saved Objects Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@rudolf
Copy link
Contributor

rudolf commented May 7, 2020

When starting up, Kibana scans the .kibana alias/index for documents that require a migration. For each document being migrated, we do a basic validation that checks if the type and namespace in the id matches the type and namespace fields. If these don't match, we don't apply the migration and just write the document as-is. Because the document's migrationVersion wasn't bumped, the next time Kibana starts up it will again see outdated documents and start a new migration.

if (serializer.isRawSavedObject(raw)) {

Because the Saved Objects API ensures that written documents are always valid, this will only affect users which write saved object documents directly into Elasticsearch instead of using the Kibana API's.

As a first step we can add logging to highlight this case to users.

@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 May 7, 2020
@elasticmachine
Copy link
Contributor

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

@rudolf
Copy link
Contributor Author

rudolf commented May 7, 2020

This bug can also lead to data loss if multiple Kibana nodes are using the same Elasticsearch index. If one of the nodes are restarted while the other nodes accept writes, the restarted node will create a new .kibana_n+1 index and start migrating documents over to it. If old nodes update documents in .kibana_n which were already migrated by the restarted node, or create new documents, these writes will be lost once the restarted node moves the .kibana alias from .kibana_n to .kibana_n+1.

@rudolf
Copy link
Contributor Author

rudolf commented Jan 14, 2021

Once we complete #75780 Kibana upgrade migrations will fail if there are corrupt saved object documents encountered. Users will have to delete the corrupt document to proceed. This prevents hard to debug migration problems where we're unable to transform the corrupt document but still try persist it leading which might lead to a mappings exception.

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 Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants