Skip to content

Commit

Permalink
make getProcessingDistributionsForWorkId threadsafe (#29979)
Browse files Browse the repository at this point in the history
* make getProcessingDistributionsForWorkId synchronized to avoid race conditions with remove tracker

* correctly access the concurrent hashmap to avoid race conditions

---------

Co-authored-by: Claire McCarthy <[email protected]>
  • Loading branch information
clmccart and clmccart authored Jan 29, 2024
1 parent c9135e0 commit b72eacf
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,10 @@ public Optional<ActiveMessageMetadata> getActiveMessageMetadataForWorkId(String
}

public Map<String, IntSummaryStatistics> getProcessingDistributionsForWorkId(String workId) {
if (!activeTrackersByWorkId.containsKey(workId)) {
if (completedProcessingMetrics.containsKey(workId)) {
return completedProcessingMetrics.get(workId);
}
return new HashMap<>();
}
DataflowExecutionStateTracker tracker = activeTrackersByWorkId.get(workId);
if (tracker == null) {
return completedProcessingMetrics.getOrDefault(workId, new HashMap<>());
}
return mergeStepStatsMaps(
completedProcessingMetrics.getOrDefault(workId, new HashMap<>()),
tracker.getProcessingTimesByStepCopy());
Expand Down

0 comments on commit b72eacf

Please sign in to comment.