Biao Liu created FLINK-13635:
--------------------------------

             Summary: Unexpectedly interrupted in AsyncFunction#timeout
                 Key: FLINK-13635
                 URL: https://issues.apache.org/jira/browse/FLINK-13635
             Project: Flink
          Issue Type: Improvement
          Components: API / DataStream
    Affects Versions: 1.9.0
            Reporter: Biao Liu
             Fix For: 1.10.0


Currently the way of handling {{AsyncFunction#timeout}} is a bit weird in 
{{AsyncWaitOperator#processElement}}.
 
There are two methods in {{AsyncFunction}}, {{asyncInvoke}} and {{timeout}}. 
The {{asyncInvoke}} is executed in task thread, while the {{timeout}} is 
executed in system time service. When the {{asyncInvoke}} finished, it might 
complete the {{ResultFuture}}. Then it cancels the registered timer of 
{{timeout}}. However there is no any synchronization between the 
{{asyncFunction}}, {{timeout}} and the cancelation. Moreover this cancelation 
is with interruption enabled.

The {{timeout}} must be implemented very carefully. Because when the 
{{timeout}} is executing, there might be an interruption triggered at the same 
time (due to a completion of {{ResultFuture}}). That means the {{timeout}} must 
handle {{InterruptedException}} well everywhere if there is any operation 
reacting with this exception.

My proposals are described below.
1. It should be written down in document that the {{asyncInvoke}} and 
{{timeout}} might be invoked at the same time.
2. This interruption of {{timeout}} should be avoided. There should be a 
synchronization between cancelation and {{timeout}}. If the {{timeout}} is 
executing, the cancelation should be avoided. If the cancelation has been 
invoked, this {{timeout}} should not be invoked anymore. Or we could simply 
cancel the timer without an interruption.

CC [~kkl0u], [~till.rohrmann]



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to