You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "Rangsh (via GitHub)" <gi...@apache.org> on 2026/09/27 07:17:36 UTC

[I] [Improve][Zeta] Detect and recover when WAL disruptor worker dies on Error [seatunnel]

Rangsh opened a new issue, #12492:
URL: https://github.com/apache/seatunnel/issues/12492

   ### Related
   
   Follow-up from review of https://github.com/apache/seatunnel/pull/12081 (residual gap agreed out of scope for that PR).
   
   cc @DanielLeens @SEZ9
   
   ### Describe the bug / gap
   
   In `WALWorkHandler` (`imap-storage-file`), the sole Disruptor consumer currently catches `Exception` around `writer.write(...)` and around `executeResponse(...)`:
   
   - `catch (Exception e)` does **not** catch `Error` (e.g. `OutOfMemoryError`).
   - If an `Error` escapes `writer.write()` (or otherwise kills the worker), the Disruptor consumer thread dies.
   - Nothing currently detects that the worker is dead, so it is not restarted.
   - After that point, in-flight / subsequent APPEND waiters still resolve via their **timed** `RequestFuture.get(timeout, unit)` path (they ride out `writDataTimeoutMilliseconds` / the shared batch deadline), but the worker itself stays dead and further APPENDs cannot succeed until process restart.
   
   `WALWorkHandlerSurvivabilityTest` already covers the `Exception` / fail-close path (non-`IOException` from `write()`, and `hsync()` failure). It does **not** cover this `Error` / dead-worker detection + recovery gap.
   
   ### Expected behavior
   
   When the WAL worker dies because of an `Error` (or equivalent uncaught throwable that kills the sole consumer):
   
   1. The failure is detected (not silent forever).
   2. Callers are not left depending only on wait timeouts with no indication that the writer pipeline is permanently down.
   3. Ideally the worker can be restarted safely, or the storage / node fails loudly in a controlled way rather than silently fail-closing forever.
   
   ### Proposed direction (for discussion)
   
   Separate from #12081. Possible approaches to evaluate in a follow-up PR:
   
   - Widen the handler boundary carefully for `Error` / `Throwable` where safe (without swallowing fatal JVM errors incorrectly), **and/or**
   - Add Disruptor exception handler / supervisor that detects consumer death and surfaces a clear failure / triggers recovery.
   - Add a regression test that proves an injected `Error` does not leave the pipeline silently dead forever.
   
   ### Scope note
   
   Do **not** block merge of #12081 on this. That PR already addresses the `Exception` survivability + fail-close + timed wait contract; this issue tracks only the residual `Error` / dead-worker gap called out by @SEZ9 and @DanielLeens.
   
   ### Environment
   
   - Module: `seatunnel-engine-storage/imap-storage-plugins/imap-storage-file`
   - Class: `org.apache.seatunnel.engine.imap.storage.file.disruptor.WALWorkHandler`
   - Head discussed in review: `7f69d7f69` on PR #12081


