scwhittle commented on code in PR #40639:
URL: https://github.com/apache/beam/pull/40639#discussion_r4587352463


##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingModeExecutionContext.java:
##########
@@ -798,19 +802,46 @@ private Windmill.WorkItemCommitRequest.Builder 
buildWorkItemTruncationRequestBui
     return outputBuilder;
   }
 
-  private final long computeSourceBytesProcessed(String 
sourceBytesCounterName) {
+  @VisibleForTesting
+  long computeSourceBytesProcessed(String sourceBytesCounterName) {
     if (!(workExecutor instanceof DataflowMapTaskExecutor)) {
       return 0L;
     }
-    HashMap<String, ElementCounter> counters =
-        ((DataflowMapTaskExecutor) workExecutor)
-            .getReadOperation()
-            .receivers[0]
-            .getOutputCounters();
+    // Note this is a problem for both custom source read operators and SDF 
ParDos: extracting
+    // the byte count counter values here races with 
StreamingWorkerStatusReporter, which also
+    // calls getAndReset on all modified counters to report to Dataflow. We 
should find a more

Review Comment:
   is it on the same thread? if so it doesn't seem like a race, just sensitive 
to ordering.
   
   We could add a get method instead of getAndReset to call in this case if we 
want to leave it set for the normal reporting.



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to