zhangshenghang opened a new pull request, #13486:
URL: https://github.com/apache/seatunnel/pull/13486

   Yes. I am contributing to Apache SeaTunnel.
   
   ### Purpose of this change
   
   A savepoint request must not be silently re-executed on another master. This 
change makes the `savePointJob` client request non-retryable and adds an E2E 
regression test for a master switch that happens while a stop-with-savepoint 
request is still waiting for its barrier acknowledgements.
   
   ### Problem
   
   `SeaTunnelEngine.yaml` declared `savePointJob` with `retryable: true`, so 
the generated `SeaTunnelSavePointJobCodec` sent the invocation as retryable. 
When the active master died while the savepoint barrier was unacknowledged, the 
Hazelcast client re-sent the request to the newly active master. The new master 
first restored the job (`DOING_SAVEPOINT -> PENDING -> SCHEDULED -> RUNNING`), 
and one second later the retried request pushed it back to `DOING_SAVEPOINT`. 
That checkpoint was never acknowledged, expired after `checkpoint.timeout`, the 
pipeline was cancelled and the job ended `FAILED`; after the terminal cleanup 
the status even became `UNKNOWABLE`. A master switch therefore destroyed a job 
it is supposed to preserve.
   
   Savepoints are not idempotent: re-running one on a restored job is never the 
intended semantics. The client should fail the call and let the operator decide 
whether to request a new savepoint.
   
   ### Changes
   
   - `client-protocol-definition/SeaTunnelEngine.yaml`: 
`savePointJob.request.retryable: false` with the rationale next to it.
   - `SeaTunnelSavePointJobCodec#encodeRequest`: generated code aligned 
(`setRetryable(false)`).
   - New `SavepointInFlightMasterFailoverIT` plus test-only fixtures 
(`SavepointBarrierHoldGate`, `SavepointBarrierHoldSink*`) and its job template:
     - submits a streaming job with a large FakeSource split and waits until 
the sink has processed rows;
     - holds the savepoint barrier inside the sink writer (`snapshotState`), so 
the request is provably in flight;
     - shuts down the active master while the job is `DOING_SAVEPOINT` and the 
pending checkpoint id matches the held barrier;
     - requires the client savepoint call to fail (not to be retried), the 
restored job to stay `RUNNING` for a stability window (a retried request would 
put it back to `DOING_SAVEPOINT`), and the job to remain cancellable.
   
   ### Test
   
   ```
   ./mvnw -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base \
     -DskipUT=true -DskipIT=false -Dit.test=SavepointInFlightMasterFailoverIT 
-Dskip.spotless=true verify
   ```
   
   Result: `Tests run: 1, Failures: 0, Errors: 0` (about 71 s).
   
   Negative control: with `setRetryable(true)` restored, the same test fails 
because the retried savepoint leaves the job unrecoverable (`expected: 
<RUNNING> but was: <UNKNOWABLE>`), which is exactly the regression this test 
guards.
   
   ### Compatibility
   
   Only the client retry policy of one protocol message changes; no REST API, 
config option, wire-format field or public class signature changes. Retrying a 
savepoint is not a documented or relied-on behavior: a transient failure now 
surfaces to the caller instead of being replayed on another member.
   
   Closes #13485
   


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