AtharvUrunkar commented on code in PR #38246:
URL: https://github.com/apache/beam/pull/38246#discussion_r3115671971
##########
sdks/python/container/boot.go:
##########
@@ -314,23 +314,47 @@ func launchSDKProcess() error {
var wg sync.WaitGroup
wg.Add(len(workerIds))
- for _, workerId := range workerIds {
- go func(workerId string) {
- defer wg.Done()
-
- bufLogger := tools.NewBufferedLogger(logger)
- errorCount := 0
- for {
- childPids.mu.Lock()
- if childPids.canceled {
- childPids.mu.Unlock()
- return
- }
- logger.Printf(ctx, "Executing Python (worker
%v): python %v", workerId, strings.Join(args, " "))
- cmd :=
StartCommandEnv(map[string]string{"WORKER_ID": workerId}, os.Stdin, bufLogger,
bufLogger, "python", args...)
- childPids.v = append(childPids.v,
cmd.Process.Pid)
- childPids.mu.Unlock()
-
+for _, workerId := range workerIds {
+ go func(workerId string) {
+ defer wg.Done()
+
+ workerCtx := grpcx.WriteWorkerID(ctx, workerId)
Review Comment:
Good catch — thanks for digging into this.
You're right that `WriteWorkerID` does not overwrite existing metadata but
instead appends to it via `metadata.Join`. That means reusing the parent `ctx`
could result in multiple worker IDs being accumulated, which is definitely not
what we want.
Using `context.Background()` to create a clean root context per worker makes
sense and avoids unintended metadata propagation from the parent context.
I’ll update the implementation to use a fresh context for each worker to
ensure isolation and avoid side effects in logging.
--
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]