wenjin272 opened a new issue, #1436:
URL: https://github.com/apache/flink-agents/issues/1436

   ### Search before asking
   
   - [x] I searched the issues and found no existing issue tracking this Java 
runtime problem. #1181 covers a related Python pickle failure, but does not 
address Java exception type and field preservation.
   
   ### Description
   
   Java durable execution can replay a different exception from the one thrown 
during the original execution. This changes application error handling after 
recovery.
   
   `RunnerContextImpl.DurableExecutionException` persists only the exception 
class name and message. On replay, it tries a public `(String)` constructor and 
falls back to `RuntimeException` if reconstruction fails:
   
   
https://github.com/apache/flink-agents/blob/e1d2a073bdcfc50e15411e27c20d2a3e32b4cc8d/runtime/src/main/java/org/apache/flink/agents/runtime/context/RunnerContextImpl.java
   
   Consequently:
   
   - Exceptions without a public `(String)` constructor lose their concrete 
type. A typed `catch` that handles the original failure no longer handles the 
replayed failure.
   - Even when that constructor exists, additional business fields are not 
persisted and cannot be restored, such as a task handle, status, or retry 
metadata.
   
   This was found while reviewing #1382: its Java media exceptions carry a job 
handle and status, and the timeout exception also carries a polling budget. 
However, the limitation is in the existing runtime and applies to other 
structured exceptions as well. This issue tracks the general Java runtime 
problem independently of that PR.
   
   Expected behavior: define and support a durable exception round-trip 
contract that preserves the concrete exception type and the business fields 
required by its handlers. Merely adding `(String)` constructors to individual 
exceptions does not preserve those fields. The serialization mechanism and 
behavior for unsupported exception types should be explicit rather than 
assuming arbitrary exceptions can be reconstructed from a message.
   
   ### How to reproduce
   
   The following minimal probe exercises the runtime's exception 
recording/reconstruction helper without requiring a media provider:
   
   ```java
   import 
org.apache.flink.agents.runtime.context.RunnerContextImpl.DurableExecutionException;
   
   public class DurableExceptionRoundTripProbe {
       public static final class TaskFailure extends RuntimeException {
           private final String taskId;
   
           public TaskFailure(String taskId, String message) {
               super(message);
               this.taskId = taskId;
           }
   
           public String getTaskId() {
               return taskId;
           }
       }
   
       public static void main(String[] args) {
           TaskFailure original = new TaskFailure("task-1", "timed out");
           Exception replayed = 
DurableExecutionException.fromException(original).toException();
           System.out.println(replayed.getClass().getName());
           System.out.println(replayed instanceof TaskFailure);
       }
   }
   ```
   
   Observed output:
   
   ```text
   java.lang.RuntimeException
   false
   ```
   
   The same reconstruction is used when reading a recorded durable failure. 
During the original call, the runtime throws the original exception; during 
replay, it throws the reconstructed one.
   
   Regression coverage should exercise persisted exception payloads through the 
actual synchronous and asynchronous durable replay paths, verify the type and 
business fields, and confirm that replay does not execute the callable again. 
Cancellation and framework faults must remain excluded from persisted business 
failures.
   
   ### Version and environment
   
   Java runtime. The class/message-only implementation is present on current 
main (`e1d2a073bdcfc50e15411e27c20d2a3e32b4cc8d`). The local helper probe 
reproduced the type loss; no full cluster failover test was run for this report.
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!
   


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