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

   Linked issue: #1436
   
   ### Purpose of change
   
   A durable call that failed now replays the same exception after recovery: 
the same concrete type, with its fields. Today the record keeps only the class 
name and message, so an exception without a public `(String)` constructor comes 
back as `RuntimeException`, and fields such as a task handle or status are lost 
even when the type survives. A typed `catch` that handled the original failure 
then misses the replayed one.
   
   #### Runtime flow
   
   `serializeDurableException` builds the `DurableExecutionException` record 
for every recorded failure (sync `durableExecute`, reconcilable calls, and the 
async completion path). It now also stores the exception in Java serialized 
form, as a base64 `serializedException` field in the same JSON payload. On 
replay, `toException()` is still the single reconstruction point, used by 
`tryGetCachedResult` (sync and async single calls) and `readTerminalOutcomeAt` 
(`gather`). It deserializes `serializedException` with the context class loader 
first and only then falls back to the existing class-and-message reconstruction.
   
   #### Key decisions
   
   - Java serialization through Flink's `InstantiationUtil`, rather than a 
Jackson contract that each exception opts into. Exceptions are `Serializable` 
by default, so most user exceptions round-trip with no changes, and the field 
set is whatever the class declares.
   - The old class and message fields stay in the record, so the fallback and 
older records keep working.
   
   ### Behavioral Semantics
   
   #### Interaction decisions
   
   | Exception at record time | Read back at replay | Replayed exception |
   |---|---|---|
   | Serializable | Deserializes | The original type with its fields, message, 
cause and stack trace |
   | Serializable | Fails (class changed, missing, corrupt bytes) | 
Class-and-message reconstruction, as before; a warning is logged |
   | Not serializable | n/a, `serializedException` omitted | Class-and-message 
reconstruction, as before |
   | Record written before this change | n/a, no `serializedException` | 
Class-and-message reconstruction, as before |
   
   #### Behavioral contracts
   
   1. A recorded failure whose exception is serializable replays as an instance 
of the same class, with the same field values and message, on the sync path, 
the async path and `gather`.
   2. Replaying a recorded failure does not call the callable again.
   3. A non-serializable exception is recorded and replayed through the 
existing class-and-message path; recording does not fail.
   4. A serialized form that cannot be read back falls back to the existing 
reconstruction instead of failing the replay.
   5. Cancellation and framework faults are not recorded as business failures 
(unchanged).
   
   #### Failure behavior
   
   Serialization failure at record time is absorbed (debug log) and the record 
is written without `serializedException`. Deserialization failure at replay is 
absorbed (warning log) and falls back. Neither raises.
   
   ### Tests
   
   | Contract | Tests |
   |---|---|
   | 1 | 
`RunnerContextImplDurableExecuteTest.structuredFailureReplaysWithItsTypeAndFields`,
 
`JavaRunnerContextImplDurableExecuteAsyncTest.testDurableExecuteAsyncStructuredFailureReplaysWithItsTypeAndFields`,
 `testGatherReturnsStructuredCachedFailureOutcome`, 
`DurableExecutionContextTest.testDurableExecutionExceptionRestoresTypeWhenStringConstructorMissing`
 |
   | 2 | the same sync and async tests assert the call count stays at 1; the 
async and gather tests also assert the replay executor is not used |
   | 3 | `unserializableFailureReplaysFromItsClassAndMessage` |
   | 4 | `unreadableSerializedFailureReplaysFromItsClassAndMessage` |
   | 5 | existing interruption and `UncapturableException` tests, unchanged |
   
   The sync and async tests record the failure, round-trip the `ActionState` 
through `ActionStateSerde`, and replay in a new context. All four contract 1 
tests fail on main. `RunnerContextImplDurableExecuteTest`, 
`JavaRunnerContextImplDurableExecuteAsyncTest` and 
`DurableExecutionContextTest` pass, and the full runtime module passes except 
`JavaMCPStartupIntegrationTest`'s startup timeout, which fails the same way on 
main locally.
   
   Not verified: a full cluster failover, and Python-side durable failures 
(Python records its own payload and is not touched here).
   
   ### API
   
   No public API change. `DurableExecutionException` gains a three-argument 
constructor and ignores unknown JSON fields. Records written by this version 
carry an extra field; a runtime older than this change cannot read those 
records, because its mapper rejects unknown fields, so rolling back across this 
change after a failure was recorded fails that replay. Records written before 
this change replay as before. There is no size cap on the serialized exception, 
which includes its stack trace and cause chain; if you want one, I can skip the 
serialized form above a threshold and fall back to class and message.
   
   ### Documentation
   
   - [ ] `doc-needed`
   - [x] `doc-not-needed`
   - [ ] `doc-included`
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   - [x] Yes
   - [ ] No
   
   Generated-by: Claude Code 2.1.331 (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