MartijnVisser opened a new pull request, #30022:
URL: https://github.com/apache/flink/pull/30022

   ## What is the purpose of the change
   
   CepOperator doesn't snapshot the watermark, so after a restore it hands 
events that were already late to the NFA after newer events. SharedBuffer can 
then give such an event the EventId of an event a partial match still holds, 
and the job fails with an IllegalStateException or NullPointerException, or 
emits a wrong match.
   
   Events that were late before the failure but are newer than everything the 
NFA holds are still processed; that is FLINK-38055 / FLINK-5601.
   
   ## Brief change log
   
   - When a timer fires, CepOperator sends buffered events at or before the 
newest event its partial and completed matches reference to the late data 
output. This needs no new state, and also lets checkpoints taken before the fix 
restore when their buffer holds such an event.
   - SharedBuffer keeps the counter of a timestamp while an event with that 
timestamp is in use, instead of removing counters as time advances. This also 
covers processing time going back. A snapshot from before the fix can keep at 
most one unused counter per key; it does no harm.
   - A MATCH_RECOGNIZE restore test with late rows.
   
   There is no switch to turn this off: the first change only affects events 
that would otherwise break the SharedBuffer, and the second has no correct old 
behaviour to go back to.
   
   ## Verifying this change
   
   - `CepOperatorLateEventsAfterRestoreTest`, heap and RocksDB: late events 
after a restore go to the side output or the metric, also when they were 
already buffered at the snapshot or are older than a completed match that waits 
for an earlier partial match; on-time events buffered at the snapshot are 
processed; restore from a drained savepoint. 10 of the 12 fail without the fix.
   - `SharedBufferTest`, `CEPOperatorTest`: no EventId reused while in use, 
also when processing time goes back; no counters left after cleanup; releasing 
many events with one timestamp stays linear in state reads.
   - `MatchRecognizeRestoreTest` `match-late-rows-after-restore`: `+I[k, 6, 7, 
8]` instead of `+I[k, 1, 2, 8]` without the fix.
   - Outside this PR: 42 randomized restore setups (heap and RocksDB, 
rescaling, interrupted timers), 150 seeds each, against a run without restore: 
no exceptions, and the only differences are events that were late before the 
failure. Savepoints from 2.2.1 and 2.3.0 restore into this change, and 
savepoints taken with it restore into 2.2.1 and 2.3.0.
   - JMH, 100 keys, RocksDB and ForSt: the first commit alone is within noise 
of master; with both, throughput goes up 1.6x to 2.2x, because SharedBuffer no 
longer iterates its counters for every timestamp. Heap is unchanged.
   
   ## Does this pull request potentially affect one of the following parts:
   
   - Dependencies (does it add or upgrade a dependency): no
   - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
   - The serializers: no
   - The runtime per-record code paths (performance sensitive): yes, see JMH 
above
   - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
   - The S3 file system connector: no
   
   ## Documentation
   
   - Does this pull request introduce a new feature? no
   - If yes, how is the feature documented? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Claude Opus 5.5)
   


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