bpattarkine opened a new pull request, #1504:
URL: https://github.com/apache/flink-agents/pull/1504

   Linked issue: #1431
   
   ### Purpose of change
   
   Kafka and Fluss recovery markers use explicit serialization when Agents 
writes operator state. Operators can restore a legacy Kryo checkpoint, and the 
Kafka cleanup tool can read either checkpoint format. This is a draft 
implementation step toward explicit serialization for the Agents runtime.
   
   #### Runtime flow
   
   The durable execution manager opens the existing marker union-list state. 
Flink restores existing entries using the serializer described in the 
checkpoint. On registration, the new serializer snapshot accepts the old Kryo 
format for migration. The next checkpoint writes a marker kind followed by 
either Fluss bucket offsets or Kafka topic identity, schema version, and 
partition offsets. The offline Kafka cleanup tool supplies the same state 
serializer when it opens the union list.
   
   #### Key decisions
   
   The Flink state name remains stable so Flink can migrate 
already-deserialized entries and reject downgrades through its serializer 
compatibility checks. Kafka marker identity and offsets use Flink's scalar and 
map serializers. Recovery markers contain framework metadata, so the format 
does not need an application-value codec.
   
   The [benchmark 
report](https://github.com/apache/flink-agents/issues/1431#issuecomment-7354412587)
 measured a small operator-state size reduction in the processing-key patch and 
no clear throughput or checkpoint latency signal. This draft claims format and 
recovery behavior only.
   
   #### Remaining work for generic-types=false
   
   Track processing keys in #1503. Java outputs need declared output type 
information at the agent operator boundary. Events, queued and in-flight tasks, 
and memory still need explicit state and copy contracts. Application values 
need a single serialization contract across checkpoint state, 
mutation-isolating copies, and the durable journal, including PyFlink value 
representations and rejection of unsupported values. Runtime acceptance 
requires Java and PyFlink jobs that checkpoint and restore in-flight tasks and 
memory with generic types disabled, including durable replay and restore 
compatibility checks. The Kafka cleanup tool still uses generic stream type 
information for the intermediate marker stream.
   
   ### Behavioral Semantics
   
   #### Interaction decisions
   
   | Reader | Legacy Kryo checkpoint | Explicit marker checkpoint |
   | --- | --- | --- |
   | Updated operator | Restores the legacy values and writes the explicit 
format on its next checkpoint | Restores the explicit values |
   | Updated Kafka cleanup tool | Reads the saved Kafka topic ID and partition 
offsets | Reads the same fields |
   | Legacy operator | Restores through its existing serializer | Rejects the 
incompatible serializer |
   
   #### Behavioral contracts
   
   1. Kafka and Fluss markers retain the offsets required for durable recovery. 
Kafka markers also retain topic identity and schema version.
   2. The updated Kafka cleanup tool creates equivalent cleanup offsets from 
both formats.
   3. Marker state can be restored with Flink generic types disabled. A job 
still requires generic types enabled for the remaining runtime paths.
   
   #### Failure behavior
   
   An unsupported marker value or marker kind fails serialization or restore. A 
version whose marker descriptor still expects Kryo fails at state registration 
when restoring a checkpoint written with the explicit marker format. Rollback 
uses a pre-upgrade savepoint.
   
   ### Tests
   
   | Contract | Verification |
   | --- | --- |
   | Kafka and Fluss marker values survive migration and restore | 
`RecoveryMarkerStateTest` restores both values from Kryo, checkpoints them in 
the current format, and verifies that the legacy descriptor rejects that 
checkpoint. `ActionStateDivergenceRecoveryTest` covers operator recovery and 
replay. |
   | Kafka cleanup reads both formats | 
`KafkaActionStateCleanupToolTest.testPlanReadsRealUnionStateFromSavepoint` 
writes and reads a canonical savepoint for each format, then checks calculated 
offsets. |
   | Marker state restores with generic types disabled | 
`RecoveryMarkerStateTest` configures `pipeline.generic-types=false` before 
restoring the migrated marker checkpoint. |
   
   The focused runtime build passed 52 tests. Full PyFlink and end-to-end 
generic-types-disabled restores remain outside this draft.
   
   <details>
   <summary>Focused test invocation</summary>
   
   ```sh
   mvn -B --no-transfer-progress -pl runtime -am \
     
-Dtest=RecoveryMarkerStateTest,KafkaActionStateCleanupToolTest,DurableExecutionManagerTest,ActionStateDivergenceRecoveryTest
 \
     -Dsurefire.failIfNoSpecifiedTests=false clean test
   ```
   
   </details>
   
   ### API
   
   The Java, Python, and YAML job configuration stays the same. Existing Kafka 
and Fluss markers restore forward. Use a pre-upgrade savepoint when rolling 
back to a version that expects Kryo marker state.
   
   ### Documentation
   
   - [ ] `doc-needed`
   - [ ] `doc-not-needed`
   - [x] `doc-included`
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   - [x] Yes
   - [ ] No
   
   Generated-by: Codex CLI 0.173.0 (GPT-6)
   


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