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/IndexLifecycleRunner.java
currentStep = getCurrentStep(stepRegistry, policy, indexMetadata, lifecycleState);
        } catch (Exception e) {
            markPolicyRetrievalError(policy, indexMetadata.getIndex(), lifecycleState, e);
            return;
        }
        if (currentStep == null) {
            Step.StepKey currentStepKey = Step.getCurrentStepKey(lifecycleState);
            if (TerminalPolicyStep.KEY.equals(currentStepKey)) {
                
                
                
                return;
            }
            logger.warn("current step [{}] for index [{}] with policy [{}] is not recognized", currentStepKey, index, policy);
            return;
        }
        logger.trace(
            "[{}] maybe running async action step ({}) with current step {}",
            index,
            currentStep.getClass().getSimpleName(),
            currentStep.getKey()
        );
        if (currentStep.getKey().equals(expectedStepKey) == false) {
            throw new IllegalStateException(
                "expected index ["
                    + indexMetadata.getIndex().getName()
                    + "] with policy ["
                    + policy
                    + "] to have current step consistent with provided step key ("
                    + expectedStepKey