Rewriting SO id during migration#97222
Merged
mshustov merged 40 commits intoelastic:masterfrom Apr 26, 2021
Merged
Conversation
required to enforce idempotent id generation for SO
mshustov
commented
Apr 15, 2021
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('creates a V2 migrator that initializes a new index and migrates an existing index', async () => { |
Contributor
Author
There was a problem hiding this comment.
the implementation is tested in the integration tests
mshustov
commented
Apr 15, 2021
| transformRawDocs: TransformRawDocs, | ||
| outdatedDocuments: SavedObjectsRawDoc[], | ||
| index: string, | ||
| refresh: estypes.Refresh |
Contributor
Author
There was a problem hiding this comment.
I'd move to named arguments instead, but let's do it in a separate PR for all the actions at once
mshustov
commented
Apr 15, 2021
rudolf
reviewed
Apr 15, 2021
Contributor
rudolf
left a comment
There was a problem hiding this comment.
Did a quick first pass and the implementation looks very solid!
src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.ts
Show resolved
Hide resolved
mshustov
commented
Apr 20, 2021
| import _ from 'lodash'; | ||
| import { estypes } from '@elastic/elasticsearch'; | ||
| import { MigrationEsClient } from './migration_es_client'; | ||
| import { CountResponse, SearchResponse } from '../../../elasticsearch'; |
Contributor
Author
There was a problem hiding this comment.
no changes in the file, a simple cleanup
mshustov
commented
Apr 20, 2021
mshustov
commented
Apr 20, 2021
| await new Promise((resolve) => setTimeout(resolve, 10000)); | ||
| }); | ||
|
|
||
| it('rewrites id deterministically for SO with namespaceType: "multiple" and "multiple-isolated"', async () => { |
Contributor
Author
There was a problem hiding this comment.
mshustov
commented
Apr 20, 2021
| "title": "test_index*" | ||
| }, | ||
| "type": "test_index*" | ||
| "type": "index-pattern" |
Contributor
Author
There was a problem hiding this comment.
invalid type that used to fail migration.
1 task
…st test file during cleanup phase
… the first test file during cleanup phase" This reverts commit a128d7b.
jportner
suggested changes
Apr 25, 2021
src/core/server/saved_objects/migrations/core/document_migrator.ts
Outdated
Show resolved
Hide resolved
This reverts commit 97315b6.
Contributor
Author
|
@jportner reverted, I will skip the test on |
Contributor
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
mshustov
added a commit
to mshustov/kibana
that referenced
this pull request
Apr 26, 2021
* some typos * implement an alternative client-side migration algorithm required to enforce idempotent id generation for SO * update tests * lol * remove unnecessary param from request generic * remove unused parameter * optimize search when quierying SO for migration * fix wrong type in fixtures * try shard_doc asc * add an integration test * cleanup * track_total_hits: false to improve perf * add happy path test for transformDocs action * remove unused types * fix wrong typing * add cleanup phase * add an integration test for cleanup phase * add unit-tests for cleanup function * address comments * Fix functional test * set defaultIndex before each test. otherwise it is deleted in the first test file during cleanup phase * sourceIndex: Option.some<> for consistency * Revert "set defaultIndex before each test. otherwise it is deleted in the first test file during cleanup phase" This reverts commit a128d7b. * address comments from Pierre * fix test * Revert "fix test" This reverts commit 97315b6. * revert min convert version back to 8.0 Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
mshustov
added a commit
that referenced
this pull request
Apr 26, 2021
* Rewriting SO id during migration (#97222) * some typos * implement an alternative client-side migration algorithm required to enforce idempotent id generation for SO * update tests * lol * remove unnecessary param from request generic * remove unused parameter * optimize search when quierying SO for migration * fix wrong type in fixtures * try shard_doc asc * add an integration test * cleanup * track_total_hits: false to improve perf * add happy path test for transformDocs action * remove unused types * fix wrong typing * add cleanup phase * add an integration test for cleanup phase * add unit-tests for cleanup function * address comments * Fix functional test * set defaultIndex before each test. otherwise it is deleted in the first test file during cleanup phase * sourceIndex: Option.some<> for consistency * Revert "set defaultIndex before each test. otherwise it is deleted in the first test file during cleanup phase" This reverts commit a128d7b. * address comments from Pierre * fix test * Revert "fix test" This reverts commit 97315b6. * revert min convert version back to 8.0 Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co> * skip id rewriting test Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
This was referenced Apr 29, 2021
This was referenced Jun 29, 2021
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implementation is based on algorithm changes described in #93002
TLDR: Kibana doesn't reindex SO in ES, but instead loads them from Elasticsearch server, transforms, rewrites
idfor SO registered withnamespace: multipleandnamespace: multiple-isolated, writes SO back to Elasticsearch server.Performance concerns.
Tested on the migration of 100 000 SavedObjects https://github.com/elastic/kibana/blob/6712bc07279c9582094d31eb22ebf72bdfaba2f7/src/core/server/saved_objects/migrationsv2/integration_tests/migration_7.7.2_xpack_100k.test.ts
Performance seems to be better in the worst-case scenario when we have a lot of outdated documents, as
readWithPitseems to be more performant thansearchForOutdatedDocuments. See logs:Master
batchSize
1_000:154secmigration_test_kibana.log
batchSize
10_000:104secBranch
batchSize
1_000:97secmigration_test_kibana.log
batchSize
10_000:105secChecklist
Delete any items that are not applicable to this PR.