damccorm opened a new pull request, #41775:
URL: https://github.com/apache/beam/pull/41775

   Note: this PR was auto-generated by tooling. Before moving it out of draft, 
the author has done a full review of the PR, specifically evaluating it on the 
following criteria:
   
   - The PR is an appropriate fix for the issue (e.g. we're not changing a test 
to avoid a bug)
   - The PR is a simple fix to the issue (e.g. we're not adding infra when we 
could just modify a test)
   - The PR is not covering for other problems (e.g. if we're bumping timeouts, 
it is not because we're covering for a performance problem)
     
   Full details of the methodology of generation and review can be found here - 
https://docs.google.com/document/d/14lj7ECVov4T4EdwmIzNlWrRGE3lLDMOwX5xUMGzaLoc/edit?usp=sharing
   
   If you have concerns with the PR or with the underlying methodology used to 
generate this, please comment below - they will be addressed by the author not 
the tooling :)
   
   ## Summary
   
   Fixes a non-deterministic Go `select` race in `reconcileBackgroundTask` that 
caused `Test_compileStep/Error_during_expired_context_of_the_example` to return 
`STATUS_COMPILE_ERROR` instead of `STATUS_RUN_TIMEOUT` in 
https://github.com/apache/beam/actions/runs/46185337448 (build scan 
https://develocity.apache.org/s/fyojugvdfrkyo).
   
   ## Production Impact
   
   - **Affected workloads**: Apache Beam Playground backend 
(`playground/backend`) compile, validate, prepare, and run steps when a request 
times out or is canceled (does not affect Cloud Dataflow).
   - **Symptom**: When `pipelineLifeCycleCtx` expires or is canceled, 
`exec.CommandContext` terminates the subprocess and `runCmdWithOutput` pushes 
`false` onto buffered `successChannel`. Because both 
`<-pipelineLifeCycleCtx.Done()` and `<-successChannel` are ready, Go's `select` 
picks uniformly at random — returning `(false, nil)` roughly 50% of the time 
and misclassifying a timeout or user cancellation as a compile/run error.
   - **Resolution**: Check `pipelineLifeCycleCtx.Err() != nil` before entering 
`select` and again when `ok == false` is received from `successChannel`, 
handling timeout/cancellation deterministically.
   
   ## Changes
   
   - `playground/backend/internal/code_processing/code_processing.go`: Extract 
`handleContextDone()` inside `reconcileBackgroundTask()` and check 
`pipelineLifeCycleCtx.Err() != nil` before `select` and when `!ok` is read from 
`successChannel`.
   
   ### Verification
   - Triggered `beam_Playground_Precommit.yml` workflow run on branch: 
[`46452002570`](https://github.com/apache/beam/actions/runs/46452002570)
   


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