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
verify(controller, times(1)).saveErrorState(any(), any());
    }
    public void testTrialRunExtractsNonStateActions() {
        ReservedClusterStateHandler<Map<String, Object>> newStateMaker = new ReservedClusterStateHandler<>() {
            @Override
            public String name() {
                return "maker";
            }
            @Override
            public TransformState transform(Object source, TransformState prevState) throws Exception {
                ClusterState newState = new ClusterState.Builder(prevState.state()).build();
                return new TransformState(newState, prevState.keys());
            }
            @Override
            public Map<String, Object> fromXContent(XContentParser parser) throws IOException {
                return parser.map();
            }
        };
        ReservedClusterStateHandler<Map<String, Object>> exceptionThrower = new ReservedClusterStateHandler<>() {
            @Override
            public String name() {
                return "non-state";
            }
            @Override
            public TransformState transform(Object source, TransformState prevState) {
                return new TransformState(prevState.state(), prevState.keys(), (l) -> internalKeys(l));
            }
            private void internalKeys(ActionListener<NonStateTransformResult> listener) {
                listener.onResponse(new NonStateTransformResult(name(), Set.of("key non-state")));
            }