Skip to content

Conversation

@gwbrown
Copy link
Contributor

@gwbrown gwbrown commented Oct 18, 2018

The Move To Step API now checks to see if the target step is an
AsyncActionStep, and if so, runs it.

AsyncActionSteps are otherwise only run when they are entered by
executing the previous step, rather than periodically or on cluster state
updates, so if an AsyncActionStep was entered via the Move To Step API, ILM
would never touch that index again.

Fixes #34294

The Move To Step API now checks to see if the target step is an
AsyncActionStep, and if so, runs it.

Previously, AsyncActionSteps would only be run when they are entered by
executing the previous step, so if an AsyncActionStep was entered via
the Move To Step API, ILM would never touch that index again.
@gwbrown gwbrown added the :Data Management/ILM+SLM Index and Snapshot lifecycle management label Oct 18, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@Override
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
IndexMetaData newIndexMetaData = newState.metaData().index(indexMetaData.getIndex());
if (newIndexMetaData == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this occur due to batching of updates?

Copy link
Contributor

Choose a reason for hiding this comment

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

After talking with @DaveCTurner it seems like we won't have any batching here because batching occurs within the same instance of ClusterStateTaskExecutor and we don't implement batching ourselves here. However I think this check is still nice to have in case there are other factors at play.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be assert newIndexMetaData != null?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like David's suggestion here, as it suggests this should never happen more strongly than an if

Copy link
Contributor

Choose a reason for hiding this comment

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

An assert is less strong though? because the check will not be done in production code, only in tests.

If we can envisage any scenarios where the newState passed to this method can be different to the state we returned in execute() then I think this whould stay as an if statement so we don't end up in a situation where we have a NPE thrown here because the index was deleted. IF we are confident that this kind of scenario should never occur and assert is fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

right. I guess I don't see this hurting, so I won't block it, but it may be misleading to people new to the code to walk through state in which this may be possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could add something like assert false : "there should be no opportunity for the index to be deleted" inside the if - that way we can catch it in testing while still handling it in production if there's a case we missed. Does that sound reasonable, or is it too messy?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should leave this with the if statement so we are protected against NPEs. If we also want to add an assert to catch things in tests then that fine but I think the protection against a NPE in production should remain

Copy link
Contributor

@colings86 colings86 left a comment

Choose a reason for hiding this comment

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

Left a reply on your comment but this LGTM

@Override
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
IndexMetaData newIndexMetaData = newState.metaData().index(indexMetaData.getIndex());
if (newIndexMetaData == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

After talking with @DaveCTurner it seems like we won't have any batching here because batching occurs within the same instance of ClusterStateTaskExecutor and we don't implement batching ourselves here. However I think this check is still nice to have in case there are other factors at play.

@gwbrown
Copy link
Contributor Author

gwbrown commented Oct 24, 2018

@elasticmachine retest this please

@gwbrown gwbrown merged commit f6ac0e4 into elastic:index-lifecycle Oct 29, 2018
gwbrown added a commit that referenced this pull request Oct 29, 2018
The Move To Step API now checks to see if the target step is an
AsyncActionStep, and if so, runs it.

Previously, AsyncActionSteps would only be run when they are entered by
executing the previous step, so if an AsyncActionStep was entered via
the Move To Step API, ILM would never touch that index again.
@gwbrown gwbrown deleted the ilm/fix-move-to-step branch December 7, 2018 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/ILM+SLM Index and Snapshot lifecycle management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants