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

[Upgrade Assistant] Open And Close Slight Refactor #59890

Merged
merged 5 commits into from
Mar 12, 2020

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Mar 11, 2020

Summary

After merging #58890, I realised that if we set openAndClose on a reindex operation when it gets created and that reindex operation waits on a queue for a long time the edge case could arise that the index is opened before it is processed by the reindex worker. In that situation the reindex service would read the reindex options, attempt to open the already open index (which is fine) and then later close the open index which it thought it opened, leaving the open index closed again.

This PR just moves the point at which we check for the index being closed to just before it is reindexed to reduce the chances of this happening.

We should rather only check if an index is currently closed the
moment before starting to reindex. We still store a flag to
indicate that we opened an index that was closed, but this
should not be set from the reindex handlers because the reindex
task may only start some time later in which case the closed
index could have been opened and our reindex job will open it
and close it again.
@jloleysens jloleysens added v8.0.0 Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes Feature:Upgrade Assistant v7.7.0 labels Mar 11, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@@ -317,7 +321,10 @@ export const reindexServiceFactory = (
const startReindexing = async (reindexOp: ReindexSavedObject) => {
const { indexName, reindexOptions } = reindexOp.attributes;

if (reindexOptions?.openAndClose === true) {
const indicesState = await esIndicesStateCheck(callAsUser, [indexName]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth adding a comment here to reflect your thoughts in the PR description? For example:

// Where possible, derive reindex options at the last moment before reindexing
// to prevent them from becoming stale as they wait in the queue.

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

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

Code changes LGTM. I tested again using the description provided in #58890, and validated everything is still working as expected.

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@jloleysens jloleysens merged commit abc14f5 into elastic:master Mar 12, 2020
@jloleysens jloleysens deleted the ua/refactor/open-and-close branch March 12, 2020 10:39
jloleysens added a commit to jloleysens/kibana that referenced this pull request Mar 12, 2020
* Refactor: Move checking of closed index to single point

We should rather only check if an index is currently closed the
moment before starting to reindex. We still store a flag to
indicate that we opened an index that was closed, but this
should not be set from the reindex handlers because the reindex
task may only start some time later in which case the closed
index could have been opened and our reindex job will open it
and close it again.

* Added debug log

* Added comment

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

jloleysens added a commit that referenced this pull request Mar 12, 2020
* Refactor: Move checking of closed index to single point

We should rather only check if an index is currently closed the
moment before starting to reindex. We still store a flag to
indicate that we opened an index that was closed, but this
should not be set from the reindex handlers because the reindex
task may only start some time later in which case the closed
index could have been opened and our reindex job will open it
and close it again.

* Added debug log

* Added comment

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Mar 12, 2020
* master: (45 commits)
  skip flaky suite (elastic#59717)
  UI Metrics use findAll to retrieve all Saved Objects (elastic#59891)
  [Discover] Migrate Context mocha tests to use Jest (elastic#59658)
  [Maps] Move redux reducers and store logic to NP (elastic#58294)
  rebalance x-pack groups (elastic#58930)
  [Discover] Reimplement $route.reload when index pattern changes (elastic#59877)
  [Upgrade Assistant Meta] Breaking changes issue template (elastic#59745)
  Skip CI based on changes in PR (elastic#59939)
  [ML] Transforms: Replace KqlFilterBar with QueryStringInput. (elastic#59723)
  [ML] Functional tests - stabilize date_nanos test (elastic#59986)
  [ML] Typescripting client side endpoint functions (elastic#59928)
  a11y tests on adding columns to discover table (elastic#59375)
  fix graph plugin config path (elastic#59540)
  fix vega config issues (elastic#59737)
  [Upgrade Assistant] Open And Close Slight Refactor (elastic#59890)
  [ML] Adding shared services to ml setup contract (elastic#59730)
  [Visualize] Fix linked search behavior (elastic#59690)
  [ML] Register NP ML plugin for Kibana management section. (elastic#59762)
  [Lens] Adds using queries/filters for field existence endpoint (elastic#59033)
  Delete FilterStateManager and QueryFilter :-D (elastic#59872)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Upgrade Assistant release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants