-
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
Invalid searchSourceJSON
causes saved object migration to fail
#78535
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6e6475c
Invalid `searchSourceJSON` causes saved object migration to fail
alexwizp 97e2201
Merge remote-tracking branch 'upstream/master' into #78530
alexwizp b0e1ac7
7.8.2 -> 7.9.3
alexwizp e4da267
return migration into 6.7.2
alexwizp 00e625f
Merge remote-tracking branch 'upstream/master' into #78530
alexwizp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I am not sure if we "can" remove (or should) old migrations. The problem is, that depending on from which version you then came, you'll either ran in 6.7.2 over that migration or not. E.g. you were updating from 6.6.0 to 7.6.0 and then 7.10.0, will give you different migrations then upgrading from 6.6.0 to 7.10.0. @rudolf Do you know if this is at all possible? If it's possible I still would like to hear your opinion on if we should do something like that, because this sounds like a horrible source for errors that we'll never be able to find later, since we removed old migrations from the code and won't see it when debugging?
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.
@timroes you highlighted a good question in general. It seems to me that wherever we add this migration script, there will still be questions.
Also, analyzing this particular script, I see no problems if it is executed in
7.8.
On the other hand, it seems strange to me to add in7.8
something that is valid for an upgrade from version5
to6
From my point of view we should keep version as it (6.7.2) and just a fix reason of an exception:
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.
My understanding is that this migration fixes a bug introduced in v5 (or a bug in the v6 migration). The version the data bug was introduced is irrelevant, the migration version captures when this migration was applied and the data was transformed and fixed. So a search document with a migrationVersion of 7.9.3 means that this data has been migrated and fixed in Kibana 7.9.3. And then we know that any kibana > 7.9.3 can safely consume this document knowing it has the expected shape.
What complicates matters here is that we first released this migration in v7.8.0 as "6.7.2". As Joe pointed out in the original PR this means that this migration would not have been applied to documents which for instance had already been upgraded to v7.4.0 because we only apply newer migrations. So if someone created a v5 document with this bug (or however you reproduce the original issue) and then upgraded through some path to v7.4.0 this transformation will not be applied when they later upgrade to > v7.8.0
So there are two issues which should be addressed, one is correctly handling invalid JSON, the other is making sure that this migration is applied to all documents. To get this migration applied to all versions we need to set it's version to the oldest Kibana this will get released in (e.g. 7.9.3).
Since the "new" 7.9.3 migration is the same as the 6.7.2 migration, anyone running Kibana > 7.9.3 will always have this migration applied (perhaps it's applied twice, but that's fine).
However removing the migration might still be a bad idea because it makes it harder to find and debug because it's no longer in the
master
codebase. So I can see some benefit in keeping the 6.7.2 migration just as a historic reference so that if someone ever wonders why a document had a migration applied with v6.7.2 they'll be able to find that migration in the codebase. We would then have two identical migration scripts with different versions.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.
The other option is to not have duplicate migrations but just have a big comment block in the code above the 7.9.3 migration stating that at some point this was released as a 6.7.2 migration and later changed.
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.
I think the "traceability" here would outrule that small performance drawback of running that other (same) migration in 6.7.2 and as far as I understand there'll be no other drawback to it, why I'd suggest we're not removing it, but instead keeping it for the old version.
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.
Agreed, I also prefer the better traceability of duplicate migrations.