You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "robertwb (via GitHub)" <gi...@apache.org> on 2023/02/15 01:04:33 UTC

[GitHub] [beam] robertwb commented on a diff in pull request #25473: Add retry logic to Python boot script.

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


##########
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:
   Thanks. Done.



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