-- 
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] [Improve][Zeta] Detect and recover when WAL disruptor worker dies on Error [seatunnel]

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

   ## Claim + proposed approach
   
   Hi @SEZ9 @DanielLeens — I'll take this follow-up and open a separate PR after we align on the approach below (keeping it out of #12081 as agreed).
   
   I re-traced the current #12081 head (`7f69d7f69`) against LMAX Disruptor `3.4.4` (the version this module depends on). Summary of what I think is actually broken, and the fix I propose.
   
   ### What already works (from #12081)
   
   - `WALWorkHandler` APPEND path uses sticky fail-close (`appendBlockedAfterWriteFailure`) on `catch (Exception)`.
   - Subsequent APPENDs get `done(false)` without touching the stream.
   - `IMapFileStorage.isAppendPermanentlyBlocked()` → `FileMapStore` surfaces a clear `IMapStorageException` ("permanently fail-closed… restart required").
   - Production callers only use timed `RequestFuture.get(timeout, unit)` / shared batch deadline — no unbounded hang on the hot path.
   - Untimed `get()` already documents “prefer timed / Future-contract only” — so I do **not** plan a Javadoc-only commit unless you still want wording tweaks.
   
   ### Residual gap (this issue)
   
   `catch (Exception)` does **not** cover `Error`. If `writer.write(...)` (or `executeResponse(...)`) throws an `Error`:
   
   1. `executeResponse(...)` may never run → that request rides out only via timed wait.
   2. `appendBlockedAfterWriteFailure` is **not** set → callers do **not** get the explicit permanently-blocked signal from `FileMapStore`.
   3. The sole Disruptor consumer can still die. With `handleEventsWithWorkerPool`, `WorkProcessor` catches `Throwable` and delegates to the default `FatalExceptionHandler`, which **re-throws** (`RuntimeException` wrap). That escape exits the processor loop and leaves the sole worker dead.
   4. After that, further APPENDs sit unanswered until timeout / process restart — the silent dead-worker mode called out here.
   
   So this is not “callers hang forever” (timed waits still fire); it is “pipeline dies without the fail-close / loud-failure contract that #12081 already established for `Exception`”.
   
   ### Proposed fix (PR scope)
   
   Prefer aligning `Error` with the existing **fail-close + loud surface** design over in-process worker restart / writer reopen (those remain unsafe for the torn mid-file reasons already settled in #12081 F4).
   
   1. **`WALWorkHandler` APPEND write boundary**  
      Widen the write-path catch from `Exception` to `Throwable`. On any failure (including `Error`):
      - set `appendBlockedAfterWriteFailure = true`
      - always call `executeResponse(requestId, false)`
      - **do not rethrow** on the APPEND path (same survivability shape as today’s `Exception` handling) so the sole consumer stays alive in fail-closed mode and subsequent APPENDs complete immediately with `false`
   
   2. **`executeResponse` guard**  
      Widen its catch the same way (`Throwable`), so a late/missing future or an `Error` from `done(...)` cannot take down the sole worker either (closes the F2 residual you called out).
   
   3. **Defense-in-depth on `WALDisruptor`**  
      Install a custom Disruptor `ExceptionHandler` via `setDefaultExceptionHandler(...)` instead of relying on `FatalExceptionHandler`:
      - log at ERROR with sequence / event context
      - trip the same sticky fail-close on the `WALWorkHandler` instance when possible
      - **do not rethrow** (rethrow is what turns an already-handled escape into a dead sole worker today)
      - CLOSED / shutdown path can stay best-effort; the important contract is steady-state APPEND
   
   4. **No in-process writer reopen / worker restart in this PR**  
      Keep “restart the engine node” as the recovery story, matching the existing fail-close Javadoc and `FileMapStore` messaging. Blind `fs.create` reopen of fixed `wal.txt` stays out of scope.
   
   5. **Regression test**  
      Extend `WALWorkHandlerSurvivabilityTest` (or add a sibling) to inject an `Error` from `write(...)` and assert:
      - `onEvent` returns normally (worker not killed by the handler boundary)
      - failing future completes `false`
      - sticky fail-close trips
      - a subsequent APPEND completes `false` without a second `write(...)`
      - optionally a small `WALDisruptor`-level test that an escaping throwable does not leave the pipeline depending only on wait timeouts
   
   ### Explicit non-goals for the first PR
   
   - Swallowing fatal JVM state without fail-close / logging (we still log; we convert it into the existing permanent-block contract rather than a silent dead consumer).
   - Auto-restarting the Disruptor worker or reopening the WAL writer in-process.
   - Any change to #12081’s timed-wait / shared batch-deadline / Exception fail-close behavior beyond Error coverage.
   
   ### Ask
   
   Does this direction look right to you before I start coding?
   
   In particular:
   - OK to treat APPEND-path `Error` like `Exception` (fail-close + complete future + keep consumer alive), rather than letting `FatalExceptionHandler` kill the sole worker?
   - OK to leave in-process restart as a later discussion / non-goal?
   
   Happy to adjust based on your preference, then I’ll open the follow-up PR against the post-#12081 baseline and link it here.


-- 
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] [Improve][Zeta] Detect and recover when WAL disruptor worker dies on Error [seatunnel]

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

   Thanks @SEZ9 — agreed, I'll treat the points you confirmed as the locked v1 contract and will not start implementation until #12081 is merged and this follow-up is rebased on it.
   
   Pinning the two pre-PR points:
   
   1. **Single owner.** The `WALWorkHandler` catch path is the sole owner of the fail-close trip and best-effort `done(false)` for the affected request. The custom Disruptor `ExceptionHandler` is a log + idempotent backstop only: if fail-close is already tripped or the future is already completed, it must not `done(...)` again or race the sticky flag.
   2. **Queued APPENDs do not touch the writer.** Once fail-close is tripped, best-effort completion of already-queued APPENDs only completes their futures. It must not re-enter `write(...)` or any other writer state.
   
   I'll open the PR against the rebased baseline after #12081 lands, include the safe synthetic `Error` regression, and reference this contract in the description.


