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

   ### Contribution acknowledgement
   
   Yes — I am contributing this change to **Apache SeaTunnel**, and I confirm 
it follows the project's contribution conventions (English PR 
title/description, one focused change, formatting and E2E validated locally). 
This is a test-only change: no production code, configuration default, REST/API 
or data format is modified.
   
   ### What this PR does
   
   Adds `RestoreMetricsResetIT`, an E2E regression guard for the runtime 
metrics of a pipeline that the Zeta engine restores after a task failure, plus 
a test-only sink fixture (`RestoreMetricsProbe`) that fails exactly once and 
paces its writes.
   
   The fixture is a single in-process Zeta node with one streaming pipeline 
(`FakeSource` → probe sink, parallelism 1, `checkpoint.interval = 1000`, 
`job.retry.times = 3`, `job.retry.interval.seconds = 0`):
   
   - the probe sink's **first** writer fails on purpose after 20 rows, so the 
task fails and the engine restores the pipeline; every later writer of the same 
sink label runs normally;
   - the probe paces every write (100 ms per row), so the written-row metric of 
the restored attempt can be sampled while it is still small instead of jumping 
straight past the failure point;
   - the test requires that, from the moment the restored sink writer is 
deployed, the pipeline's `SinkWriteCount` is observed at or below **half** the 
failed attempt's rows (the restored attempt starts over), and that it later 
grows **past** that point (the restored attempt makes progress), with the job 
staying `RUNNING` throughout.
   
   ### Why this is a boundary with real regression risk
   
   A restored pipeline reuses the task-group locations of the failed attempt. 
The worker keeps serving the failed attempt's task-group metrics for those 
locations, and the engine only discards them when the restore path cleans the 
task-group contexts (`JobMaster#clearPipelineMetricsForRestore`, called from 
`SubPlan#prepareRestorePipeline`, added with #11495). A refactor that drops 
that call, that removes only the metrics snapshots but not the task-group 
contexts, or that clears the metrics after the replacement attempt is deployed 
instead of before it, silently makes the restored pipeline continue counting 
from the failed attempt's values.
   
   The job stays `RUNNING`, checkpoints keep completing, and every 
REST/`JobClient` request succeeds — only the numbers are wrong. Operators use 
these counters for throughput, backlog and capacity decisions, so a silent 
double count is a user-visible correctness problem with no failing status to 
notice.
   
   ### Why the existing coverage does not reach it
   
   - The unit tests added with #11495 (`StateTransitionCleanupTest`) mock 
`JobMaster`/`SeaTunnelServer`; they assert the call order and the state-store 
removal but never run a real task failure against a real worker-side metrics 
registry.
   - `CommittedMetricsIT`, `MultiTableMetricsIT` and `RealtimeMetricsRestIT` 
assert the metrics of healthy jobs (and of finished jobs), never the metrics of 
a pipeline that was restored.
   - `ClusterFaultToleranceIT` logs the job metrics after a failure but does 
not assert them, and it exercises worker/master loss rather than a task failure 
with a pipeline retry.
   - `JobMetricsTest` (engine-server unit test) restarts a savepoint-restored 
job, which creates a fresh `JobMaster` and therefore cannot observe the 
per-pipeline restore path.
   
   No existing engine E2E asserts that the metrics of a restored pipeline 
belong to the new attempt.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. Test-only change: one E2E class, one test-tree sink fixture (four files) 
and one job config.
   
   ### How was this patch tested?
   
   ```
   ./mvnw -pl seatunnel-engine/seatunnel-engine-server -am install -DskipTests
   ./mvnw -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base \
     -DskipUT=true -DskipIT=false -Dit.test=RestoreMetricsResetIT \
     -DfailIfNoTests=false verify
   ./mvnw -pl seatunnel-ci-tools test -Dtest=ImportClassCheckTest
   ```
   
   Result: `Tests run: 1, Failures: 0, Errors: 0, Skipped: 0` (about 9 s on JDK 
17), five consecutive runs; the last run was a full `verify` including 
`spotless:check`. `ImportClassCheckTest` passes (8 tests).
   
   Negative control: commenting out the 
`jobMaster.clearPipelineMetricsForRestore(getPipelineLocation())` call in 
`SubPlan`, rebuilding `seatunnel-engine-server` and re-running the test makes 
it fail after the observation window with:
   
   ```
   The metrics of the restored pipeline must start from the new attempt, but 
the lowest
   written-row count observed after the restore was 19 (the failed attempt 
wrote 20 rows
   before failing). Samples: [19, 19, ... 1675, 1676] (2809 samples)
   ```
   
   The mutation was reverted, the pristine engine-server jar was reinstalled 
(sha256 `dd06e8ab…`), and the test passes again.
   


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