-
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
[Upgrade Assistant] Open And Close Slight Refactor #59890
[Upgrade Assistant] Open And Close Slight Refactor #59890
Conversation
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.
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
@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]); |
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.
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.
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.
Code changes LGTM. I tested again using the description provided in #58890, and validated everything is still working as expected.
@elasticmachine merge upstream |
* 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>
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* 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>
* 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) ...
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.