-- 
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] [Improve][Zeta] Detect and recover when WAL disruptor worker dies on Error [seatunnel]

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

   Thanks @Rangsh — the recorded contract matches the agreed direction, and the gate stands: no implementation on this follow-up until #12081 is merged and this work is rebased on it.
   
   Confirming the points as the locked v1 scope:
   
   - Fatal VM / thread / linkage errors (and any non-enumerated `Error`): best-effort `done(false)` on the affected request, trip the sticky permanent fail-close, then rethrow. No in-process consumer resume, no writer reopen.
   - Already-queued APPENDs: best-effort completed with failure, not left to wait timeouts.
   - Later APPENDs: observe permanent fail-close immediately without calling `write(...)`.
   - `Exception` handling from #12081 stays unchanged.
   - Regression uses a safe synthetic `Error` only, never a real OOM.
   
   Two things to pin down before the PR so there's no ambiguity at review time:
   
   1. **Single owner for the fail-close trip.** State explicitly whether the trip + best-effort completion happens in the handler's own catch path or in the custom Disruptor `ExceptionHandler`, and make sure it is idempotent so a fatal error that passes through both does not double-complete a future or race the sticky flag.
   2. **Queued-APPEND completion must not touch the writer.** The best-effort failure completion for already-queued events should only complete their futures — confirm it cannot re-enter `write(...)` or any writer state once fail-close is tripped.
   
   Once #12081 lands, please open the PR against the rebased baseline with the regression test included and reference this contract in the description.
   
   <!-- streview-comment:1600 -->


-- 
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] [Improve][Zeta] Detect and recover when WAL disruptor worker dies on Error [seatunnel]

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

   Thanks @DanielLeens — appreciated, and fully understood.
   
   I'll keep the revised failure-class design as the agreed direction only (not an implementation go-ahead), and I will not start this dependent PR until #12081 is green, merged, and this follow-up is rebased on that baseline. Separately, #12081 is now synced to latest `dev` with a fresh Build in flight.
   
   Recording the before-coding contract here:
   
   - **Already-queued APPENDs:** best-effort complete with failure (`done(false)` / permanent-block); do not leave them timeout-only.
   - **Later APPENDs:** observe sticky permanent fail-close immediately, without calling `write(...)`.
   - **Rethrow boundary (v1):** after best-effort completion + fail-close, rethrow `VirtualMachineError` (incl. `OutOfMemoryError`), `ThreadDeath`, `LinkageError`, and any other non-enumerated `Error`. No `Error` is recoverable in v1; do not silently resume the consumer or reopen the writer.
   - **Regression:** safe synthetic `Error` only — never a real OOM test.
   
   Happy to tighten this further if helpful; otherwise I'll wait on the #12081 gate before coding.


