SEPURI-SAI-KRISHNA opened a new issue, #13554:
URL: https://github.com/apache/seatunnel/issues/13554

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues. Related but different: #13208 (the barrier case, 
open fix #13209), #13317 and #13339 (terminal task events), #13338 (restore 
error report).
   
   ### What happened
   
   This is the follow-up agreed in #13209. On Zeta the master addresses five 
operations to a task by `TaskLocation` only:
   - `CheckpointBarrierTriggerOperation`
   - `NotifyTaskStartOperation`
   - `NotifyTaskRestoreOperation`
   - `CheckpointFinishedOperation`
   - `CheckpointEndOperation`
   
   The worker resolves the task group by `TaskGroupLocation` 
(`TaskExecutionService.getExecutionContext` or `getTask`). A pipeline restore 
deploys the next attempt at the same location. Each deployment has an 
`executionId` in its `TaskGroupContext`, but none of these operations carries 
one. So the worker cannot tell an operation of an ended attempt from one of the 
current attempt.
   
   Measured on one in-process node, with the engine classes of dev `ee0fb0d72f` 
and a task that records each call. "Next attempt" means a new deployment at the 
same location:
   
   | Case | barrier | start | restore | finished | end |
   |---|---|---|---|---|---|
   | A: sent while the group has no context and state `CREATED` (as after a 
reset); next attempt deployed 1 s later | reaches the next attempt | reaches it 
| reaches it | fails at once | fails at once |
   | B: no context, state `CANCELED`: time until the operation fails | 21 ms | 
60,033 ms | 4 ms | 3 ms | 2 ms |
   | C: sent after attempt 1 was cancelled and the next attempt deployed | 
reaches it | reaches it | reaches it | reaches it | reaches it |
   | D: as A, but state `CANCELED` when sent and `CREATED` before the next 
attempt | no | reaches it | no | not run | not run |
   
   Three behaviours cause this:
   - **Retry:** barrier, start and restore retry 
`TaskGroupContextNotFoundException` 30 times, 2 s apart. An operation sent for 
a missing context waits up to 60 s and then reaches whichever deployment is 
published at that location (A). For the barrier this is #13208.
   - **Start retries after the end:** in `NotifyTaskStartOperation` the 
condition is `exception instanceof TaskGroupContextNotFoundException || 
exception instanceof NullPointerException && !server.taskIsEnded(...)`. Because 
`&&` binds first, a missing context is retried even when the group has ended 
(B, D). The other four conditions require `!taskIsEnded`.
   - **Dead retry:** `CheckpointFinishedOperation` and `CheckpointEndOperation` 
catch every exception and throw a new `SeaTunnelEngineException`, so their 
retry condition never matches (A, B).
   
   What a stale operation then does to a `SeaTunnelTask` of the next attempt 
(read, not run):
   - **restore:** `restoreState` runs with the stale operation's state and 
completes `restoreComplete`. When the attempt's own restore follows, 
`SourceFlowLifeCycle.restoreState` sends its splits to the enumerator again, 
and `SinkFlowLifeCycle.restoreState` creates a second writer.
   - **start:** `startCalled` is set, so the task leaves `READY_START` without 
waiting for the master's start, which is sent only after every task has 
reported `READY_START`.
   - **finished:** `SinkFlowLifeCycle.notifyCheckpointComplete` commits its 
`lastCommitInfo` without checking the checkpoint id.
   
   I would like to work on this. Proposed direction, to agree here before I 
open a PR: the master sends the expected `executionId` with these five 
operations and keeps the current one per task group where a new master can read 
it after failover. The worker drops an operation whose id does not match its 
context. I would reuse the id that #13339 adds to terminal events, so there is 
one attempt token. With that check in place, retrying while the context is 
missing becomes safe, which answers @nzw921rx's question in #13209. The 
serialized form of the operations changes, so the PR needs a rolling-upgrade 
note. Fixing the `NotifyTaskStartOperation` condition and the dead retry would 
be part of the same PR.
   
   ### SeaTunnel Version
   
   dev (`5cf050be3f`). Measured on `ee0fb0d72f`; the six commits since then 
change no engine file.
   
   ### SeaTunnel Config
   
   ```conf
   # none: in-process probe, no job config
   ```
   
   ### Running Command
   
   ```shell
   In-process probe (AbstractSeaTunnelServerTest): deployLocalTask with a 
recording AbstractTask, operations sent with 
NodeEngineUtil.sendOperationToMemberNode. Happy to share the probe.
   ```
   
   ### Error Exception
   
   ```log
   B start: failed: TaskGroupContextNotFoundException: task group 
TaskGroupLocation{jobId=20001, pipelineId=1, taskGroupId=...} not found. after 
60033 ms
   ```
   
   ### Zeta or Flink or Spark Version
   
   Zeta
   
   ### Java or Scala Version
   
   JDK 17
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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