lukecwik commented on code in PR #23589:
URL: https://github.com/apache/beam/pull/23589#discussion_r993782709


##########
sdks/go/pkg/beam/core/runtime/harness/harness.go:
##########
@@ -328,14 +329,20 @@ func (c *control) getOrCreatePlan(bdID 
bundleDescriptorID) (*exec.Plan, error) {
        desc, ok := c.descriptors[bdID]
        c.mu.Unlock() // Unlock to make the lookup or build the descriptor.
        if !ok {
-               newDesc, err := c.lookupDesc(bdID)
+               newDesc, err, _ := c.bundleGetGroup.Do(string(bdID), func() 
(interface{}, error) {

Review Comment:
   this reduces most of the race condition here but there is still a race since 
c.descriptors is only updated within the singleflight so if the singleflight 
completes after someone has checked that the descriptor isn't there another 
singleflight load could happen.
   
   I looked and found that it seems like there is a ComputeIfAbsent like way to 
do this as per 
https://stackoverflow.com/questions/49528232/is-there-a-function-similar-to-javas-concurrentmap-computeifabsent-in-go



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