You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Task]: Clear per key watermark and timer state of the Spark 4 streaming stateful processor #40517
BeamStatefulProcessor keeps a beamWatermark and a beamTimersValueState per grouping key and never clears beamWatermark, so a stateful ParDo, and the upcoming windowed GroupByKey, over an unbounded key space grows the state store forever, even after all windows of a key expired and its beamState map is empty. Clear both when no timers remain and beamState is empty, or attach a TTLConfig derived from allowed lateness.
Hi, I'd like to work on this. In BeamStatefulProcessor, storeWatermark always writes beamWatermark, so I'd clear beamWatermark and beamTimers after handleInputRows/handleExpiredTimer once no timers remain and beamState is empty, with a streaming test checking the key's state is gone after window expiry.
Activity
schizophrenicmaniac commentedon Oct 12, 2026
.take-issue
Hi, I'd like to work on this. In BeamStatefulProcessor, storeWatermark always writes beamWatermark, so I'd clear beamWatermark and beamTimers after handleInputRows/handleExpiredTimer once no timers remain and beamState is empty, with a streaming test checking the key's state is gone after window expiry.
tkaymak commentedon Oct 12, 2026
Thanks for taking this. Two things to line up:
beamWatermarkturns the next visit of that key into a first visit, which filters late data againstTIMESTAMP_MIN_VALUE(contract comment intimerInternals, [Task]: Tighten the late data bound of the Spark 4 streaming stateful ParDo to the previous batch watermark #40446). A late element for a cleared key would then be accepted instead of dropped. Please cover that case in the test and say in the PR how you handle it, for example by keeping a much smaller marker or by accepting it as part of [Task]: Tighten the late data bound of the Spark 4 streaming stateful ParDo to the previous batch watermark #40446.BeamStatefulProcessoris about to change shape: [Spark 4] Group the streaming stateful ParDo by encoded key bytes to support null keys #40516 (open) switches the Spark grouping key to encoded bytes, and the next PR for windowed GroupByKey turns it into an abstract base with a ParDo and a GroupByKey subclass. The cleanup belongs in the base, so building on top of [Spark 4] Group the streaming stateful ParDo by encoded key bytes to support null keys #40516 and keeping the change insidehandleInputRowsandhandleExpiredTimerkeeps the conflict small. I will link the GroupByKey PR here when it is open.