You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "Vivek1106-04 (via GitHub)" <gi...@apache.org> on 2026/09/22 12:47:55 UTC

[I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Vivek1106-04 opened a new issue, #12441:
URL: https://github.com/apache/seatunnel/issues/12441

   ### What happened
   
   `CheckpointCoordinator.startSavepoint()` waits for the in-flight checkpoint to drain while
   holding the coordinator `lock`, and the periodic checkpoint trigger takes that same lock. A
   trigger that fires during a savepoint window therefore blocks on the savepoint for as long as
   the in-flight checkpoint takes, which is seconds under backpressure.
   
   `CheckpointCoordinator.java:917-920` on `dev`:
   
   ```java
   CompletableFuture<PendingCheckpoint> savepoint;
   synchronized (lock) {
       while (pendingCounter.get() > 0 && !shutdown) {
           Thread.sleep(500);
       }
   ```
   
   `tryTriggerPendingCheckpoint` (`CheckpointCoordinator.java:771`) enters `synchronized (lock)`
   before it can check anything, so it cannot fail fast and cannot re-arm itself; it simply waits.
   
   `CheckpointManager.triggerSavePoints()` (`CheckpointManager.java:229-233`) fans out over every
   coordinator of the job in a `parallelStream`, so one job suspend puts all of that job's
   pipelines into this state at the same time.
   
   ### Why this is worth a dedicated issue
   
   On `dev` today, the blocked trigger occupies a thread from that pipeline's own
   `newScheduledThreadPool(2, ...)`, so the cost is contained: a savepointing pipeline can only
   delay itself.
   
   #12165 (STIP-40, #12339) replaces those per-pipeline pools with one member-wide bounded
   dispatch pool. The blocking is unchanged, but its blast radius is not: enough concurrently
   savepointing pipelines can occupy dispatch threads that unrelated pipelines need for their own
   triggers and timeout watchdogs. That makes this a cross-pipeline coupling rather than a
   per-pipeline one.
   
   The mechanism is verified from source and was independently confirmed by @DanielLeens in review.
   Reaching simultaneous occupancy of the whole dispatch pool has **not** been reproduced - it needs
   periodic triggers to coincide with savepoint windows, a narrow coincidence at the default
   `checkpoint.interval` of 300000 ms, though the 500 ms re-arm at `CheckpointCoordinator.java:841`
   widens it. I am reporting the lock-holding, not a reproduced incident.
   
   ### Expected behavior
   
   A savepoint should not hold the coordinator lock while it sleeps. Two directions were discussed
   in the #12165 review:
   
   - **(a) Move the wait outside the lock.** Drain first, then take the lock to create the savepoint
     checkpoint. The larger and more correct change, and the one that fixes it for `dev` as well as
     for the shared scheduler.
   - **(b) Make the trigger non-blocking.** `tryLock` plus reschedule in the dispatch body, so a
     trigger that cannot get the lock re-arms itself instead of waiting. Smaller, and keeps the
     change inside the new scheduler, but leaves the lock-holding in place for every other caller.
   
   Either wants deterministic coverage: with dispatch capacity filled by savepoint-contended
   coordinators, an unrelated pipeline still receives its trigger and watchdog work on time.
   
   ### Context
   
   - STIP-40: #12339
   - PR: #12165, where the class Javadoc now documents this case explicitly rather than claiming a
     dispatched body is always short-lived
   - Benchmark: #12418 measures the scheduling delay this path would show up in
   


-- 
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: commits-unsubscribe@seatunnel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5902801924

   @Rangsh — agreed, and thanks for consolidating. Closing #12493 in favor of #12511 makes sense, since Vivek1106-04's change already carries the unlocked drain, the `CHECKPOINT_COORDINATOR_SHUTDOWN` mapping for a cut-short drain, and the SubPlan `jobMaster.isNeedRestore()` re-check.
   
   Since you offered to help on #12511, two things would be useful, both tied to the two bugs recorded above:
   
   1. Re-run `CheckpointCoordinatorTest#testTryTriggerNotBlockedBySavepointDrain` against #12511 (red base `c3f06f9a82c119e427df0fb1f440bae583148f62`) and confirm it still goes red → green there, so the part-1 proof carries over from #12493.
   2. Independently reproduce the SubPlan race: `SavePointTest#testSavePointButJobGoingToFail` failing with the unlocked drain but without the re-check and passing with it, and `SavePointTest#testSavePointFailureDuringPipelineRestoreWaitEndsTheJob` red on `dev`. A second look at the 4 s / 5 s savepoint outcomes vs. the 3 s restore wait is what I'd most like verified.
   
   @Vivek1106-04 — on bug 2, could you confirm here (or point to the relevant part of https://github.com/apache/seatunnel/pull/12493#issuecomment-5862502658) which of `CHECKPOINT_COORDINATOR_RESET`, `PIPELINE_END`, `CHECKPOINT_COORDINATOR_COMPLETED`, and the `handleCoordinatorError` reason are mapped to `CHECKPOINT_COORDINATOR_SHUTDOWN`, and which, if any, should still surface as a real savepoint failure? That's the remaining piece I'd like nailed down for the cut-short-drain behavior in #12511.
   
   <!-- streview-comment:1414 -->


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "Rangsh (via GitHub)" <gi...@apache.org>.
Rangsh commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5777719148

   @Vivek1106-04 @DanielLeens Here is my proposed solution. I would like to go over it with you and check whether there are any missing parts or unreasonable aspects.
   
   ## 1. Background
   
   Before creating a savepoint checkpoint, `CheckpointCoordinator.startSavepoint()` waits until any in-flight checkpoint has drained (`pendingCounter == 0`) or the coordinator has shut down. On current `dev`, that wait is a sleep-poll **inside** `synchronized (lock)`:
   
   ```java
   synchronized (lock) {
       while (pendingCounter.get() > 0 && !shutdown) {
           Thread.sleep(500);
       }
       // create + start SAVEPOINT_TYPE pending checkpoint
   }
   ```
   
   The periodic trigger path (`tryTriggerPendingCheckpoint`) also enters the same `lock` before it can skip, create a checkpoint, or re-arm the next timer. A trigger that fires during this window therefore blocks for as long as the in-flight checkpoint takes (often seconds under backpressure), instead of failing fast or re-arming.
   
   `CheckpointManager.triggerSavePoints()` fans out over every pipeline coordinator with `parallelStream`, so one job suspend can put all of that job's pipelines into this wait at the same time.
   
   Today the blocked trigger mainly occupies that pipeline's own small scheduled pool, so the damage is mostly self-contained. With the member-wide bounded dispatch pool from #12165 (STIP-40: #12339), the same lock-holding can occupy shared dispatch threads that unrelated pipelines need for their own triggers and timeout watchdogs. The issue reports the lock-holding defect (source-verified); full simultaneous occupancy of the dispatch pool is not required to justify fixing the lock scope.
   
   ## 2. Goal
   
   Keep savepoint's "wait for in-flight checkpoint, then create SAVEPOINT_TYPE" behavior, but **do not hold the coordinator lock while sleeping**. Concurrent work that needs the same lock (especially periodic triggers) must not be serialized behind that drain. Shutdown / already-completed / existing in-flight savepoint handling must stay correct. Checkpoint and savepoint completeness / recovery semantics must not change.
   
   ## 3. Design
   
   ### 3.1 Change the wait boundary in `startSavepoint()`
   
   1. Perform the `pendingCounter` drain wait **outside** `synchronized (lock)` (same 500 ms poll cadence, or equivalent), exiting when `pendingCounter == 0` or `shutdown`.
   2. Enter `synchronized (lock)` only for a short critical section that:
      - re-checks shutdown / completed (fail closed with the existing close reasons if the coordinator ended during the unlocked wait);
      - re-checks whether a savepoint is already in flight;
      - then `createPendingCheckpoint(..., SAVEPOINT_TYPE)` + `startTriggerPendingCheckpoint(...)`.
   3. Leave `CheckpointManager.triggerSavePoints()` fan-out and savepoint completion future wiring unchanged in this slice.
   
   This removes the long critical section at its source, so every caller of that lock benefits on current `dev` and under the shared dispatch pool—without relying on only the trigger path becoming non-blocking while savepoint still sleeps under the lock.
   
   ### 3.2 Correctness constraints for the unlocked window
   
   While waiting outside the lock, another thread may complete the pending checkpoint, shut the coordinator down, or start competing coordinator work. The post-wait locked section must therefore treat the unlocked drain as **stale until revalidated**, and must not create a savepoint against a terminal coordinator. Inclusive behavior for "already have an in-flight savepoint" should remain as today's early return of that savepoint's future.
   
   ### 3.3 Tests
   
   Add deterministic unit coverage in `CheckpointCoordinatorTest` (no full-cluster requirement for the first PR):
   
   1. Force `pendingCounter > 0`, start `startSavepoint()` on one thread so it enters the drain wait.
   2. Concurrently invoke `tryTriggerPendingCheckpoint` (or another path that needs the same `lock`) and assert it is **not** blocked for the full drain duration—i.e. sleep-poll no longer runs under the lock.
   3. After the pending checkpoint drains, assert the savepoint is still created successfully.
   4. Assert shutdown / already-completed during the unlocked wait still fails closed with the existing close reasons.
   
   I am not treating "fill the entire shared dispatch pool" as a merge gate for the first PR; scheduling-delay measurement can stay with #12418. The first PR should prove the lock-scope fix on current `dev` with the unit tests above.
   
   Please let me know if this direction looks right, or if anything above should be adjusted before I open the PR. Thanks!


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "Vivek1106-04 (via GitHub)" <gi...@apache.org>.
Vivek1106-04 commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5862580535

   @Rangsh @DanielLeens @SEZ9
   
   Recording two bugs here that stay silent on `dev` and that any correct fix for this issue exposes. The agreed plan and constraints above do not mention either of them, and #12493 does not fix them (details in https://github.com/apache/seatunnel/pull/12493#issuecomment-5862502658). I found both while writing my fix and have fixed them in the same change.
   
   **1. SubPlan restore race: job stuck in `DOING_SAVEPOINT`**
   
   A pipeline that fails while its job is in `DOING_SAVEPOINT` is reset and waits `pipelineRestoreIntervalSeconds` before restarting. `JobMaster.savepointFailed()` learns about the broken savepoint only after that decision and calls `forceStopPipeline()`. That call marks the job as never needing restore, but it finds only reset tasks and stops nothing. The pipeline then restarts after the wait, and the job never leaves `DOING_SAVEPOINT`.
   
   On `dev` the lock-held drain hides this, because it delays `cleanPendingCheckpoint` long enough that the timing rarely lines up. Once the drain is moved off the lock, `SavePointTest#testSavePointButJobGoingToFail` fails consistently in the full test run. Any fix for this issue has to include a fix for this race, or it turns `SavePointTest` red.
   
   Fix: after the restore wait, `SubPlan` re-checks `jobMaster.isNeedRestore()`. If a stop was decided meanwhile, the pipeline goes back to the terminal state it failed with, keeping its error, so the normal terminal path ends it. Regression: `SavePointTest#testSavePointFailureDuringPipelineRestoreWaitEndsTheJob` with two pipelines. One sink fails the savepoint at 4 s and the other finishes its part at 5 s, so the stop lands inside the 3 s restore wait. It is red on `dev`, where the job stays in `DOING_SAVEPOINT`.
   
   **2. Failure reason when the drain is cut short**
   
   Constraint 2 above says every interrupt, shutdown, completion and create failure path completes the shared future exceptionally, but it does not say with which reason, and the reason matters. `JobMaster.isSavepointStartPreconditionException` treats a savepoint as never started, and retryable, only for `CHECKPOINT_COORDINATOR_SHUTDOWN` and `TASK_NOT_ALL_READY_WHEN_SAVEPOINT`.
   
   `cleanPendingCheckpoint` is called with `CHECKPOINT_COORDINATOR_RESET`, `PIPELINE_END` (from `cancelCheckpoint`), `CHECKPOINT_COORDINATOR_COMPLETED`, or the reason from `handleCoordinatorError`. The natural reading, failing the future with that close reason, is a bug. If a pipeline ends while a savepoint is draining, the job master then handles it as a real savepoint failure even though no savepoint checkpoint was ever created, and `SavePointTest` breaks. A drain ended by `cleanPendingCheckpoint` has to report `CHECKPOINT_COORDINATOR_SHUTDOWN`, whatever the close reason.
   
   **Also a correction to the plan:** the gate check belongs next to `pendingCounter > 0` in `tryTriggerPendingCheckpoint()`, not in `createPendingCheckpoint()`, because `createPendingCheckpoint()` cannot re-arm the trigger.
   
   I am opening my PR for this issue now, based on `dev`. It contains the drain-off-lock fix with the part 1 regression (red on `dev`), plus the fixes for both bugs above. Part 2 (cross-pipeline) is written and red/green on top of #12165, and will follow once #12165 is merged, so this issue stays open until then, as agreed.
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5807100783

   @Vivek1106-04 thanks for recording this here. Agreed on the red-first regression as the closing condition for this issue.
   
   On part 1 (same coordinator): this is the direct check for the problem under discussion — `startSavepoint()` sleep-polling `pendingCounter` while holding the coordinator lock, which blocks `tryTriggerPendingCheckpoint()` for the whole drain. Running it against current `dev` before the fix and showing the blocking behavior is the right way to prove the test actually exercises the lock, so please treat that as a hard requirement for the PR: hold `pendingCounter > 0`, start the savepoint, call `tryTriggerPendingCheckpoint()`, and assert it returns well within the drain time, creates no new pending checkpoint, and re-arms. This also folds in the "no non-savepoint pending checkpoint while the gate is set" check from the constraints above, so one deterministic test covering both is fine.
   
   On part 2 (cross-pipeline): agreed that it can only go red on a base that includes the shared dispatch pool from #12165, so the ordering you laid out works for me — both parts in one PR if #12165 lands first, otherwise part 1 lands with the fix and part 2 follows once #12165 is in. Either way this issue stays open until part 2 has been shown red then green.
   
   Remaining asks for whoever opens the fix PR:
   
   1. Implement the unlocked drain per the four constraints already recorded above (shared draining future installed under the lock, wait outside the lock, exceptional completion on every interrupt/shutdown/completed/create-failure path, gate honored by all non-savepoint trigger paths with re-arm).
   2. Include the part 1 regression and, in the PR description, the red run: which test, which base revision, and the observed failure.
   3. If part 2 is included, add the same red-run record for it; if not, note in the description that part 2 is pending #12165 so we don't lose track.
   4. Keep the #12442 trigger-failure policy out of this change.
   
   <!-- streview-comment:1288 -->


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5951992366

   Thanks for supplying the carry-over proof with the actual red assertion and for separating the two restore-race scenarios.
   
   That evidence closes the remaining source-level questions on the intended #12511 behavior: the savepoint drain must not hold the coordinator lock, the cut-short drain must use the retryable shutdown classification, and the SubPlan restore wait must re-check whether restoration is still required. I do not need additional retry loops in this issue at this point.
   
   However, the current #12511 Build is failing. The issue therefore remains open and the fix must not be treated as present in `dev` or ready for merge. Please resolve the Build failure (or document concrete evidence that it is unrelated), then keep the existing red-to-green regressions intact for review.
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5892218040

   Classification: A / Zeta savepoint coordinator lock and terminal-state handling.
   
   Closing #12493 in favor of #12511 is the correct consolidation: the latter is the single implementation path for the unlocked in-flight-checkpoint drain, the cut-short-drain shutdown mapping, and the SubPlan restore re-check. Please do not reopen or continue a competing drain PR.
   
   This is not complete in `dev`: #12511 is open and its Build is currently failing. The implementation remains blocked until the failing Build is resolved or independently shown unrelated, the branch is current with `dev`, and the savepoint regressions prove the lock release, shutdown classification, and failure-during-restore behavior together. No label, assignment, or closure change in this pass.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "Vivek1106-04 (via GitHub)" <gi...@apache.org>.
Vivek1106-04 commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5982000984

   @SEZ9 sorry for the slow answer on bug 2. In #12511, when `cleanPendingCheckpoint` cuts a draining savepoint short, the request always fails with `CHECKPOINT_COORDINATOR_SHUTDOWN`, whatever the close reason:
   
   | Close reason | Caller | Savepoint request fails with |
   |---|---|---|
   | `CHECKPOINT_COORDINATOR_RESET` | `restoreCoordinator()` (master failover) | `CHECKPOINT_COORDINATOR_SHUTDOWN` |
   | `PIPELINE_END` | `cancelCheckpoint()` | `CHECKPOINT_COORDINATOR_SHUTDOWN` |
   | `CHECKPOINT_COORDINATOR_COMPLETED` | completion of the final checkpoint | `CHECKPOINT_COORDINATOR_SHUTDOWN` |
   | reason passed to `handleCoordinatorError` | coordinator error | `CHECKPOINT_COORDINATOR_SHUTDOWN` |
   
   None of them should surface as a real savepoint failure. A draining request has not created its savepoint checkpoint yet, so nothing was started, and `JobMaster.isSavepointStartPreconditionException` is the contract for exactly that case. It is also what `dev` returned when its drain loop noticed `shutdown`.
   
   What does still surface as a real failure is a savepoint whose checkpoint was created and then aborted. Its `PendingCheckpoint` fails with the abort reason, and that reaches the shared request unchanged.
   
   As of `a691fb195`, `CheckpointCoordinatorTest#testCoordinatorResetDuringSavepointDrainFailsTheRequestAndResumesTriggering` is parameterized over all four reasons (with `CHECKPOINT_INSIDE_ERROR` standing in for the error case) and asserts `CHECKPOINT_COORDINATOR_SHUTDOWN` for each.
   
   The branch is rebased onto current `dev`, and both red-to-green regressions are still on it. The round answering DanielLeens's review is pushed, and CI is running on the new head.
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5825951039

   Thanks @Vivek1106-04, recording this here works for me. Agreed: the regression is how this issue closes, and both parts must be shown red on the current blocking lock acquisition before the fix turns them green.
   
   On part 1 (same coordinator): this is the right shape. Hold `pendingCounter > 0`, start `startSavepoint()`, then call `tryTriggerPendingCheckpoint()` on the same coordinator. Red run: it blocks for the full drain on current `dev`. Green run: it returns within a bound far below the drain time, creates no pending checkpoint, and re-arms. That lines up with constraints 3 and 4 already listed above (no new non-savepoint pending checkpoint while the gate is set, re-arm rather than drop). Two asks so this stays deterministic rather than sleep-timed:
   
   - Gate the drain with a latch/future the test controls, so "blocks for the full drain" and "returns well under the drain time" are asserted against a test-owned signal, not wall-clock sleeps.
   - Cover the general, completed-point, and schema-change trigger paths in the same test, since all three must re-arm identically.
   
   On part 2 (cross-pipeline): agreed on the ordering dependency. It can only go red on a base that contains the shared dispatch pool, so either both parts land in this PR if the scheduler change merges first, or the fix lands with part 1 and part 2 follows immediately after. Thanks for offering to write part 2 yourself in that case; this issue stays open until part 2 has been shown red then green.
   
   For the PR description, please include for each part: the test name, the base revision it was run against, and the observed failure (blocking/starvation), followed by the passing run with the fix.
   
   Everything else above stands unchanged, including keeping the unexpected-trigger-failure policy out of this change.
   
   <!-- streview-comment:1303 -->


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "Rangsh (via GitHub)" <gi...@apache.org>.
Rangsh commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5853901285

   @Vivek1106-04 @DanielLeens @SEZ9
   
   I have opened the fix PR for this issue: https://github.com/apache/seatunnel/pull/12493
   
   It follows the agreed direction and constraints:
   
   1. Unlocked drain with one shared savepoint request/future + gate installed under the lock
   2. Drain wait outside the lock; interrupt / shutdown / completed / create-failure paths clear the gate and complete the shared future exceptionally
   3. While the gate is set, all non-savepoint `tryTriggerPendingCheckpoint` paths (general / completed-point / schema-change) skip create and re-arm
   4. Deterministic part-1 unit coverage in `CheckpointCoordinatorTest`
   
   **Part 1 red → green** (as required):
   
   | | |
   |---|---|
   | Test | `CheckpointCoordinatorTest#testTryTriggerNotBlockedBySavepointDrain` |
   | Red base | `c3f06f9a82c119e427df0fb1f440bae583148f62` (`dev`) |
   | Red | trigger blocked for the full drain while `pendingCounter > 0` |
   | Green | same test + gate / coalesce / interrupt-cleanup — all passing on the PR |
   
   Drain lifetime is owned by the test via `pendingCounter` (latch-style), not wall-clock sleeps.
   
   **Part 2** (cross-pipeline) is noted in the PR as pending #12165, per the ordering we agreed. #12442 trigger-failure policy is kept out of this change.
   
   Please take a look when you have a chance. Thanks!


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5964403529

   @Rangsh — thanks for running both verification points on #12511 and writing them up this clearly.
   
   On point 1, the carry-over is accepted. Re-applying `testTryTriggerNotBlockedBySavepointDrain` onto the #12511 tip and showing it red on `c3f06f9a82c119e427df0fb1f440bae583148f62` with the `tryTriggerPendingCheckpoint must return while savepoint drain is still held` assertion, then green on `91001c42caeb25ae1a44cc3b7eeeab1c57201cfb`, is exactly the proof I was after. It is also fine that the test on #12511 itself is named `testTriggerDuringSavepointDrainReturnsAndRearmsWithoutCreatingACheckpoint`; the behaviour under test is the same.
   
   On point 2, the three-row table answers the restore-race question. The source timings you pulled (4 s `prepareCommit` failure, 5 s `checkpoint_sleep`, 3 s `JOB_RETRY_INTERVAL_SECONDS` default) line up with the scenario, and seeing `testSavePointFailureDuringPipelineRestoreWaitEndsTheJob` red on the drain-only commit `146a1b5c5`, red on `dev` at `4c874e2a4061aea9d5db65e74edeb211b498fe27`, and green on the full #12511 tip isolates the `isNeedRestore()` re-check as the piece that fixes it. Nothing more is needed from you on either of these two points.
   
   What's still open is unchanged from before: #12511's Build is failing, so the fix is not in `dev` and I'm keeping this issue open. Remaining asks:
   
   1. Get the #12511 Build green, or post concrete evidence that the failure is unrelated to the savepoint changes.
   2. Keep both red → green regressions (the drain test and `testSavePointFailureDuringPipelineRestoreWaitEndsTheJob`) intact on the branch as it is updated so they can be re-checked at review time.
   
   Closing #12493 in favor of #12511 stays the right call; please don't reopen a parallel drain PR. If you have cycles to help land the Build fix on #12511, that's the most useful place to put them.
   
   <!-- streview-comment:1476 -->


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5987011304

   @Vivek1106-04 thanks, that answers bug 2 for me.
   
   The classification you describe is the behavior I was after: a draining savepoint that gets cut short by `cleanPendingCheckpoint` has not created its checkpoint yet, so collapsing every close reason (`CHECKPOINT_COORDINATOR_RESET`, `PIPELINE_END`, `CHECKPOINT_COORDINATOR_COMPLETED`, and the `handleCoordinatorError` path) to `CHECKPOINT_COORDINATOR_SHUTDOWN` keeps it inside the `JobMaster.isSavepointStartPreconditionException` contract and matches what `dev` returned when its drain loop saw `shutdown`. Keeping the "checkpoint created, then aborted" case as a real failure with the abort reason propagated unchanged through the `PendingCheckpoint` is also the right split. Parameterizing `testCoordinatorResetDuringSavepointDrainFailsTheRequestAndResumesTriggering` over all four reasons as of `a691fb195` is exactly the pin I wanted on that, so nothing further is needed on the classification itself.
   
   That leaves the one open item from the earlier review: the Build failure on #12511. You mention the branch is rebased onto current `dev` and CI is running on the new head; once it finishes, please post the outcome here. If anything is still red, either fix it or document concrete evidence that it is unrelated to this change. Please also confirm that both red-to-green regressions (the drain-gate test Rangsh ported and checked red/green in https://github.com/apache/seatunnel/pull/12511#issuecomment-5977952591, and `testSavePointFailureDuringPipelineRestoreWaitEndsTheJob`) still pass on the rebased head.
   
   Until that is in, this issue stays open and the fix should not be treated as present in `dev`.
   
   <!-- streview-comment:1519 -->


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5882272417

   @Vivek1106-04 thanks for recording these. You're right that neither the agreed constraints nor my PR as posted covers them, and I'll treat both as in scope for the PR rather than as separate follow-ups, since moving the drain off the lock is exactly what exposes them.
   
   **1. SubPlan restore race (`DOING_SAVEPOINT`)**
   Agreed on the analysis: once `cleanPendingCheckpoint` is no longer delayed by the lock-held drain, `forceStopPipeline()` landing during the `pipelineRestoreIntervalSeconds` wait finds only reset tasks and stops nothing, so the restart proceeds and the job never leaves `DOING_SAVEPOINT`. Your fix shape — re-check `jobMaster.isNeedRestore()` after the restore wait and return the pipeline to the terminal state it failed with, keeping its error — is what I'd want in my PR too. I'll add that re-check in `SubPlan` and bring in `SavePointTest#testSavePointFailureDuringPipelineRestoreWaitEndsTheJob` as the regression, confirming it is red on `c3f06f9a82c119e427df0fb1f440bae583148f62` and that `SavePointTest#testSavePointButJobGoingToFail` stays green in the full run.
   
   **2. Failure reason when the drain is cut short**
   Also agreed that constraint 2 is underspecified here. My PR currently fails the shared future with the close reason passed to `cleanPendingCheckpoint` (`CHECKPOINT_COORDINATOR_RESET`, `PIPELINE_END`, `CHECKPOINT_COORDINATOR_COMPLETED`, or the `handleCoordinatorError` reason), which, as you point out, `JobMaster.isSavepointStartPreconditionException` won't classify as never-started/retryable, since it only recognizes `CHECKPOINT_COORDINATOR_SHUTDOWN` and `TASK_NOT_ALL_READY_WHEN_SAVEPOINT`. Could you share the remedy you settled on — which reason the shared future is failed with on each of the interrupt / shutdown / completed / create-failure paths, and whether you widened `isSavepointStartPreconditionException` or mapped the close reasons on the coordinator side? I'd like to match your choice so the two changes don't diverge.
   
   If your fix is already in a branch or PR, a link would help so I can either rebase on it or fold your two fixes in with attribution — whichever you prefer. I'd rather not have two competing changes for the same drain.
   
   Once I have that, I'll update the PR, redo the red → green table for the new `SavePointTest` case on the same red base, and reply on https://github.com/apache/seatunnel/pull/12493#issuecomment-5862502658.
   
   <!-- streview-comment:1383 -->


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "Rangsh (via GitHub)" <gi...@apache.org>.
Rangsh commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5883958578

   @Vivek1106-04 @DanielLeens @SEZ9
   
   Closing #12493 in favor of #12511.
   
   Vivek's PR already carries the unlocked drain (part 1), the coordinator-side `CHECKPOINT_COORDINATOR_SHUTDOWN` mapping for a cut-short drain, and the SubPlan restore re-check that keeps `SavePointTest` honest. Continuing a second PR for the same drain would only diverge from the remedy SEZ9 asked to match.
   
   I will review #12511 instead. Part 2 (cross-pipeline) still waits on #12165 as agreed; this issue stays open until that lands.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "Rangsh (via GitHub)" <gi...@apache.org>.
Rangsh commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5977954527

   @SEZ9 Thank you for the review and for confirming both points. Understood, and I won't reopen a parallel PR.
   
   From reading #12511, DanielLeens's review there asks for the failed jobs to be re-run once the requested changes are pushed, and its one blocker is a test that pins the drain gate. To help with that, I've ported the matching test from #12493 onto the branch and checked it red without the gate and green with it: https://github.com/apache/seatunnel/pull/12511#issuecomment-5977952591
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5794530592

   Classification: A / Zeta savepoint/checkpoint concurrency.
   
   The proposed direction is sound. Current `dev` confirms the root condition: `startSavepoint()` sleeps while holding the coordinator lock, while `tryTriggerPendingCheckpoint()` must acquire that same lock before it can observe the pending-checkpoint state or schedule its next attempt. `createPendingCheckpoint(...)` currently has only the `tryTriggerPendingCheckpoint` and `startSavepoint` call paths, so this is the right boundary to preserve the existing drain exclusion without keeping the lock across the sleep.
   
   Please keep the implementation in one focused PR with these constraints:
   
   1. Install one shared savepoint-draining request/future and its gate atomically while holding the lock; concurrent `startSavepoint()` calls must receive that same future throughout the drain, not race before `savepointPendingCheckpoint` exists.
   2. Perform the drain wait outside the lock. Every interrupt, shutdown, completed-coordinator, and create failure path must clear the gate under the lock and complete that shared future exceptionally, so ordinary triggering cannot remain suppressed.
   3. While the gate is set, all non-savepoint calls through `tryTriggerPendingCheckpoint()` must follow the existing pending-checkpoint behavior: do not create a new pending checkpoint and re-arm rather than drop the trigger. Cover general, completed-point, and schema-change checkpoint types; this is needed to preserve today's lock-exclusion semantics.
   4. Add deterministic tests for the unlocked drain, no new non-savepoint pending checkpoint during the drain, concurrent savepoint coalescing, interrupt/shutdown cleanup, and successful resumption of ordinary periodic triggering after the gate is cleared.
   
   Please keep #12442's unexpected-trigger-failure policy separate from this concurrency change. No assignment or label change is needed.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5862165474

   @Rangsh thanks, this is what I asked for. The part 1 table covers the three things I wanted recorded: the test (`CheckpointCoordinatorTest#testTryTriggerNotBlockedBySavepointDrain`), the red base (`c3f06f9a82c119e427df0fb1f440bae583148f62` on `dev`), and the failure mode. Owning the drain lifetime through `pendingCounter` instead of wall-clock sleeps is the right way to keep it deterministic.
   
   Two small asks on the red run before I review https://github.com/apache/seatunnel/pull/12493:
   
   1. Please make sure the same table (test, base revision, failure) is in the PR description itself, not only here, so the red run travels with the change.
   2. For the "Red" row, please paste the actual observed failure from running the test against `c3f06f9a82c119e427df0fb1f440bae583148f62` (the assertion or timeout output), rather than the summary "blocked for the full drain". Along with that, state the bound the green side asserts on for `tryTriggerPendingCheckpoint` returning, so it is clear it is well below the drain time.
   
   Part 2 ordering is as agreed: it stays pending on #12165, I will write the cross-pipeline regression once that is in, and this issue remains open until part 2 has gone red then green. Keeping #12442's trigger-failure policy out of this change is also correct.
   
   I will go through the PR once the description is updated.
   
   <!-- streview-comment:1362 -->


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "Rangsh (via GitHub)" <gi...@apache.org>.
Rangsh commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5777568815

   Hi, I would like to take this issue.
   I will investigate the savepoint path holding the coordinator lock across its sleep-poll and blocking concurrent checkpoint triggers, and work on the fix.
   Please assign this issue to me, thanks.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "Vivek1106-04 (via GitHub)" <gi...@apache.org>.
Vivek1106-04 commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5806797054

   @Rangsh thanks for taking this. The direction and @DanielLeens's four constraints look right to me. One requirement was settled on the STIP thread (#12339, [SEZ9](https://github.com/apache/seatunnel/issues/12339) and DanielLeens) after your plan was posted. It moves a regression test out of #12165 and into this issue, so I am recording it here as agreed.
   
   **The regression is required for this fix, and it must be written red first.** Your plan says full occupancy of the shared dispatch pool is not a merge gate. It does not have to be reproduced as an incident. But the regression below is how this issue closes, and it must fail against the current blocking lock acquisition before the fix makes it pass.
   
   What it has to show:
   
   1. **Same coordinator (works on `dev` today).** Hold `pendingCounter > 0`, start `startSavepoint()`, then call `tryTriggerPendingCheckpoint` on the same coordinator. Before the fix it blocks for the full drain. That is the red run. After the fix it returns within a bound far below the drain time, creates no pending checkpoint, and re-arms. This is your test 1 plus the gate check from test 2. The only extra requirement is to run it against current `dev` first and show it fails.
   2. **Cross-pipeline (needs the shared scheduler from #12165).** Fill dispatch capacity with coordinators that are in a savepoint drain. Assert that an unrelated pipeline still gets its periodic trigger and its timeout watchdog on time. Before the fix, the contended coordinators hold every dispatch thread, so the unrelated pipeline starves. That is the red run. After the fix it is served.
   
   Part 2 has an ordering dependency. The shared dispatch pool only exists with #12165, so part 2 can only go red on a base that contains it:
   
   - If #12165 merges first, both parts land in this PR.
   - If this fix is ready first, it can land with part 1. Part 2 is then added as soon as #12165 is in, and I will write it myself. Either way, this issue stays open until part 2 has been shown red then green.
   
   Please put the red run in the PR description for each part: which test, which base revision, and the failure you saw.
   
   Everything else in DanielLeens's constraints stands unchanged. That includes keeping #12442's trigger-failure policy out of this change.
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] startSavepoint holds the coordinator lock across its sleep-poll, blocking concurrent checkpoint triggers [seatunnel]

Posted by "Rangsh (via GitHub)" <gi...@apache.org>.
Rangsh commented on issue #12441:
URL: https://github.com/apache/seatunnel/issues/12441#issuecomment-5944740848

   ## Independent verification (SEZ9 ask on #12441)
   
   Re-ran the two checks you asked for against this PR. Summary below.
   
   ### 1. Part-1 carry-over: `CheckpointCoordinatorTest#testTryTriggerNotBlockedBySavepointDrain`
   
   |#12511 renamed the equivalent coverage to `testTriggerDuringSavepointDrainReturnsAndRearmsWithoutCreatingACheckpoint`; I also re-applied the original `#12493` method name onto this tip so the exact test SEZ9 named can be re-run.|
   
   | | |
   |---|---|
   | **Test** | `CheckpointCoordinatorTest#testTryTriggerNotBlockedBySavepointDrain` |
   | **Red base** | `c3f06f9a82c119e427df0fb1f440bae583148f62` (unfixed coordinator + the `#12493` test) |
   | **Red failure** | `AssertionFailedError: tryTriggerPendingCheckpoint must return while savepoint drain is still held (pendingCounter>0); blocked for the full drain indicates the lock is held across sleep-poll ==> expected: <true> but was: <false>` |
   | **Green tip** | `#12511` @ `91001c42caeb25ae1a44cc3b7eeeab1c57201cfb` |
   | **Green** | `Tests run: 1, Failures: 0, Errors: 0` |
   
   Part-1 proof carries over from `#12493` to `#12511`.
   
   ### 2. SubPlan restore race (4 s / 5 s vs 3 s)
   
   **Timing check (source):**
   - failing sink: `InMemorySinkWriter.prepareCommit` → `Thread.sleep(4000L)` then throw (`throw_exception`)
   - slow sink: `Thread.sleep(5000L)` (`checkpoint_sleep`)
   - restore wait: `EnvCommonOptions.JOB_RETRY_INTERVAL_SECONDS` default **3**
   
   That matches the conf/test contract: stop from the 4 s failure must land inside the failed pipeline’s 3 s restore wait, while the other pipeline is still finishing its 5 s savepoint work.
   
   | Scenario | Revision / tree | `testSavePointFailureDuringPipelineRestoreWaitEndsTheJob` | Observed |
   |---|---|---|---|
   | unlocked drain **without** `isNeedRestore()` re-check | `#12511` drain commit on `146a1b5c5` (no SubPlan re-check) | **RED** | `expected: <FAILED> but was: <DOING_SAVEPOINT>` (60s timeout). Timeline: savepoint → pipeline-1 fails ~**+4 s** → restart after ~**+3 s** restore wait → job stuck in `DOING_SAVEPOINT` |
   | current `dev` (test cherry-picked, no SubPlan fix) | `4c874e2a4061aea9d5db65e74edeb211b498fe27` | **RED** | same: `expected: <FAILED> but was: <DOING_SAVEPOINT>`; fail ~+4 s, restore restart ~+3 s |
   | `#12511` full (unlocked drain **+** re-check) | `91001c42caeb25ae1a44cc3b7eeeab1c57201cfb` | **GREEN** | after the 3 s wait: `no longer needs restore, ending it as FAILED instead of restarting it` → job leaves `DOING_SAVEPOINT` → `FAILED` |
   
   **`SavePointTest#testSavePointButJobGoingToFail`:**
   - **GREEN** on `#12511` full (`91001c42c`) together with the restore-wait test (`Tests run: 2, Failures: 0`).
   - On unlocked drain **without** the re-check, two isolated runs of this single test still passed. The race is reliably exposed by `testSavePointFailureDuringPipelineRestoreWaitEndsTheJob` (the 4 s / 5 s / 3 s case), which is the one that stayed red without the re-check and went green with it.
   
   Happy to dig further if you want more `testSavePointButJobGoingToFail` retries under a full `SavePointTest` class run.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org