[ 
https://issues.apache.org/jira/browse/FLINK-8721?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16408471#comment-16408471
 ] 

ASF GitHub Bot commented on FLINK-8721:
---------------------------------------

Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5737#discussion_r176212439
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionGraph.java
 ---
    @@ -763,48 +764,32 @@ public Executor getFutureExecutor() {
                return userAccumulators;
        }
     
    -   /**
    -    * Gets the accumulator results.
    -    */
    -   public Map<String, Object> getAccumulators() {
    -
    -           Map<String, Accumulator<?, ?>> accumulatorMap = 
aggregateUserAccumulators();
    -
    -           Map<String, Object> result = new HashMap<>();
    -           for (Map.Entry<String, Accumulator<?, ?>> entry : 
accumulatorMap.entrySet()) {
    -                   result.put(entry.getKey(), 
entry.getValue().getLocalValue());
    -           }
    -
    -           return result;
    -   }
    -
        /**
         * Gets a serialized accumulator map.
         * @return The accumulator map with serialized accumulator values.
         */
        @Override
        public Map<String, SerializedValue<Object>> getAccumulatorsSerialized() 
{
    +           return aggregateUserAccumulators()
    +                   .entrySet()
    +                   .stream()
    +                   .collect(Collectors.toMap(Map.Entry::getKey, entry -> 
serializeAccumulator(entry.getKey(), entry.getValue())));
    +   }
     
    -           Map<String, Accumulator<?, ?>> accumulatorMap = 
aggregateUserAccumulators();
    -
    -           Map<String, SerializedValue<Object>> result = new 
HashMap<>(accumulatorMap.size());
    -           for (Map.Entry<String, Accumulator<?, ?>> entry : 
accumulatorMap.entrySet()) {
    -
    +   private static SerializedValue<Object> serializeAccumulator(String 
name, Accumulator<?, ?> accumulator) {
    +           try {
    +                   if (accumulator instanceof FailedAccumulator) {
    +                           return new SerializedValue<>(accumulator);
    +                   }
    +                   return new 
SerializedValue<>(accumulator.getLocalValue());
    +           } catch (IOException ioe) {
    +                   LOG.error("Could not serialize accumulator " + name + 
'.', ioe);
                        try {
    -                           final SerializedValue<Object> serializedValue = 
new SerializedValue<>(entry.getValue().getLocalValue());
    -                           result.put(entry.getKey(), serializedValue);
    -                   } catch (IOException ioe) {
    -                           LOG.error("Could not serialize accumulator " + 
entry.getKey() + '.', ioe);
    -
    -                           try {
    -                                   result.put(entry.getKey(), new 
SerializedValue<>(new FailedAccumulatorSerialization(ioe)));
    -                           } catch (IOException e) {
    -                                   throw new RuntimeException("It should 
never happen that we cannot serialize the accumulator serialization 
exception.", e);
    -                           }
    +                           return new SerializedValue<>(new 
FailedAccumulator(ioe));
    --- End diff --
    
    Hmm, the problem I see here is that in the success case, we store the 
accumulator value and in the failure case we store an `Accumulator` instance. 
Thus, the user will expect the accumulator value and casting it accordingly. 
Thus he will never call the `Accumulator` methods which will throw the 
exceptions (see `JobExecutionResult` for how the user interacts with the 
accumulator values). In that sense the previous solution with storing a 
`FailedAccumulatorSerialization` was also flawed.
    
    What we actually would have to store in the `SerializedValue` is something 
like an `Either<Throwable, V>`. On the client side when accessing the 
`accumulatorsValueMap` it should check whether it is left or right and in the 
left case throw the exception.
    
    Alternatively, we say that an accumulator failure always results in a job 
failure. This means that in `JobMaster#jobStatusChanged` we generate a failed 
`ArchivedExecutionGraph` in case of an accumulator failure.


> Client blocks indefinitely if job archiving fails
> -------------------------------------------------
>
>                 Key: FLINK-8721
>                 URL: https://issues.apache.org/jira/browse/FLINK-8721
>             Project: Flink
>          Issue Type: Improvement
>          Components: Client, JobManager
>    Affects Versions: 1.5.0
>            Reporter: Chesnay Schepler
>            Assignee: Piotr Nowojski
>            Priority: Blocker
>              Labels: flip-6
>             Fix For: 1.5.0
>
>
> While porting the  {{AccumulatorErrorITCase}} i noticed that, for FLIP-6, if 
> the job archiving fails (in this case due to a custom accumulator throwing an 
> exception in #merge) no response is sent to the client.
> {code}
> 3547 [flink-akka.actor.default-dispatcher-2] ERROR 
> org.apache.flink.runtime.rpc.akka.FencedAkkaRpcActor  - Caught exception 
> while executing runnable in main thread.
> org.apache.flink.test.accumulators.AccumulatorErrorITCase$CustomException
>       at 
> org.apache.flink.test.accumulators.AccumulatorErrorITCase$FaultyAccumulator.clone(AccumulatorErrorITCase.java:113)
>       at 
> org.apache.flink.test.accumulators.AccumulatorErrorITCase$FaultyAccumulator.clone(AccumulatorErrorITCase.java:107)
>       at 
> org.apache.flink.api.common.accumulators.AccumulatorHelper.mergeInto(AccumulatorHelper.java:52)
>       at 
> org.apache.flink.runtime.executiongraph.ExecutionJobVertex.getAggregatedUserAccumulatorsStringified(ExecutionJobVertex.java:599)
>       at 
> org.apache.flink.runtime.executiongraph.ArchivedExecutionJobVertex.<init>(ArchivedExecutionJobVertex.java:49)
>       at 
> org.apache.flink.runtime.executiongraph.ExecutionJobVertex.archive(ExecutionJobVertex.java:612)
>       at 
> org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph.createFrom(ArchivedExecutionGraph.java:313)
>       at 
> org.apache.flink.runtime.jobmaster.JobMaster.jobStatusChanged(JobMaster.java:985)
>       at 
> org.apache.flink.runtime.jobmaster.JobMaster.access$1400(JobMaster.java:136)
>       at 
> org.apache.flink.runtime.jobmaster.JobMaster$JobManagerJobStatusListener.lambda$jobStatusChanges$0(JobMaster.java:1181)
>       at 
> org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleRunAsync(AkkaRpcActor.java:292)
>       at 
> org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleMessage(AkkaRpcActor.java:147)
>       at 
> org.apache.flink.runtime.rpc.akka.FencedAkkaRpcActor.handleMessage(FencedAkkaRpcActor.java:66)
>       at 
> org.apache.flink.runtime.rpc.akka.AkkaRpcActor.lambda$onReceive$0(AkkaRpcActor.java:129)
>       at 
> akka.actor.ActorCell$$anonfun$become$1.applyOrElse(ActorCell.scala:544)
>       at akka.actor.Actor$class.aroundReceive(Actor.scala:502)
>       at akka.actor.UntypedActor.aroundReceive(UntypedActor.scala:95)
>       at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
>       at akka.actor.ActorCell.invoke(ActorCell.scala:495)
>       at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
>       at akka.dispatch.Mailbox.run(Mailbox.scala:224)
>       at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
>       at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
>       at 
> scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
>       at 
> scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
>       at 
> scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to