Chengbing Liu created FLINK-41612:
-------------------------------------

             Summary: Async lookup retry backoff can block on the common pool 
and cause concurrent calls
                 Key: FLINK-41612
                 URL: https://issues.apache.org/jira/browse/FLINK-41612
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Runtime
    Affects Versions: 2.3.0
            Reporter: Chengbing Liu
             Fix For: 2.4.0


Async lookup retries currently call {{Thread.sleep}} from a 
{{whenCompleteAsync}} callback. With the default CompletableFuture executor, 
each sleeping callback occupies a worker in the common ForkJoin pool. During a 
burst of lookup misses, other callbacks can queue for a worker before their 
backoff even begins.

The old callback also submits the retry from the worker thread. That submission 
can overlap an initial lookup for another record on the task thread and race on 
mutable state in the same connector instance.
h3. How to reproduce

Both cases were reproduced on the Flink 2.3.0 release artifact with JDK 17 and 
a test {{{}AsyncLookupFunction{}}}.
 # *Blocked completion worker.* Use a single-thread completion executor and 
configure a 30-second retry delay. Complete the first lookup with an empty 
result, then submit a no-op to the same executor. After 300 ms, the no-op is 
still queued and the worker is in {{{}Thread.sleep{}}}.
 # *Concurrent lookup submissions.* Configure a 1 ms retry delay. Keep the 
initial call for key B inside {{asyncLookup()}} while completing the first 
attempt for key A with an empty result. The retry for A enters the same 
function instance on a different thread before the call for B returns.

h3. Expected behavior

Waiting for a retry should leave completion workers free to process other 
results. Initial attempts and retries should be submitted serially on the task 
thread. Requests that have already been submitted should still be able to run 
concurrently.
h3. Proposed fix

Use the operator’s processing-time timers for backoff and submit retries 
through the task mailbox when a timer fires. Cancel pending retry timers on 
close.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to