antonbobkov commented on code in PR #25473:
URL: https://github.com/apache/beam/pull/25473#discussion_r1106536433


##########
sdks/python/container/boot.go:
##########
@@ -251,20 +251,31 @@ func launchSDKProcess() error {
                go func(workerId string) {
                        defer wg.Done()
 
-                       childPids.mu.Lock()
-                       if childPids.canceled {
+                       errorCount := 0
+                       for {
+                               childPids.mu.Lock()
+                               if childPids.canceled {
+                                       childPids.mu.Unlock()
+                                       return
+                               }
+                               log.Printf("Executing Python (worker %v): 
python %v", workerId, strings.Join(args, " "))
+                               cmd := 
StartCommandEnv(map[string]string{"WORKER_ID": workerId}, "python", args...)
+                               childPids.v = append(childPids.v, 
cmd.Process.Pid)
                                childPids.mu.Unlock()
-                               return
-                       }
-                       log.Printf("Executing Python (worker %v): python %v", 
workerId, strings.Join(args, " "))
-                       cmd := StartCommandEnv(map[string]string{"WORKER_ID": 
workerId}, "python", args...)
-                       childPids.v = append(childPids.v, cmd.Process.Pid)
-                       childPids.mu.Unlock()
-
-                       if err := cmd.Wait(); err != nil {
-                               log.Printf("Python (worker %v) exited: %v", 
workerId, err)
-                       } else {
-                               log.Printf("Python (worker %v) exited.", 
workerId)
+
+                               if err := cmd.Wait(); err != nil {
+                                       // Retry on fatal errors, like OOMs and 
segfaults, not just
+                                       // DoFns throwing exceptions.
+                                       errorCount += 1
+                                       if errorCount < 4 {
+                                               log.Printf("Python (worker %v) 
exited: %v", workerId, err)

Review Comment:
   perhaps add more information in the logs about retries/failures. Maybe 
something along the lines of "Python (worker %v) exited: %v, retrying process." 
and "Python (worker %v) exited: %v, out of retries: restarting SDK container."



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