Today the `ReservedClusterStateService` decides whether or not to submit an update-error task depending on the content of the last-applied state as exposed by `ClusterService#state()`. This may happen concurrently with another state being published, so does not give a fully consistent view of the latest state. Instead it should check the state within the cluster state task executor, triggering a no-op update as appropriate.
server/src/test/java/org/elasticsearch/reservedstate/service/ReservedClusterStateServiceTests.java
nonStateTransformResults.stream().map(n -> n.handlerName()).collect(Collectors.toSet()),
                    containsInAnyOrder(expectedHandlers.toArray(new String[0]))
                );
                assertThat(
                    nonStateTransformResults.stream().map(n -> n.updatedKeys()).flatMap(Set::stream).collect(Collectors.toSet()),
                    containsInAnyOrder(expectedValues.toArray(new String[0]))
                );
            }
            @Override
            public void onFailure(Exception e) {
                fail("Shouldn't reach here");
            }
        });
    }
    class TestHandler implements ReservedClusterStateHandler<Map<String, Object>> {
        @Override
        public String name() {
            return ReservedClusterSettingsAction.NAME;
        }
        @Override
        public TransformState transform(Object source, TransformState prevState) {
            return prevState;
        }
        @Override
        public Map<String, Object> fromXContent(XContentParser parser) throws IOException {
            return parser.map();
        }
    }
}