-
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
Only migrate an index if necessary #124946
Comments
Pinging @elastic/kibana-core (Team:Core) |
An additional benefit of checking the mappings would be that we don't need to run the |
For reference... Here is where we calculate the md5 hash of every plugins mapping fields: https://github.com/elastic/kibana/blob/main/packages/core/saved-objects/core-saved-objects-migration-server-internal/src/core/build_active_mappings.ts#L27 And we have an existing |
We will have to remember that upgrades from 7.x to 8.x rewrite the _id of saved object types that become We would either have to add a check so that we still kick off a full migration if a type becomes Alternatively, we could audit all 8.x releases and confirm that there has been no changes to |
We know we will need to prevent changing more existing types to be shareable for other features (as we won't be able to support id rewriting), so I'd say checking / blocking |
Yes, that's a really nice way to add a technical control 😁 |
I know this probably implies more changes, but given we kinda already know we're planning on decoupling model version from Kibana version, would it make sense to go further and change the index naming to something not including the version number? We will likely need to do it later anyway, so now may be the correct option. WDTY @rudolf? (Hard not to troll here, but we could, idk, use a number-based versioning instead?) |
That would just be absurd 👎 |
Edit: in this scenario we'd detect that a version migration was already completed and update the existing index with the mappings of the new plugin. One useful feature of the version number in the index is that we block upgrades if that version number is newer. So if we remove it from the index we would have to put the Kibana version also into the mappings |
Fixes #124946 ## Summary Takes a step toward optimising our migration paths by only reindexing (an expensive operation) when needed by checking whether the current SO mappings have "changed". By "changed" we mean that we have detected a new md5 checksum of any registered saved object type relative to the hashes we have stored. ## How to test These changes are constrained to the `model.ts`, a test was added for correctly detecting that mappings are the same during the `INIT` phase to send us down the correct migration path. Additionally, we have a new Jest integration test `skip_reindex.test.ts` that runs Kibana and inspects the logs for the expected model transitions. Everything else should remain the same. ## Happy path for skipping reindex ``` RUN INIT IF !versionMigrationIsComplete AND !kibana indexBelongsToLaterVersion AND !waitForMigrationCompletion AND mappingsAreUnchanged THEN the migration operations must target the existing .kibana_x.y.z_001 index RUN PREPARE_COMPATIBLE_MIGRATION (new state) we remove old version aliases (prevent old reads/writes), and set the current version alias (prevent old migrations) SKIP LEGACY_SET_WRITE_BLOCK SKIP ... SKIP SET_SOURCE_WRITE_BLOCK SKIP ... SKIP REFRESH_TARGET RUN OUTDATED_DOCUMENTS_SEARCH_OPEN_PIT ... RUN MARK_VERSION_INDEX_READY DONE ``` ## Notes * This optimisation will only be triggered when there are no mappings changes AND we are upgrading to a new version. This does not cover all cases. In future we will make this more sophisticated by checking for incompatible changes to mappings and only reindexing when those occur. ## Related * #147503 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Gerard Soldevila <[email protected]>
In order to support different Kibana instances having different plugins enabled, the v2 migration algorithm had to perform a migration for every version, because even if instance 1 doesn't think any migrations are necessary, instance 2 might have a plugin which defines a migration for this version.
Given that we no longer support unknown saved object types #101351 I don't think there are any reasons that we need to run the migration on every upgrade. If the mappings have stayed the same, we could just add new version specific aliases to the existing index. This will improve the performance of migrations in the majority of cases,
but for some edge case configurations it could cause unexpected downtime once a plugin gets enabled
If a Kibana deployment has:Then, as soon as the plugin is enabled, Kibana will see that the indices are no longer up to date and will therefore cause downtime while performing a full migration because of the migration function/mapping changes in the newly enabled plugin.
This means we could have an alias like
.kibana_8.0.0
pointing to the index.kibana_7.16.0_001
which might seem wrong. We would have to educate users/support that this could be the expected behaviour. Alternatively we could clone the index into.kibana_8.0.0_001
but this seems expensive. Another alternative is to obfuscate the version by hashing the version number. Though at the end of the day this is internal implementation details that users shouldn't have to even know about so just keeping the existing index name with a version-specific alias seems simpler.This would be the first step towards scaling migration performance by having an index per saved object type #104081 It would also give immediate benefits since we typically migrate the task manager index much less frequently than the .kibana index.
The text was updated successfully, but these errors were encountered: