[ 
https://issues.apache.org/jira/browse/BEAM-12209?focusedWorklogId=587555&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-587555
 ]

ASF GitHub Bot logged work on BEAM-12209:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 22/Apr/21 22:43
            Start Date: 22/Apr/21 22:43
    Worklog Time Spent: 10m 
      Work Description: amaliujia commented on a change in pull request #14617:
URL: https://github.com/apache/beam/pull/14617#discussion_r618790658



##########
File path: 
sdks/java/fn-execution/src/main/java/org/apache/beam/sdk/fn/stream/DirectStreamObserver.java
##########
@@ -59,9 +60,8 @@ public DirectStreamObserver(Phaser phaser, 
CallStreamObserver<T> outboundObserve
 
   @Override
   public void onNext(T value) {
-    numberOfMessagesBeforeReadyCheck += 1;
-    if (numberOfMessagesBeforeReadyCheck >= maxMessagesBeforeCheck) {
-      numberOfMessagesBeforeReadyCheck = 0;
+    if (maxMessagesBeforeCheck <= 1 ||

Review comment:
       Does `maxMessagesBeforeCheck` need to be an atomic integer?

##########
File path: 
sdks/java/fn-execution/src/main/java/org/apache/beam/sdk/fn/stream/DirectStreamObserver.java
##########
@@ -59,9 +60,8 @@ public DirectStreamObserver(Phaser phaser, 
CallStreamObserver<T> outboundObserve
 
   @Override
   public void onNext(T value) {

Review comment:
       So this function could be called in a multiple threading environment 
thus we need an atomic integer?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 587555)
    Time Spent: 50m  (was: 40m)

> DirectStreamObserver is not thread-safe as advertised due to racy integer 
> operations
> ------------------------------------------------------------------------------------
>
>                 Key: BEAM-12209
>                 URL: https://issues.apache.org/jira/browse/BEAM-12209
>             Project: Beam
>          Issue Type: Bug
>          Components: java-fn-execution
>            Reporter: Sam Whittle
>            Assignee: Sam Whittle
>            Priority: P2
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> An AtomicInteger should be used instead for the message counting for periodic 
> flow control checking.



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

Reply via email to