← Back to Pull requests

[Spark 4] Clear the watermark of keys without timers or state in the streaming stateful ParDo #40550

Closed
unknown closed this pull request without merging on Oct 20, 2026 22:50 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 10:00 UTC
Author

BeamStatefulProcessor wrote beamWatermark on every visit and never removed it, so each key that ever went through a streaming stateful ParDo kept a row in the state store even after all its windows expired. beamTimers was already cleared by persistTimers once no timers remain. The watermark was the only thing left behind.

storeWatermark, called from handleInputRows and handleExpiredTimer, now clears beamWatermark when the key has no timers and beamState is empty, for example after the GC timer of its last window fired. The change stays inside those two code paths, so it should rebase cleanly onto #40516 and the GroupByKey base-class split.

On late data: after the cleanup, the key's next visit is a first visit and filters late data against TIMESTAMP_MIN_VALUE, so a late element for an already expired window of that key is processed instead of dropped. I went with accepting this as part of #40446. A brand-new key already behaves this way. Keeping any marker per key means keeping the same Long the issue wants gone. A TTLConfig is processing-time based, so it doesn't line up with allowed lateness. I updated the contract comment in timerInternals to cover cleared keys.

The new test, testExpiredKeyLeavesNoState, sends a single element for one key and lets its only window expire as the source watermark advances. It then reads the checkpoint through the statestore data source and asserts that beamState, beamTimers and beamWatermark have no rows left. Without the change one beamWatermark row remains.

Fixes #40517

Diff: 191 lines (+143 / -48) across 2 files Reviewer: schizophrenicmaniac Review duration: 10850m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 191 lines diff across 2 files
0.36
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.315
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #40550"
general weight: 0.35
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 35.9% (MEDIUM) · Higher = larger blast radius
35.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.2% · Safe to merge
14.2%
Repository