You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "Abacn (via GitHub)" <gi...@apache.org> on 2025/06/03 15:44:51 UTC

[PR] Fix data race ExecutionStateSampler.java:491 in ExecutionStateImpl.reset() [beam]

Abacn opened a new pull request, #35135:
URL: https://github.com/apache/beam/pull/35135

   internal bug: b/415452542
   
   **Please** add a meaningful description for your change here
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/actions/workflows/build_wheels.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/actions/workflows/python_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/actions/workflows/java_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Go tests](https://github.com/apache/beam/actions/workflows/go_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
   


-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix data race ExecutionStateSampler.java:491 in ExecutionStateImpl.reset() [beam]

Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn merged PR #35135:
URL: https://github.com/apache/beam/pull/35135


-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix data race ExecutionStateSampler.java:491 in ExecutionStateImpl.reset() [beam]

Posted by "scwhittle (via GitHub)" <gi...@apache.org>.
scwhittle commented on code in PR #35135:
URL: https://github.com/apache/beam/pull/35135#discussion_r2167596960


##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/control/ExecutionStateSampler.java:
##########
@@ -477,7 +477,7 @@ public void takeSample(long millisSinceLastSample) {
       }
 
       /** Updates the monitoring data for this {@link ExecutionState}. */
-      public void updateMonitoringData(Map<String, ByteString> monitoringData) {
+      public synchronized void updateMonitoringData(Map<String, ByteString> monitoringData) {

Review Comment:
   can you mark hasReportedValue and lastReportedValue with guardedby("this") annotation?



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix data race ExecutionStateSampler.java:491 in ExecutionStateImpl.reset() [beam]

Posted by "scwhittle (via GitHub)" <gi...@apache.org>.
scwhittle commented on code in PR #35135:
URL: https://github.com/apache/beam/pull/35135#discussion_r2124946591


##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/control/ExecutionStateSampler.java:
##########
@@ -543,15 +543,21 @@ public void start(String processBundleId) {
 
     @Override
     public void updateIntermediateMonitoringData(Map<String, ByteString> monitoringData) {
-      for (ExecutionStateImpl executionState : executionStates) {
-        executionState.updateMonitoringData(monitoringData);
+      // executionState may get reset in reset() call below
+      synchronized (activeStateTrackers) {
+        for (ExecutionStateImpl executionState : executionStates) {
+          executionState.updateMonitoringData(monitoringData);

Review Comment:
   can we instead make the  ExecutionStateImpl synchronize lastReportedValue and hasReportedValue? it could just synchronize on itself for it an reset().  The comment around those says it is guarded by some other mutex but it clearly isn't in the reset case.
   
   It's odd to use activeStateTrackers here for internal state to unrelated executionState just because we happen to be holding it in reset() when modifying the execution states.



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix data race ExecutionStateSampler.java:491 in ExecutionStateImpl.reset() [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35135:
URL: https://github.com/apache/beam/pull/35135#issuecomment-2936059849

   Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment `assign set of reviewers`


-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix data race ExecutionStateSampler.java:491 in ExecutionStateImpl.reset() [beam]

Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on code in PR #35135:
URL: https://github.com/apache/beam/pull/35135#discussion_r2167329185


##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/control/ExecutionStateSampler.java:
##########
@@ -543,15 +543,21 @@ public void start(String processBundleId) {
 
     @Override
     public void updateIntermediateMonitoringData(Map<String, ByteString> monitoringData) {
-      for (ExecutionStateImpl executionState : executionStates) {
-        executionState.updateMonitoringData(monitoringData);
+      // executionState may get reset in reset() call below
+      synchronized (activeStateTrackers) {
+        for (ExecutionStateImpl executionState : executionStates) {
+          executionState.updateMonitoringData(monitoringData);

Review Comment:
   changed to implement option 1



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix data race ExecutionStateSampler.java:491 in ExecutionStateImpl.reset() [beam]

Posted by "scwhittle (via GitHub)" <gi...@apache.org>.
scwhittle commented on code in PR #35135:
URL: https://github.com/apache/beam/pull/35135#discussion_r2124953826


##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/control/ExecutionStateSampler.java:
##########
@@ -543,15 +543,21 @@ public void start(String processBundleId) {
 
     @Override
     public void updateIntermediateMonitoringData(Map<String, ByteString> monitoringData) {
-      for (ExecutionStateImpl executionState : executionStates) {
-        executionState.updateMonitoringData(monitoringData);
+      // executionState may get reset in reset() call below
+      synchronized (activeStateTrackers) {
+        for (ExecutionStateImpl executionState : executionStates) {
+          executionState.updateMonitoringData(monitoringData);

Review Comment:
   Or can we enforce this and document it better than the current incorrect comment about split lock around the racy variables by annotating them with:
   
   GuardedBy("ExecutionStateSampler.this.activeStateTrackers")
   It seems like that syntax might work from https://errorprone.info/bugpattern/GuardedBy



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix data race ExecutionStateSampler.java:491 in ExecutionStateImpl.reset() [beam]

Posted by "scwhittle (via GitHub)" <gi...@apache.org>.
scwhittle commented on PR #35135:
URL: https://github.com/apache/beam/pull/35135#issuecomment-2970481213

   @Abacn friendly ping


-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix data race ExecutionStateSampler.java:491 in ExecutionStateImpl.reset() [beam]

Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on code in PR #35135:
URL: https://github.com/apache/beam/pull/35135#discussion_r2167631038


##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/control/ExecutionStateSampler.java:
##########
@@ -477,7 +477,7 @@ public void takeSample(long millisSinceLastSample) {
       }
 
       /** Updates the monitoring data for this {@link ExecutionState}. */
-      public void updateMonitoringData(Map<String, ByteString> monitoringData) {
+      public synchronized void updateMonitoringData(Map<String, ByteString> monitoringData) {

Review Comment:
   Thanks for pointing. Updated.



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix data race ExecutionStateSampler.java:491 in ExecutionStateImpl.reset() [beam]

Posted by "chamikaramj (via GitHub)" <gi...@apache.org>.
chamikaramj commented on PR #35135:
URL: https://github.com/apache/beam/pull/35135#issuecomment-2992652117

   Any updates ? Assume this doesn't have to be a release blocker.


-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix data race ExecutionStateSampler.java:491 in ExecutionStateImpl.reset() [beam]

Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on PR #35135:
URL: https://github.com/apache/beam/pull/35135#issuecomment-2936054642

   R: @scwhittle 


-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org