In https://github.com/elastic/elasticsearch/pull/78547 we introduced batching for the ILM master tasks that occur on the happy path. However if a high-shard-count cluster encounters problems while doing ILM-related things—perhaps some nodes are temporarily unavailable for taking a snapshot—then we process the resulting `ilm-retry-failed-step` and `ilm-move-to-error-step` tasks one-by-one which can significantly delay the cluster's recovery from its problems.

We should batch these things together too.

It looks like we also enqueue duplicate `ilm-retry-failed-step` on each poll interval too, although we do appear to treat the duplicates as no-ops at execution time.

Relates https://github.com/elastic/elasticsearch/issues/77466
x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/MoveToErrorStepUpdateTask.java
} else {
            
            
            
            return currentState;
        }
    }
    @Override
    public void clusterStateProcessed(ClusterState oldState, ClusterState newState) {
        if (newState.equals(oldState) == false) {
            stateChangeConsumer.accept(newState);
        }
    }
    @Override
    public void onFailure(Exception e) {
        final MessageSupplier messageSupplier = () -> new ParameterizedMessage(
            "policy [{}] for index [{}] failed trying to move from step [{}] to the ERROR step.",
            policy,
            index.getName(),
            currentStepKey
        );
        if (ExceptionsHelper.unwrap(e, NotMasterException.class, FailedToCommitClusterStateException.class) != null) {
            logger.debug(messageSupplier, e);
        } else {
            logger.error(messageSupplier, e);
            assert false : new AssertionError("unexpected exception", e);
        }
    }
}