SEPURI-SAI-KRISHNA opened a new pull request, #13383:
URL: https://github.com/apache/seatunnel/pull/13383

   Yes, glad to contribute to Apache SeaTunnel.
   
   ### Purpose of this pull request
   
   Closes #13316.
   
   When a job ends, the callback that `JobMaster.initStateFuture` registers 
runs `cleanJob()` and only then completes `jobMasterCompleteFuture`. 
`cleanJob()` clears the checkpoints if needed, stores the job info and the 
finished state in the history, and schedules the removal of the job state maps; 
each of these can throw, for example while the checkpoint storage or the IMap 
is unavailable. `withTryCatch` logs and swallows the exception, so:
   
   - `jobMasterCompleteFuture` is never completed, and `JobMaster.run()` blocks 
on `jobMasterCompleteFuture.join()` in its `finally` forever, holding a 
coordinator thread;
   - clients waiting for the job hang;
   - the steps after the failing one do not run, so for example a failed 
checkpoint clear also skips the history and the removal of the job state maps.
   
   Changes, all in `JobMaster`:
   
   - The callback completes `jobMasterCompleteFuture` in a `finally`, so no 
cleanup failure can keep the job from completing.
   - `cleanJob()` runs each of its four steps on its own and logs a failure as 
a warning with the job id, so one failing step no longer skips the others.
   
   The job result is unchanged: a job that finished, failed or was canceled 
reports that status even when its cleanup partly failed. One consequence to 
note: if storing the finished state fails, the removal of the job state maps is 
still scheduled, so the final status of that job is not kept anywhere once the 
cleanup delay passes. Before, those maps were never removed and the client 
never got the result.
   
   I checked the open PRs that touch `JobMaster.java` (#13339, #13337, #12510, 
#12209, #12137, #12134, #12043, #11962, #11841, #11783, #11602, #11512, #11162, 
#10551, #10431): none changes `cleanJob()` or the completion of 
`jobMasterCompleteFuture`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. A job whose cleanup fails now completes: clients get its result and the 
coordinator thread is released, with a warning that names the failed step. No 
option, default, API or state format changes.
   
   ### How was this patch tested?
   
   - `JobMasterTest#testJobCompletesWhenACleanupStepFails`, parameterized over 
the clear of the checkpoints, the store of the job info and the store of the 
finished state. It builds a real `JobMaster` with spies on its 
`CheckpointManager` and `JobHistoryService`, makes the step throw, cancels the 
job before it starts and asserts that the job master future completes with 
`CANCELED` within 10 seconds, that every other step still ran, and that the 
cleanup record of the job state maps was added (observed with an entry 
listener, since the coordinator may process and remove it right away).
     - With the `JobMaster` of dev all three cases time out, and the log shows 
the injected exception swallowed in the callback, as described in the issue.
     - With only the `finally` and the old `cleanJob()`, all three fail: the 
future completes, but the steps after the failing one do not run.
   - `./mvnw test -pl seatunnel-engine/seatunnel-engine-server` on JDK 17: 732 
tests, 0 failures, 0 errors, 5 skipped. `JobMasterTest`: 13 tests, 0 failures.
   - `spotless:check`, `git diff --check`.
   
   ### Check list
   
   * [x] If any new Jar binary package adding in your PR, please add License 
Notice according
     [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
 (no new jar)
   * [x] If necessary, please update the documentation to describe the new 
feature. https://github.com/apache/seatunnel/tree/dev/docs (not needed: no 
option or behavior a user configures)
   * [x] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this PR. (not needed)
   * [ ] If you are contributing the connector code, please check that the 
following files are updated: (not a connector)
   


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

  • [PR] [Fix][Zeta] Complete a jo... SEPURI-SAI-KRISHNA (via GitHub) via commits

Reply via email to