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

Use PiT for outdated document search #98797

Merged
merged 17 commits into from
May 4, 2021

Conversation

mshustov
Copy link
Contributor

@mshustov mshustov commented Apr 29, 2021

Summary

Part of #90279
PR adds PiT usage when searching for outdated docs. I removed refresh: wait_for to reduce reindex overhead. Instead, Kibana does manual refresh after all the docs were transformed (for both index migration and outdated documents migration).

Checklist

Delete any items that are not applicable to this PR.

@mshustov mshustov added chore v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.14.0 project:ResilientSavedObjectMigrations Reduce Kibana upgrade failures by making saved object migrations more resilient labels Apr 29, 2021
* index for backup purposes, but won't be available in the upgraded index.
*/
unusedTypesQuery: Option.Option<estypes.QueryContainer>,
query: estypes.QueryContainer | undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always defined, so I removed the Option container

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update the readWithPit description?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always defined

Why the | undefined then? For testing purposes?

Was the comment meant for reindex, L586, where you changed from Option.Option<estypes.QueryContainer> to estypes.QueryContainer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the | undefined then? For testing purposes?

Was the comment meant for reindex, L586, where you changed from Option.Option<estypes.QueryContainer> to estypes.QueryContainer?

yes for both


export type FatalState = BaseState & {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it improves TS performance

@@ -997,6 +1008,8 @@ interface SearchForOutdatedDocumentsOptions {
* Search for outdated saved object documents with the provided query. Will
* return one batch of documents. Searching should be repeated until no more
* outdated documents can be found.
*
* Used for testing only
Copy link
Contributor Author

@mshustov mshustov May 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can move it to testing tools in a follow-up

Actions.readWithPit(
client,
state.pitId,
state.outdatedDocumentsQuery,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't use unusedTypesQuery because target index already contains filtered SO types

@mshustov mshustov marked this pull request as ready for review May 3, 2021 17:36
@mshustov mshustov requested a review from a team as a code owner May 3, 2021 17:36
Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review only: Implementation looks solid and the logic flow makes sense.
I left a few comments and questions but these shouldn't hold up the PR.
LGTM

* index for backup purposes, but won't be available in the upgraded index.
*/
unusedTypesQuery: Option.Option<estypes.QueryContainer>,
query: estypes.QueryContainer | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update the readWithPit description?

Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

* index for backup purposes, but won't be available in the upgraded index.
*/
unusedTypesQuery: Option.Option<estypes.QueryContainer>,
query: estypes.QueryContainer | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always defined

Why the | undefined then? For testing purposes?

Was the comment meant for reindex, L586, where you changed from Option.Option<estypes.QueryContainer> to estypes.QueryContainer?

Comment on lines +932 to +941
const readWithPitTask = readWithPit(
client,
pitResponse.right.pitId,
{
match: { title: { query: 'doc' } },
},
1000,
undefined,
true
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to switch to an object argument the next time we touch this code, argument list is hard to follow without seing the signature (undefined, true). For consistency, we may even want to do that for all actions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +973 to +977
expect.not.objectContaining({
_seq_no: expect.any(Number),
_primary_term: expect.any(Number),
}),
])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Test will pass if _seq_no or _primary_term exist but it not a number. I would rather test for property existence here. OTOH, by the ES spec, these properties are numbers, so it's probably fine as it is.

Comment on lines +59 to +60
// contains migrated index with 8.0 aliases to skip migration, but run outdated doc search
dataArchive: Path.join(__dirname, 'archives', '8.0.0_migrated_with_outdated_docs.zip'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with 8.0 aliases

We'll probably need to disable this test in the 7.x branch, as I think it will fail because the alias points to an higher version of Kibana?

But I don't see any other option to test such scenario on master.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed offline: it's okay to skip the test on 7.x branch to reduce the maintenance cost of different fixtures for 8 and 7.x branches

@mshustov mshustov enabled auto-merge (squash) May 4, 2021 07:45
@mshustov mshustov added the auto-backport Deprecated - use backport:version if exact versions are needed label May 4, 2021
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@mshustov mshustov merged commit c815e4c into elastic:master May 4, 2021
@mshustov mshustov deleted the migration-outdated-docs-search-pit branch May 4, 2021 09:53
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request May 4, 2021
* use PiT for OUTDATED_DOCUEMENT_SEARCH step

* update tests

* fix typo

* fix so migrations unit tests

* TEMP: use wait_for when transformin docs

* add a step to refresh target index if transformed outdated docs

* add unit tests

* refresh before searching outdated docs

* add integration test for outdated docs migration

* add a step to refresh target index if transformed outdated docs

* make query required

* address comments
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request May 4, 2021
* Use PiT for outdated document search (#98797)

* use PiT for OUTDATED_DOCUEMENT_SEARCH step

* update tests

* fix typo

* fix so migrations unit tests

* TEMP: use wait_for when transformin docs

* add a step to refresh target index if transformed outdated docs

* add unit tests

* refresh before searching outdated docs

* add integration test for outdated docs migration

* add a step to refresh target index if transformed outdated docs

* make query required

* address comments

* skip test

Co-authored-by: Mikhail Shustov <restrry@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed chore project:ResilientSavedObjectMigrations Reduce Kibana upgrade failures by making saved object migrations more resilient release_note:skip Skip the PR/issue when compiling release notes v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants