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

Xintong Song commented on FLINK-22340:
--------------------------------------

Thanks for the info, [~jiamo].

Despite the reported problem happens in a user defined function, which is not 
how {{ThresholdMeter}} is expected to be used, the same problem can also happen 
for the runtime internals. Thus, we need to fix this anyway. I've opened a PR 
to make {{ThresholdMeter}} thread safe.

In your case, I would suggest to use {{MeterView}}. One of the reasons we make 
{{ThresholdMeter}} an internal class is that, it is not optimized for 
performance critical scenarios. Notice that a user defined function can be 
invoked on every data record, which makes it extremely sensitive to the 
performance. {{MeterView}} updates the rate with a background thread, and 
reduces the computation overhead by maintaining a history of events count. 
However, that means you would need do the threshold checking yourselves.

> Concurrent access to ThresholdMeter may lead to NPE
> ---------------------------------------------------
>
>                 Key: FLINK-22340
>                 URL: https://issues.apache.org/jira/browse/FLINK-22340
>             Project: Flink
>          Issue Type: Bug
>          Components: Runtime / Coordination
>    Affects Versions: 1.13.0
>            Reporter: Xintong Song
>            Assignee: Xintong Song
>            Priority: Critical
>              Labels: pull-request-available
>             Fix For: 1.13.0
>
>
> It is reported on github [1] that NPE is thrown from ThreasholdMeter, which 
> is likely caused by concurrent accesses.
> [1] 
> https://github.com/apache/flink/commit/b9e576fb845b817d804da3d68471ff8a4723dcf3#commitcomment-49681105



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to