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

   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 Prism production panic (`panic in ElementManager.Bundles watermark 
evaluation goroutine: assignment to entry in nil map` at 
`elementmanager.go:2329`) observed twice across independent `PreCommit Python 
ML` runs (`WatchFilePatternTest.test_file_newer_than_pipeline_start_is_emitted` 
in https://github.com/apache/beam/actions/runs/46453026568, build scan 
https://develocity.apache.org/s/fmtk4nivxmjtc, and 
`WatchFilePatternTest.test_one_poll_emits_only_the_newest_model` in 
https://github.com/apache/beam/actions/runs/46453383204, build scan 
https://develocity.apache.org/s/mp6ezw4l6znng).
   
   ## Production Impact
   
   - **Affected workloads**: Any pipeline executed on the Apache Beam Prism 
runner (Go, Python, Java, or YAML) with after-processing-time triggers on 
aggregation stages (does not affect Cloud Dataflow).
   - **Symptom**: `injectTriggeredBundlesIfReady` (`elementmanager.go:1520`) 
persists a processing-time trigger timer for `(window, key)` into 
`ss.processingTimeTimers`. If the output watermark advances past 
`ss.strat.EarliestCompletion(window)` before that timer fires, watermark GC 
(`elementmanager.go:2533`) deletes `win` from `ss.state[LinkID{}]`. When the 
orphaned timer subsequently fires (or during drain at `mtime.MaxTimestamp`), 
`(*aggregateStageKind).buildProcessingTimeBundle` reads a zero-value 
`StateData` from the `nil` window map, sees `endOfWindowReached == true` / 
`ready == true`, and panics assigning 
`ss.state[LinkID{}][e.window][string(e.keyBytes)] = state`.
   - **Resolution**: Check `winState, ok := ss.state[LinkID{}][e.window]` in 
`(*aggregateStageKind).buildProcessingTimeBundle`; if `!ok`, ignore the stale 
timer and return without modifying state or emitting an empty `bundlePane`.
   
   ## Changes
   
   - `sdks/go/pkg/beam/runners/prism/internal/engine/elementmanager.go`: Guard 
against missing/garbage-collected `ss.state[LinkID{}][e.window]` in 
`(*aggregateStageKind).buildProcessingTimeBundle`.
   - `sdks/go/pkg/beam/runners/prism/internal/engine/elementmanager_test.go`: 
Add `TestAggregateBuildProcessingTimeBundle_GarbageCollectedWindow` regression 
test (verified with `go test ./go/pkg/beam/runners/prism/internal/engine`).
   
   ### Verification
   - Triggered `beam_PreCommit_GoPrism.yml` workflow run on branch: 
[`46472059073`](https://github.com/apache/beam/actions/runs/46472059073)
   


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