-- 
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] [Improve][Zeta] Detect and recover when WAL disruptor worker dies on Error [seatunnel]

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

   Classification: A / Zeta WAL failure containment.
   
   Thanks for tracing the residual path. I checked current dev and the proposed baseline before accepting a direction: #12081 is still open, BLOCKED, and has a failed Build, so its Exception fail-close and timed-wait behavior is not yet a merged dev contract. Please do not start a dependent implementation until that PR is green, merged, and the follow-up is rebased on it.
   
   The goal here is valid, but I cannot approve a blanket Exception-to-Throwable change that keeps processing after VirtualMachineError, ThreadDeath, or LinkageError. In particular, continuing a consumer after OutOfMemoryError can make file and process state unsafe. A revised design should instead state the behavior by failure class: fatal VM errors must fail the WAL path loudly and keep it permanently unavailable (with best-effort completion of the affected request) before propagating to the controlled node-failure path; do not silently resume the worker or reopen the writer in process. Any Error made recoverable must be explicitly enumerated and justified.
   
   Before a PR, please also define the exact Disruptor exception-handler contract: how it records the permanent failure, what already-queued and later APPENDs observe, and which failures it must rethrow. The regression should inject a safe synthetic Error and prove that callers receive the permanent-failure result rather than only timing out; it must not use a real heap-exhaustion test. Keep worker restart, writer reopen, and changes to #12081 out of scope.
   
   No assignment or label 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] [Improve][Zeta] Detect and recover when WAL disruptor worker dies on Error [seatunnel]

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

   Classification: A / Zeta WAL failure containment.
   
   The revised design withdraws the unsafe blanket Throwable catch and now draws the required boundary: fatal VM, thread, and linkage failures must first make the WAL path permanently unavailable and best-effort complete the affected request, then propagate to controlled node failure. No Error is approved as recoverable in v1, and a Disruptor handler must not turn such a failure into a silently resumed consumer.
   
   That is the right design direction, but it is not an implementation approval. #12081 remains open, BLOCKED, and Build-failed, so its Exception fail-close behavior is not a merged dev baseline. Do not start this dependent PR until that gate is green, merged, and rebased. Before coding, record the exact queued-versus-later APPEND contract and the rethrow boundary; use a safe synthetic Error regression, never a real OOM test.
   
   No label or assignment 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] [Improve][Zeta] Detect and recover when WAL disruptor worker dies on Error [seatunnel]

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

   ## Revised direction (after @DanielLeens feedback)
   
   Thanks @DanielLeens — agreed on the dependency and on rejecting a blanket `Exception` → `Throwable` change.
   
   ### Gate
   
   I will **not** start implementation until #12081 is green, merged, and this follow-up is rebased on that baseline. The revised design below is for alignment only.
   
   ### Failure-class behavior (APPEND write / response path)
   
   | Class | Examples | Behavior |
   | --- | --- | --- |
   | **Fatal VM / linkage** | `VirtualMachineError` (incl. `OutOfMemoryError`), `ThreadDeath`, `LinkageError` | Best-effort complete the affected request (`done(false)` if possible); trip sticky permanent fail-close so later APPENDs observe permanent failure immediately; **rethrow** so the failure propagates to the controlled node-failure path. **Do not** silently resume the sole consumer or reopen the writer in-process. |
   | **Other `Error`** | only if explicitly enumerated | Default: treat like fatal (permanent fail-close + rethrow). Any recoverable `Error` must be listed and justified before we catch-and-continue. |
   | **`Exception`** | current #12081 contract | Unchanged: sticky fail-close, complete future, keep consumer alive in fail-closed mode (no change to #12081). |
   
   So the previous “widen everything to `Throwable` and never rethrow” proposal is withdrawn for fatal errors.
   
   ### Disruptor exception-handler contract (to define before PR)
   
   Install a custom `ExceptionHandler` (not `FatalExceptionHandler` alone) with this contract:
   
   1. **Permanent failure recording** — on fatal escape / handler entry for WAL APPEND, trip the same sticky fail-close flag used by #12081 (`appendBlockedAfterWriteFailure` / equivalent), so `IMapFileStorage` / `FileMapStore` can surface the existing permanent-failure path.
   2. **Already-queued APPENDs** — best-effort complete with failure (`false` / permanent-block signal); do not leave them dependent only on wait timeouts.
   3. **Later APPENDs** — observe permanent fail-close immediately (same loud surface as Exception fail-close), without writing.
   4. **What must be rethrown** — fatal VM / linkage errors (table above) must be rethrown after best-effort completion + fail-close trip, so we do not silently keep processing in a corrupted JVM state.
   5. **Out of scope** — no in-process worker restart, no writer reopen, no changes to #12081’s Exception / timed-wait behavior.
   
   ### Regression test
   
   Extend `WALWorkHandlerSurvivabilityTest` (or sibling) with a **safe synthetic `Error`** injected from `write(...)` (not real heap exhaustion):
   
   - affected future completes with failure / permanent-block signal (not timeout-only)
   - sticky fail-close trips
   - subsequent APPEND observes permanent failure without a second `write(...)`
   - fatal path does **not** silently leave the pipeline depending only on timed waits
   
   ### Ask
   
   Does this failure-class + Disruptor contract look right before coding (post-#12081 merge)?
   
   In particular:
   1. OK that fatal `Error`s fail-close loudly + rethrow to node-failure, rather than keeping the consumer alive?
   2. OK that recoverable `Error`s stay empty for v1 unless we explicitly enumerate any?
   
   Happy to adjust wording / split the handler contract further if you want it tighter.


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