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

   ### Contribution acknowledgement
   
   Yes — this change contributes to Apache SeaTunnel.
   
   ### Purpose
   
   Fixes #13504.
   
   Both client-protocol checkpoint monitoring calls always failed in `dev`: 
`JobClient#getCheckpointHistory` and `JobClient#getCheckpointOverview`. The CLI 
options built on them (`--checkpoint-history-job-id`, 
`--checkpoint-overview-job-id`) were therefore unusable, while the REST 
endpoints kept working.
   
   Root cause: these requests are sent to the active master, so 
`GetCheckpointHistoryOperation#run` / `GetCheckpointOverviewOperation#run` 
executed on a Hazelcast operation thread. Both read the checkpoint monitor 
state through `CheckpointMonitorService` -> `CheckpointOverviewStateStore#get`, 
i.e. a blocking `IMap#get`. Hazelcast rejects a blocking wait on an operation 
thread, so every call failed with:
   
   ```
   java.lang.AssertionError: Waiting for response on this thread is illegal
       at 
com.hazelcast.spi.impl.AbstractInvocationFuture.registerWaiter(AbstractInvocationFuture.java:1155)
       at 
com.hazelcast.map.impl.proxy.MapProxySupport.invokeOperation(MapProxySupport.java:480)
       at ...HazelcastCheckpointOverviewStateStore.get(...)
       at ...CheckpointMonitorService.getHistory(...)
       at 
...GetCheckpointHistoryOperation.run(GetCheckpointHistoryOperation.java:64)
   ```
   
   The REST endpoints were unaffected because their servlet runs on a Jetty 
thread, which is exactly why the existing end-to-end coverage 
(`RestApiIT#testCheckpointOverviewAndHistoryApi`) never caught this.
   
   A second defect surfaced once the read stopped blocking: when the master has 
no monitor state for the job (before the first checkpoint is triggered, or for 
an unknown job), `GetCheckpointOverviewOperation` serialized a null payload. 
The generated response codec encodes the non-nullable `Data` field 
unconditionally, so the response encoding on the master failed with 
`NullPointerException: Cannot invoke "Data.toByteArray()" because "data" is 
null`.
   
   ### Implementation
   
   - `CheckpointOverviewStateStore#getAsync` (new): non-blocking read of the 
overview. `HazelcastCheckpointOverviewStateStore` implements it with 
`IMap#getAsync` and adapts the `CompletionStage` to a 
`PassiveCompletableFuture`.
   - `CheckpointMonitorService#getOverviewAsync` / `#getHistoryAsync`: async 
variants for callers on operation threads. The history filtering/ordering/limit 
logic is extracted into a shared `buildHistory` helper so the REST path and the 
client path cannot drift apart.
   - `GetCheckpointHistoryOperation` / `GetCheckpointOverviewOperation` now 
extend `AsyncOperation` and complete their response from the future instead of 
blocking the operation thread. `AllowedDuringPassiveState` and the serialized 
request/response layout are preserved.
   - When the master has no overview for the job, the overview operation 
returns an empty `CheckpointOverview(jobId)` instead of a null payload, 
matching what `GET /jobs/checkpoints` reports for a job without monitor state.
   
   ### E2E coverage
   
   `CheckpointHistoryClientIT` starts a real split master/worker cluster, 
submits a real streaming job with 1s checkpoints, and drives the client 
protocol:
   
   - the overview and the history must be served while the job runs (before the 
fix the very first call fails with the `AssertionError` above);
   - the history must contain the checkpoint the overview reports as latest 
completed;
   - the history is ordered newest first, and the pipeline / status / limit 
filters are applied by the master;
   - an unknown pipeline or job yields an empty history, and a job without 
monitor state yields an empty overview instead of a failed response.
   
   The new fixture only uses FakeSource -> Console so it exercises the engine's 
checkpoint scheduling and checkpoint monitor state, not connector behaviour.
   
   ### Verification
   
   - New IT fails on pre-fix code with the reported `AssertionError`, passes 
with the fix (JDK 17, in-process master + worker; 13s).
   - `./mvnw spotless:apply` on the changed modules.
   - `./mvnw -DskipTests verify` on `seatunnel-engine-server` and 
`connector-seatunnel-e2e-base`.
   
   ### Compatibility
   
   No configuration option, data format or public API signature changes. The 
two operations keep their wire payload; only the thread on which the monitor 
state is read changes, and an absent overview is now encoded as an empty 
overview instead of a null payload the codec could not encode.
   


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