-
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
SO migration v2: fail the migration early if unknown types are encountered #101351
Comments
Pinging @elastic/kibana-core (Team:Core) |
CC @jportner
I'm unsure how the
I think we would still be applying the |
Just a note that once we decide on a solution here and implement it, we need to go back and update the integration test that started this whole discussion: #100171 (Or alternately incorporate that test into the PR addressing this issue) |
No. Currently, the DocumentMigrator builds an object map containing migration info and transform functions for each known type (emphasis on line 370): kibana/src/core/server/saved_objects/migrations/core/document_migrator.ts Lines 363 to 412 in 827442b
You could modify that function to pass back both the object map and the |
Yea.. this may be tricky because we'll still need to assume that the unknown doc is following the SO document format, but I don't think we really have any other option here. |
This seems like a pretty low-risk assumption to make. The fact that we use strict mappings helps in this regard as well, though the document could still be missing many fields. But honestly, if a document is that 'corrupt' then someone probably should be taking a look at it manually rather than Kibana automatically deciding what to do with it. |
After a closer look, this seems unfortunately a little trickier than that. We're currently using the
Also, we're currently always updating this kibana/src/core/server/saved_objects/migrations/core/document_migrator.ts Lines 488 to 495 in 26272fa
If the main use cases are working fine, there are edge cases involving migrating a disabled type across the version it is supposed to be converted to multi-namespace that are causing issues. For instance:
There are two issues here if we do copy the unknown
For this specific problem, I think the correct solution is just to NOT migrate the document at all if an unknown document is encountered. That way, we're sure that all the references and/conversion transforms will be applied when the type is re-enabled and handled by the Note that to achieve this, we'll probably need to break the current (unused) assumption that a document can have multiple type, and remove this while loop here: kibana/src/core/server/saved_objects/migrations/core/document_migrator.ts Lines 486 to 499 in 26272fa
To be able to identify each document as a single and specific type, to be able to see if the type is, or not, known, as the behavior would differ in this case.
This one is way harder to solve. To be honest, I don't really have any good idea to address that, apart from splitting
Having this per-type boolean would allow to specifically flag which references were converted or not. That way, in the edge previously describe edge case, However... as the These are edge cases, but the risk of data corruption if such scenario is encountered is very real, so I think we can't really ignore them, and will have to find a proper solution. |
Note that a workaround for problem 2 (the really significant one) would be to check the references integrity of registered objects' references, and throw if a SO got references to an unknown type (given that we solve problem 1. by copying the unknown docs without migrating them at all) If not ideal, this would still allow to
|
This is starting feel like a very expensive and potentially dangerous use case to try to start supporting this late in the game. If it had been as simple as we were originally I lean towards going back and revisiting #101052 instead, but clarifying the criteria a bit. The main use case we have for disabling plugins is to debug when there is a performance problem. It seems to me that if a user disables a plugin and then later upgrades to a newer Kibana version without enabling that plugin again, it's safe to say that they don't need that data anymore and we can ask them to delete it. In other words, I don't think we need to support this:
The only case I think we really need to support is:
OR
So we should be able to refuse to upgrade if any documents of unknown types are found AND be able to remove the @kobelb Do you have any additional thoughts here? |
@joshdover do we have users hitting this bug? Could we postpone doing anything for the remainder of 7.x and starting in 8.0 explicitly block upgrades if there are any unknown saved-object types? Regardless of the answer to the prior question, how do our users delete the documents that were created by an uninstalled or disabled plugin? |
Probably? Though this behavior has been here quite some time and I haven't seen it be a significant source of support issues. However we don't have great visibility into it, so I'm not sure how frequent it's happening.
They would need to manually delete these documents from the index. Pre-system indices this is feasible for customers to do, which works out perfectly if we're ok with blocking upgrades when there are unknown types in 8.0 (where system indices will become strictly enforced). I think we could scope this issue to:
|
This seems reasonable to me. |
@pgayvallet are you 👍 on the above plan? |
Yea, that sounds good to me. Fail fast and avoid altering the source index's meta. |
See #101052 for the initial discussion
Currently, when migrating a document, if the associated SO type is not registered, the document is handled the same way as if it was from a higher Kibana version, and is therefor considered unable to be migrated, causing the whole migration to fail.
If this is not something new (this issue was still present in migration v1, as the 'culprit' is the
DocumentMigrator
used in both migrations algorithms), it is still quite problematic.The main problems are
What we want to do instead of failing is to copy the document into the temp/new index without migrating it (well, without migrating the
prop
of the unknown type, as we now have different kind of migrations)Technically, that needs to be done is to change the behavior of
nextUnmigratedProp
in theDocumentMigration
to skip migration of a type instead of failing when the type is not registeredkibana/src/core/server/saved_objects/migrations/core/document_migrator.ts
Lines 722 to 728 in 26272fa
If this may be as easy as removing the
!latestMigrationVersion
part, I suspect there may be subtle things to handle on the higher layers.Probably non exhaustive, but
migrationVersion
is preserved as it was previouslyoutdatedDocumentsQuery
is still alright)reference
transforms are still applied correctly (both inward and outward), either when the type is re-enabled, or during the unknown doc migrationNote that in case of multi-instance Kibana with different plugin sets, this could still cause issues, as if an instance without a plugin installed performs the migration last, the document in the new index will not be migrated (see #101052 (comment) for the detailed scenario), so we also need to consider (and probably document) that having multiple instances with different plugin sets is not something that we're supporting.
The text was updated successfully, but these errors were encountered: