Skip to content

[Test][E2E] Bound Flink E2E jobs and capture JVM thread dumps when one hangs - #12446

Merged
davidzollo merged 6 commits into
apache:devfrom
DanielLeens:fix-flink-e2e-job-hang-thread-dump
Nov 22, 2026
Merged

davidzollo merged 6 commits into
apache:devfrom
DanielLeens:fix-flink-e2e-job-hang-thread-dump

Conversation

@DanielLeens

Copy link
Copy Markdown
Contributor

Purpose of this pull request

kudu-connector-it is being cancelled by its 90-minute timeout-minutes on PRs that do not touch Kudu (eight PRs updated in the last two days: #12394, #12137, #11727, #11077, #11545, ... on both JDK legs) and on dev push run 35625308814 (JDK 11), while its green runs take about 30 minutes. This is a hang, not growth, and this PR makes the next occurrence diagnosable instead of silent. It does not fix the hang.

What the logs show

Both cancellations I inspected hang in KuduIT.testKuduWholeDatabaseRead, on different Flink versions (dev on Flink 1.18.0, #12394 on Flink 1.15.3, where it was the very first job on a freshly started container):

  1. The client submits kudu_to_assert_with_all_tables.conf; the JobManager logs Starting split enumerator, switched from state CREATED to RUNNING, Deploying Source: Kudu-Source ... and then logs nothing else for the job.
  2. The TaskManager receives the task, starts BlobClient Downloading ... from jobmanager/172.18.0.5:6124, and ten seconds later logs Slot offering to JobManager did not finish in time. Retrying the slot offering. The BLOB download later fails with GET operation failed: Read timed out.
  3. Two minutes after submission the ResourceManager (same JVM as the JobMaster) logs The heartbeat of JobManager with id ... timed out and the TaskManager fails the task with Disconnect from JobManager responsible for ....
  4. For the remaining ~80 minutes the TaskManager loops Could not resolve JobManager address pekko.tcp://flink@jobmanager:6123/user/rpc/jobmanager_N, the ResourceManager loops Missing resources: Job ... numberOfRequiredSlots=1, and the SeaTunnel client inside the JobManager container waits forever, until the workflow cancels the job and the containers are destroyed.

So the JobMaster RPC endpoint and the BlobServer both stop responding right after the first deployment, while the ResourceManager in the same JVM keeps running. Nothing SeaTunnel runs on the JobMaster main thread: FlinkSourceEnumerator.start()/addReader() (and through them KuduSourceSplitEnumerator.open()/run(), which create the Kudu client and build scan tokens) execute on Flink's SourceCoordinator thread. Which thread is actually stuck can only be answered by a thread dump of the JobManager JVM, and none exists because the cancellation happens first.

Change (test infrastructure only)

AbstractTestFlinkContainer#executeJob(String, List<String>):

  • runs the job submission on a daemon thread and waits at most 30 minutes for it;
  • on timeout, sends SIGQUIT to every JVM in the JobManager and TaskManager containers (found through /proc, since the Flink images ship neither pgrep nor jstack/jcmd), waits five seconds so HotSpot can print the dumps to the containers' stdout, which testcontainers already forwards into the test log, and then fails the test with a message pointing at them;
  • rethrows IOException/InterruptedException/RuntimeException from the submission unchanged, so every existing caller sees the same exceptions as before.

executeJob(String) delegates to this method, so both Flink entry points are covered; savepointJob, cancelJob and restoreJob are untouched. Green jobs are unaffected: no Flink E2E job legitimately runs anywhere near 30 minutes (the longest whole IT class in jdbc-connectors-it-part-1 is 25 minutes across all containers). A hung Kudu job now fails after 30 minutes with thread dumps instead of being cancelled after 90 minutes with nothing.

Files

  • seatunnel-e2e/seatunnel-e2e-common/src/test/java/org/apache/seatunnel/e2e/common/container/flink/AbstractTestFlinkContainer.java

How was this patch tested?

Test-infrastructure-only change; verified by this PR's GitHub CI (the Flink E2E jobs exercise the new path on every green job). Local checks were limited to ./mvnw spotless:apply -pl seatunnel-e2e/seatunnel-e2e-common. The timeout branch itself is only exercised by a real hang; the next kudu-connector-it cancellation on dev will show whether the dumps land in the log.

🤖 Generated with Claude Code

…e hangs

kudu-connector-it is cancelled at its 90 minute timeout-minutes on eight PRs
updated in the last two days and on dev run 35625308814, while its green runs
take about 30 minutes. In both inspected cancellations (dev, Flink 1.18.0, and
apache#12394, Flink 1.15.3) KuduIT.testKuduWholeDatabaseRead submits its job, the
JobManager logs "Deploying Source: Kudu-Source" and then goes silent: the
TaskManager's slot offer to the JobMaster gets no reply, its BLOB download from
the JobManager times out, and two minutes later both the ResourceManager and
the TaskManager report "The heartbeat of JobManager ... timed out". The
TaskManager then retries "Could not resolve JobManager address" for the rest
of the budget and the SeaTunnel client waits forever.

Nothing in the SeaTunnel enumerator path runs on the JobMaster main thread, so
the logs cannot say which thread is stuck; only a thread dump of the
JobManager JVM can, and the workflow-level cancellation destroys the
containers before anyone can take one.

Bound a single job submitted through AbstractTestFlinkContainer#executeJob to
30 minutes. On timeout, send SIGQUIT to every JVM in the JobManager and
TaskManager containers so HotSpot prints their thread dumps to the container
stdout that testcontainers already forwards into the test log, then fail the
test with a message pointing at them. Green jobs are unaffected: no Flink E2E
job legitimately runs anywhere near 30 minutes. JVMs are located through
/proc because the Flink images do not ship pgrep, jstack or jcmd.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions github-actions Bot added the e2e label Sep 22, 2026

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I went through the full diff and traced the call chain end to end. The approach is sound and, since this is test infrastructure I authored myself, I've held it to the same bar I'd apply to anyone else's PR. Found a couple of non-blocking follow-ups below, plus a CI note — no source-side blockers.

What Problem Does This PR Solve?

  • User pain point: kudu-connector-it has been getting force-cancelled at its 90-minute timeout-minutes on PRs that don't even touch Kudu, while its green runs take about 30 minutes. That's a hang, not organic growth. Worse, because the workflow kills the containers on cancellation, every occurrence leaves zero diagnostic evidence behind — we can't tell which thread is actually stuck.
  • Fix approach: bound a single job submitted through AbstractTestFlinkContainer#executeJob to 30 minutes. On timeout, before anything is torn down, send SIGQUIT to every JVM in the JobManager and TaskManager containers (found via /proc since the Flink images ship neither pgrep nor jstack/jcmd) so HotSpot prints thread dumps to the containers' stdout, which testcontainers already forwards into the test log, then fail with a message pointing at them.
  • One-sentence summary: this doesn't fix the hang itself, it turns an unexplained 90-minute cancellation into a 30-minute failure with real evidence attached, which is exactly what's needed to root-cause the actual issue next time it happens.

1. Code Change Review

1.1 Core Logic Analysis

Changes: entirely contained in AbstractTestFlinkContainer.executeJob(String, List<String>), plus a new private dumpJvmThreads(String, GenericContainer<?>) helper and a JOB_TIMEOUT_MINUTES = 30 constant. executeJob(String) is untouched and still delegates to the two-arg overload, so both public entry points are covered.

Before:

public Container.ExecResult executeJob(String confFile, List<String> variables) {
    log.info("test in container: {}", identifier());
    return executeJob(jobManager, confFile, null, variables);
}

After (summarized):

public Container.ExecResult executeJob(String confFile, List<String> variables) {
    ExecutorService executor = Executors.newSingleThreadExecutor(/* daemon thread */);
    Future<Container.ExecResult> result =
            executor.submit(() -> executeJob(jobManager, confFile, null, variables));
    try {
        return result.get(30, TimeUnit.MINUTES);
    } catch (TimeoutException e) {
        dumpJvmThreads("jobmanager", jobManager);
        dumpJvmThreads("taskmanager", taskManager);
        result.cancel(true);
        throw new IllegalStateException(/* points at the dumps */, e);
    } catch (ExecutionException e) {
        // unwraps IOException / InterruptedException / RuntimeException, rethrown unchanged
    } finally {
        executor.shutdownNow();
    }
}

Key findings:

  1. The green path is unaffected — every currently-passing Flink E2E job finishes well inside 30 minutes, and the extra thread hop is negligible overhead.
  2. The only genuinely new behavior is the timeout branch, which is a boundary path that (by construction) only a real hang can exercise — the PR description is upfront about this ("only the next cancellation will show whether the dumps land").
  3. This is precise, narrow diagnostic instrumentation — it's not dressed up as a fix for the actual hang, and it doesn't try to be one.
  4. I verified (not just trusted) that every Flink E2E test reaches this new code: no subclass of AbstractTestFlinkContainer (Flink13Container through Flink20Container) overrides executeJob, and there are no direct calls to the inner executeJob(GenericContainer, ...) overload anywhere in the Flink E2E tests that would bypass the new timeout. KuduIT and everything else on these containers goes through the same path.

Runtime path:

KuduIT.testKuduWholeDatabaseRead()
  -> container.executeJob(confFile)                       // unchanged entry point
      -> AbstractTestFlinkContainer.executeJob(String)     // unchanged, delegates
          -> executeJob(String, List)                      // <-- new 30-min bound here
              -> submitted to a single daemon-thread executor
              -> Future.get(30, MINUTES)
                  - green path: returns normally, executor.shutdownNow() reaps the finished worker
                  - hang path: TimeoutException -> dump JobManager + TaskManager threads
                               -> result.cancel(true) -> throw IllegalStateException

I also checked whether 30 minutes is a safe budget: I couldn't find any legitimately long-running single Flink executeJob call anywhere near that duration in the current test suite (the closest waits are unrelated container startup timeouts and post-job Awaitility assertions capped at 3-5 minutes), so this shouldn't produce new false-positive timeouts on green runs.

1.2 Compatibility Impact

Fully compatible. Both public method signatures (executeJob(String), executeJob(String, List<String>)) are unchanged, and every exception type callers could previously observe (IOException, InterruptedException, unchecked RuntimeException) still propagates exactly as before via the ExecutionException unwrap. The new IllegalStateException on timeout is a new possible exception, but only on a path that was already effectively a test failure (a 90-minute hang followed by a workflow cancellation), so no currently-passing scenario can regress. This is test-infrastructure-only — no production code, config option, protocol, or serialization format is touched.

1.3 Performance / Side-Effect Analysis

One extra daemon thread per executeJob call, cleaned up via executor.shutdownNow() in a finally block — negligible CPU/memory impact. The one real side-effect concern is concurrency-related and is written up as Issue 1 below: cancellation on timeout is best-effort only.

1.4 Error Handling and Logging

dumpJvmThreads catches broad exceptions and logs at WARN with the container role and cause, which is the right call here — a failure to capture diagnostics must never mask the actual timeout or become the primary failure. No sensitive data is logged (the shell snippet only inspects /proc/[0-9]*/comm). The thrown IllegalStateException message is specific and points the reader at the dumps in the log above it.

Issue 1 — Best-effort cancellation can leave a worker thread running against shared, reused containers (Medium)

  • Location: AbstractTestFlinkContainer.java, the TimeoutException branch and finally block inside executeJob(String, List<String>).
  • result.cancel(true) / executor.shutdownNow() only send Thread.interrupt(). The worker thread is blocked inside a docker exec socket read (via testcontainers/docker-java), which is not guaranteed to unblock on interrupt. On a genuine hang, that worker can keep issuing docker exec calls against the JobManager/TaskManager containers after this method has already thrown.
  • Since TestSuiteBase uses @TestInstance(Lifecycle.PER_CLASS) and containers are started once in @BeforeAll, a test class's containers are shared across every @Test method in the class — so a leaked worker thread from a timed-out job in one test can still be talking to the same containers while the next test method runs.
  • This only triggers on an already-rare hang and is strictly better than today's behavior (a 90-minute full-run cancellation with zero evidence), so it's not a blocker. Worth tightening later, e.g. by tracking the underlying exec session so it can be forcibly torn down rather than only interrupt-requested.
  • Raised by another reviewer: No.

Issue 2 — Fixed 5-second wait for the thread dump may be too short under exactly the conditions this targets (Low)

  • Location: dumpJvmThreads (the sleep 5 inside the container shell command, after kill -QUIT).
  • If the JVM itself is starved — plausible given this is meant for exactly that kind of hang — 5 seconds may not always be enough for HotSpot to flush the full dump to stdout before the output is captured.
  • Non-blocking: this only affects how complete the diagnostic text is, never test pass/fail. A short poll/retry instead of a fixed sleep would be a nice future refinement.
  • Raised by another reviewer: No.

2. Code Quality Assessment

2.1 Coding Standards

Follows the existing style of the file; the new constant and helper method both have explanatory comments describing purpose and constraints. No wildcard imports, no unnecessary complexity.

2.2 Test Coverage and Test Stability

This PR changes E2E test infrastructure, so per our mandatory stability analysis:

  • Assertion-risk analysis: no assertion in this diff depends on timing. The only fixed wait is the diagnostic sleep 5 noted in Issue 2, which doesn't gate any pass/fail assertion.
  • Flaky-test anti-patterns: checked for hard sleeps gating assertions (none), unreleased resources (the ExecutorService is always shut down in finally; the one gap is the in-flight worker thread on the timeout path, covered by Issue 1), shared static state (none introduced), order-sensitivity (none), and hard-coded ports/hosts (none introduced).
  • Stability rating: Stable. Nothing here makes a currently-passing Flink E2E test intermittently fail. The Issue 1 gap only matters after a genuine hang, which today already ends the whole CI run anyway — this PR only makes that existing failure mode diagnosable and 60 minutes faster, it doesn't add a new source of flakiness on green runs.

2.3 Documentation Updates

Test-infrastructure-only change with no user-visible behavior. No docs/en or docs/zh update is required.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise, narrow diagnostic instrumentation. It's explicitly not positioned as a fix for the underlying hang, and I agree with that framing — the root cause (something makes the JobMaster RPC/BlobServer stop responding right after the first task deployment) is still open.

3.2 Maintainability

Clear and well-contained: one method, one new helper, one new constant, with comments explaining the reasoning (why 30 minutes, why /proc, why SIGQUIT). Future readers hitting a kudu-connector-it timeout will have an actual thread dump to start from instead of a cold trail.

3.3 Extensibility

The pattern (bound + capture diagnostics before teardown) is reusable for any other container-based E2E suite that hits a similar "cancelled with zero evidence" problem, though it isn't extracted into a shared utility here — reasonable for a first, targeted application.

3.4 Historical-Version Compatibility

Fully compatible; nothing about this change affects historical behavior, upgrades, or persisted state, since it's test-only.

4. Issue Summary

# Issue Location Severity
1 Best-effort cancellation can leak a worker thread that keeps talking to shared, reused containers AbstractTestFlinkContainer.java (executeJob timeout branch) Medium
2 Fixed 5-second wait for thread dump may be too short under JVM-starvation conditions AbstractTestFlinkContainer.java (dumpJvmThreads) Low

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers — must be fixed

    • None in the source diff. The only current obstacle is CI: the apache-side Build check is red, but every failing job I traced (unit-test (8, windows-latest) — a Maven Central dependency-resolution hiccup fetching org.testcontainers:pulsar; engine-v2-it (11, ubuntu-latest) — an unrelated CheckpointCoordinatorFailoverIT assertion in the Zeta checkpoint coordinator; paimon-connector-it (8 and 11, ubuntu-latest) — a known Paimon connector-e2e hang pattern) is unrelated to this one-file diff. Notably, kudu-connector-it itself passed cleanly on this run. I'd suggest retriggering those four jobs rather than changing any code here.
  2. Recommended fixes — non-blocking

    • Issue 1 (Medium): worth tightening so a timed-out job's background thread can be forcibly torn down instead of only interrupt-requested, since the test class's containers are reused across test methods. Doesn't block merge because it only matters on an already-rare failure path and is strictly better than the current 90-minute blind cancellation.
    • Issue 2 (Low): consider replacing the fixed 5-second wait with a short poll for a more robust dump capture. Purely a diagnostic-quality nicety.

Overall assessment: this is a well-scoped, test-infrastructure-only change that turns a silent, expensive CI hang into a fast, evidence-carrying failure, without touching any production code or changing any existing test's behavior on the green path. I don't see a materially different implementation approach that would do better here — the SIGQUIT-via-/proc trick is a reasonable way to get thread dumps out of an image that ships none of the usual tooling. Happy to approve as soon as CI is green on the unrelated jobs above.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the current head 3cd6450a3ee2ccfba9a9b1423dccc853a4ada2e1 (my previous review was on ff99c37a99). The head moved only by a merge of apache/dev; I re-read the full PR diff against dev and it is still the single file AbstractTestFlinkContainer.java (81 additions, 1 deletion), unchanged in substance from the head I reviewed before.

What Problem Does This PR Solve?

  • User pain point: kudu-connector-it hangs are cancelled at the 90-minute workflow timeout with no evidence left behind.
  • Fix approach: bound each Flink E2E job submission (executeJob(String, List<String>)) to 30 minutes and, on timeout, send SIGQUIT to all JVMs in the JobManager and TaskManager containers before failing, so thread dumps land in the test log.
  • Summary: diagnostics only, it does not fix the hang.

1. Code Change Review

1.1 Core Logic Analysis

Runtime path (unchanged): XxxIT -> container.executeJob(conf) -> executeJob(conf, variables) which now runs the submission on a daemon single-thread executor and waits Future.get(30, MINUTES). Green path returns the same ExecResult and rethrows IOException / InterruptedException / RuntimeException unchanged (AbstractTestFlinkContainer.java ExecutionException unwrap). Only the timeout branch is new. No Flink container subclass overrides executeJob, so every Flink E2E reaches it.

1.2 Compatibility Impact

Fully compatible. Test infrastructure only; public signatures and exception types are unchanged.

1.3 Performance / Side-Effect Analysis

One extra daemon thread per job submission, shut down in finally. Nothing in production modules is touched.

1.4 Error Handling and Logging

Diagnostic capture is best effort and logged at WARN, so it cannot mask the timeout failure.

2. Code Quality Assessment

Coding standards: fine, new constant and helper are documented. Stability rating: Stable (no timing-gated assertions; the only fixed wait is the diagnostic sleep 5). Docs: none needed.

3. Architectural Soundness

Precise, narrow diagnostic change. Historical compatibility: not applicable.

4. Issue Summary

# Issue Location Severity
1 Best-effort cancellation (cancel(true) / shutdownNow()) can leave the worker thread blocked in a docker exec read against containers shared across test methods; carryover from my previous review, unchanged AbstractTestFlinkContainer.java timeout branch / finally Medium
2 Fixed 5-second wait for the dump may be short on a starved JVM; carryover, unchanged AbstractTestFlinkContainer.java dumpJvmThreads Low

5. Merge Recommendation

Conclusion: Ready to merge after CI

  1. Blockers: none in the source diff.
  2. Non-blocking: Issue 1 and Issue 2 above, same as last round.

CI note: the apache-side Build check is a pointer to the fork run (https://github.com/DanielLeens/seatunnel/actions/runs/38349664831). On this head it ended with three failed jobs, none in code this PR touches: all-connectors-it-6 (17) failed in DatabendCDCSinkIT.testDatabendSinkCDC (an Awaitility ConditionTimeout), and all-connectors-it-2 (11) and (17) failed in CassandraIT.testCassandra / testCassandraMultiTableSource on the Flink 1.20.1 container, where the Cassandra driver reports AllNodesFailedException ... NodeUnavailableException (the Flink task could not reach the Cassandra container). These tests do not hang and fail within seconds, so the 30-minute bound is not involved. The next step is to rerun only the failed jobs. The branch is behind dev by 15 commits (queue metadata only); please sync with the latest dev if the same lanes fail again. This analysis is from reading the code and CI logs; I did not run anything locally.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this Daniel-authored PR as a maintainer, including the full one-file diff, shared execute path, container log forwarding and teardown. The direction is useful, but the timeout path itself still needs a host-side bound before it can deliver the stated protection reliably. All findings from this review are included below.

What Problem Does This PR Solve?

  • User pain point: a hung Flink E2E consumes the workflow timeout, leaving little useful JVM evidence.
  • Fix approach: execute the job in a daemon executor, wait at most 30 minutes, request JVM SIGQUIT dumps from both containers, then fail the test and shut down the executor.
  • One-sentence summary: fail a stalled E2E earlier while preserving diagnostic thread dumps.

Example: a job that never exits should yield an explicit timeout and both JVM dumps around the configured test deadline, so later tests and cleanup can proceed.

1. Code Change Review

1.1 Core Logic Analysis

The only changed file is seatunnel-e2e/seatunnel-e2e-common/src/test/java/org/apache/seatunnel/e2e/common/container/flink/AbstractTestFlinkContainer.java.

// before
return executeJob(jobManager, confFile, null, variables);
// after (:220-235)
Future<Container.ExecResult> result = executor.submit(
    () -> executeJob(jobManager, confFile, null, variables));
try { return result.get(JOB_TIMEOUT_MINUTES, TimeUnit.MINUTES); }
catch (TimeoutException e) {
    dumpJvmThreads("jobmanager", jobManager);
    dumpJvmThreads("taskmanager", taskManager);
    result.cancel(true);
    throw new IllegalStateException(..., e);
}

Complete affected execution chain:

Flink test template -> executeJob(confFile[, variables]) (:203-218)
 -> daemon single-thread executor (:221-228)
 -> AbstractTestContainer.executeJob (:286-319)
    copy config/connectors -> construct existing CLI -> executeCommand
 -> container.execInContainer (AbstractTestContainer:438)
caller waits on Future (30 minutes)
 -> success: return identical ExecResult
 -> execution failure: unwrap IO/interruption/runtime cause
 -> timeout: synchronous JobManager dump, synchronous TaskManager dump
    -> execInContainer bash /proc java scan + SIGQUIT + 5-second collection delay
    -> cancel job future -> throw
 -> finally executor.shutdownNow
JUnit teardown -> stopContainersAndDeleteVolume(taskManager, jobManager) (:168-173)

Key findings:

  • The normal shared Flink submission path reaches the new wrapper; overload resolution inside the lambda selects the inherited four-argument method, so it does not recurse.
  • JVM stdout is already forwarded through Slf4jLogConsumer on both containers (:111-113,133-136), making SIGQUIT a useful diagnostic even without jstack.
  • The fixed five-second delay is diagnostic collection, not an assertion that a job completed.
  • The worker thread is daemon and the executor is always shut down, but neither fact bounds the caller's synchronous diagnostic calls. The outer method can still hang after its advertised deadline (Issue 1).
  • This changes shared E2E infrastructure, not production Source/Transform/Sink, checkpoint formats or runtime cancellation guarantees.

1.2 Compatibility Impact

Partially incompatible for the test harness only: jobs exceeding 30 minutes now fail locally in the harness instead of waiting for the workflow budget. Production public APIs, user configuration/defaults, wire protocol and serialized state do not change. The checked-in constant has no user migration requirement. Container teardown remains responsible for the remote process lifetime; interrupting a host future should not be presented as proof of remote job cancellation.

1.3 Performance / Side Effects

One executor/thread and Future per job; normal work still executes once. On timeout the code requests all Java process dumps in each container and adds at least two five-second collection delays; log volume is proportional to JVM thread count. No production hot path, connector retry or data idempotency changes. Existing teardown stops the remote containers after an exception, provided the timeout handler returns.

1.4 Error Handling and Logging

IO/runtime causes are preserved; other throwables are wrapped. Dump exceptions are logged and do not intentionally replace the timeout. Diagnostic messages identify the container role/config/engine. No new credential logging is added, though JVM dumps may contain the ordinary test diagnostics already emitted by those processes.

Issue 1: Timeout diagnostics have no host-side deadline

  • Location: AbstractTestFlinkContainer.java:233-235,274-286.
  • Description: after Future.get times out, the JUnit caller synchronously invokes execInContainer for each dump before cancelling the job Future or reaching finally. There is no timeout around either diagnostic call. If the Docker exec/transport stalls rather than throwing (the explicit failure assumption here), the caller never reaches the advertised timeout exception or teardown; even the second dump is never attempted.
  • Risk: the same full-workflow hang that this patch is meant to prevent remains possible on its failure path. This is a static liveness gap, not a claim that the supplied CI observed a diagnostic hang.
  • Best improvement: use a small, host-enforced total diagnostic budget with daemon diagnostic tasks, bounded waits and finally cancellation; attempt both roles within that budget and always propagate the original job timeout. A timeout command inside the container alone cannot bound a stalled host transport. Retain container teardown as the remote process cleanup boundary.
  • Severity: Medium, blocking for the promised bounded-time behavior.
  • Already raised by others: No; there are no non-author reviews/inline comments at the snapshot.

Issue 2: The new failure/diagnostic paths have no deterministic regression coverage

  • Location: AbstractTestFlinkContainer.java:217-290.
  • Description: existing connector E2Es exercise successful submission and some connector failures, but do not force the 30-minute timeout, a stuck/throwing dump call, or the exception-unwrapping branches. There is no test that would catch Issue 1 without consuming a workflow budget.
  • Risk: future edits can silently remove the deadline or mask the original failure across every Flink E2E suite.
  • Best improvement: introduce a narrow test seam for a short duration and command/dump callbacks, then cover successful return, IO/runtime/interruption delivery, timed-out command, throwing dump and non-returning dump under a small bounded test budget. Assert completion and cleanup, using latches/futures rather than fixed sleeps or a real 30-minute Docker job.
  • Severity: Medium, blocking coverage for this shared harness failure path.
  • Already raised by others: No.

2. Code Quality Assessment

2.1 Coding Standards

Existing-class change with descriptive Javadoc on the timeout and diagnostic helper; imports are explicit and no new dependency is added. git diff --check passed. The scope is focused.

2.2 Test Coverage and Test Stability

Stability rating: Risk present. The patch introduces no timing-sensitive result assertion, but its bounded-wait objective is incomplete on the diagnostic path and lacks direct failure-path coverage (Issues 1/2). The five-second diagnostic sleep is not a substitute for a task-ready/data assertion. Existing test outcomes must remain unchanged on success and preserve their original failure cause.

Current Build has failed all-connectors-part-2 on both JDKs and part-6 on JDK 17. The inspected Cassandra log has direct-buffer OOM / no available connection on Flink 1.20; merged #12756 fixes that memory budget in current dev. The Databend CDC log has zero rows instead of three within its three-minute condition wait; merged #12848 (2bc9d0eab71) fixes the final CDC merge in current dev. This branch is 82 commits behind and contains neither correction, so sync latest dev and rerun those failed jobs first. These specific failures are not evidence that the new 30-minute diagnostic branch works, and CI green would not clear Issues 1/2 without their changes.

2.3 Documentation Updates

User EN/ZH product docs and incompatibility notes are not needed for this test-only helper. The Javadoc should describe the final total deadline accurately after Issue 1 is fixed.

3. Architectural Soundness

3.1 Elegance

Precise direction at the right layer, incomplete failure containment. The shared Flink test wrapper owns the test budget and diagnostics. Keep the minimal fix here with bounded diagnostic execution; changing production job cancellation/connector timeouts would spread unrelated risk. A broader common-harness timeout utility can be a later extraction once its cleanup contract is proven.

3.2 Maintainability

The normal path is readable. Make the job deadline, diagnostic budget and remote cleanup ownership distinct so later maintainers do not mistake Future cancellation for a whole-container deadline.

3.3 Extensibility

Other engines could reuse a proven helper later; no need to widen this patch now.

3.4 Historical-Version Compatibility

Only the E2E execution budget changes. No task/checkpoint or job configuration migration is required.

4. Issue Summary

Number Issue Location Severity
1 Diagnostic exec can block beyond the job deadline AbstractTestFlinkContainer.java:233-235,274-286 Medium, blocking
2 Missing deterministic timeout/diagnostic regression coverage AbstractTestFlinkContainer.java:217-290 Medium, blocking

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers (must fix): Issues 1 and 2 together. Separately, incorporate merged upstream fixes #12756/#12848 and obtain a successful required Build. These are independent source/test and upstream CI gates.
  2. Recommended fixes (non-blocking): none beyond keeping the final timeout Javadoc precise.

Overall assessment: a useful shared diagnostic improvement once the failure path itself is bounded and covered. There is no existing maintainer approval/change request at the snapshot to override. Alternatives: A) a bounded daemon-task diagnostic helper here is the smallest safe fix; B) a common test-container deadline abstraction would help more engines but has a larger regression surface. Prefer A for this focused PR. Daniel is the author; this COMMENT review is not independent approval. Final review/approval needs a write-capable maintainer.

Local source-analysis evidence: fetched and checked out independent seatunnel-review-12446 at 3cd6450a3ee2ccfba9a9b1423dccc853a4ada2e1; complete git diff origin/dev...HEAD read; numbered source/rg traces above; git diff --check passed. No local compile, unit/IT/E2E, Docker, service or functional execution was performed. Current compare: dev diverged, ahead 4, behind 82; mergeable state blocked, no content conflict.

Inspected CI log: Run / all-connectors-it-2 (11, ubuntu-latest).

Inspected CI log: Run / all-connectors-it-6 (17, ubuntu-latest).

Successful unit lane: Run / unit-test (11, ubuntu-latest).

DanielLeens and others added 2 commits October 30, 2026 21:56
…r the timeout path

Each SIGQUIT request is itself a docker exec, so a stalled Docker transport
could block executeJob past the 30-minute job deadline and recreate the
silent workflow-level cancellation the deadline exists to prevent. Each
request now runs on a daemon thread and is abandoned after 60 seconds on
the host side; a stalled or failing request can no longer delay the second
dump or the timeout failure.

The job and dump deadlines are exposed as package-private getters so
AbstractTestFlinkContainerTest can drive the timeout path with mocked
containers: a hanging job plus a stalled and a failing dump request must
still fail with the timeout within the test budget, a finishing job must
return its result untouched, and a submission failure must be rethrown as
the same instance.
@DanielLeens

Copy link
Copy Markdown
Contributor Author

Addressed both blocking items from the 2026-10-22 review and synced with dev. New head: d8f644bf6e7b5fc6b89da821a76f9cf9bbec0fd0 (commit d8f644b on top of merge fb853fb of origin/dev 3ac2d1cec6a, which brings in #12756 and #12848; the merge had no conflicts).

Issue 1 - timeout diagnostics have no host-side deadline (AbstractTestFlinkContainer.java)

  • Each thread dump request now runs on its own daemon thread and is waited for at most THREAD_DUMP_TIMEOUT_SECONDS = 60 s on the host (AbstractTestFlinkContainer.java:225 constant with the rationale, :302-332 dumpJvmThreads). A request that misses the deadline is logged and abandoned, dump.cancel(true) + shutdownNow() run in finally (:329-330), and the next role is still attempted (:251-252), so a stalled Docker exec can no longer block past the job deadline or hide the second dump. Timeouts and dump failures are only logged; the original IllegalStateException for the job timeout is always thrown. Worst-case host-side bound is therefore 30 min + 2 x 60 s. Container teardown remains the cleanup boundary for the remote processes; the Javadoc says so explicitly.
  • The daemon-executor construction is shared by the job wait and the dump requests via newDaemonExecutor (:338).

Issue 2 - no deterministic coverage of the timeout/diagnostic path (AbstractTestFlinkContainerTest.java)

  • The job and dump deadlines are exposed as package-private getters getJobTimeout() / getThreadDumpTimeout() (AbstractTestFlinkContainer.java:285-295); production values are unchanged (30 min / 60 s), the existing TestFlinkContainer in the test overrides them to 200 ms and stubs the submission (AbstractTestFlinkContainerTest.java:243-288).
  • shouldFailAfterJobDeadlineAndBoundEachThreadDumpRequest (:144): job never returns, JobManager dump request blocks forever, TaskManager dump request throws. Asserts under a 10 s preemptive budget that executeJob throws IllegalStateException caused by TimeoutException, and that both containers received the kill -QUIT exec. It fails if the job deadline is removed, if the stalled dump is not bounded on the host (the call would exceed the budget), if the second dump is skipped after the first stalled, or if the dump failure replaces the timeout exception.
  • shouldReturnJobResultWithoutThreadDumpsWhenJobFinishesInTime (:188): same ExecResult instance is returned and no dump exec is issued.
  • shouldRethrowJobFailureUnchanged (:208): an IOException from the submission is rethrown as the same instance (guards the ExecutionException unwrapping), no dump exec is issued.

Local checks were limited to ./mvnw spotless:apply / spotless:check on seatunnel-e2e/seatunnel-e2e-common (both clean); compile and tests are left to CI per the validation policy. Fork Build run for the new head: https://github.com/DanielLeens/seatunnel/actions/runs/41162470372 (queued at the time of writing).

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The revised timeout path resolves my two earlier blocking requests: diagnostic exec now has a host-side deadline, and direct mock-based coverage exercises stalled/throwing diagnostics, successful return and original IOException delivery. I traced the shared submission and teardown paths again. The remaining timing-test concern is non-blocking.

What Problem Does This PR Solve?

User pain point: A hung Flink E2E can consume the workflow budget without useful JVM evidence; an unbounded diagnostic request could itself keep the timeout handler stuck.

Fix approach: Run job submission on a daemon executor with a 30-minute wait, then independently bound each container dump request to 60 seconds and propagate the original job timeout.

One-sentence summary and example: If the job and JobManager diagnostic both stall while the TaskManager diagnostic throws, the caller still receives its job TimeoutException cause after bounded diagnostic waits.

1. Code Change Review

1.1 Core Logic Analysis

The public executeJob overload delegates through a Future to the inherited four-argument submission method. That method still copies config/connectors, builds the launcher command and invokes execInContainer. On job timeout, dumpJvmThreads creates a separate daemon task for each container and bounds Future.get; finally cancels the dump and shuts down its executor. The job executor is always shut down. Existing tearDown stops both containers and deletes the volume even if one stop fails.

Before:

dumpJvmThreads("jobmanager", jobManager); // previously synchronous unbounded Docker exec

After:

Future<Container.ExecResult> dump = executor.submit(() -> container.execInContainer(...));
try { dump.get(getThreadDumpTimeout().toMillis(), TimeUnit.MILLISECONDS); }
finally { dump.cancel(true); executor.shutdownNow(); }

Key Findings

  • Normal shared Flink E2E submissions reach this wrapper; the inherited overload prevents recursion.
  • Success returns the same ExecResult; IO/interruption/runtime causes are unwrapped.
  • Each diagnostic wait is bounded independently, so a stalled first exec does not consume an unbounded host wait or skip the second role.
  • Normal configured wait budget is 30 minutes plus up to two 60-second diagnostic waits, excluding scheduling/logging overhead.
  • Future interruption does not prove remote Docker exec termination. Container teardown remains the resource boundary.
  • New method and timeout-field Javadoc explain the ownership/deadline contract.

Complete runtime path

Flink E2E -> public executeJob -> daemon task
 -> inherited executeJob(container,conf,id,variables) -> config/jars/CLI -> Docker exec
caller Future.get -> success or original failure
 -> timeout: bounded JobManager dump -> bounded TaskManager dump -> cancel job Future
 -> throw original timeout cause -> finally shutdown executor
JUnit teardown -> stop both containers and clean volume

The previously unbounded synchronous diagnostic path is removed. The test forces the job and first diagnostic to wait on a latch, makes the second diagnostic throw, and checks both requests plus the original timeout cause. This is a harness liveness improvement, not a production job-cancellation or remote-process termination guarantee.

1.2 Compatibility Impact

Partially incompatible for the test harness only. Shared Flink E2E jobs now fail when their submission exceeds the fixed 30-minute budget. Production defaults, APIs, plugin identities, checkpoints and user configuration do not change; no user migration is required.

1.3 Performance / Side-Effect Analysis

One executor per submitted job, plus two short-lived diagnostic executors only on timeout. SIGQUIT dumps add bounded wait and thread-count-dependent log volume. Daemon threads cannot pin JVM exit but uninterruptible transport work can survive until teardown.

1.4 Error Handling and Logging

The original timeout remains the cause when diagnostics stall or throw. Interrupted diagnostic waits restore the caller interrupt flag. Existing IO/runtime propagation is retained. The comment claiming interruption prevents an exec from surviving should remain understood as best effort; shutdownNow cannot force transport termination.

Issue 1: Allow scheduling headroom in the new timeout tests

  • Location: AbstractTestFlinkContainerTest.java:144-222,280-287
  • Problem description: The same 200 ms timeout is used for successful submission and diagnostic workers. On a heavily loaded runner a worker can miss that scheduling window, causing a nominal success to time out or a diagnostic Future to be cancelled before the mocked exec is reached. The outer 10-second assertion does not enlarge these inner deadlines.
  • Potential risk: A correct implementation can fail these tests under runner contention; this is a scheduling risk inferred from the deadlines, not an observed failure in the queued run.
  • Best improvement: Use generous deadlines for success/exception tests and coordinate worker entry before timing the deliberately blocked path, or provide a narrow controllable scheduling seam. Keep a generous whole-test bound.
  • Severity: Medium; non-blocking.
  • Raised by another reviewer: No

2. Code Quality Assessment

2.1 Coding Standards

The timeout constants, dump command, getters and daemon helper have explanatory comments. The changes stay in the shared Flink E2E harness and its existing unit-test class, with no new dependency or production seam.

2.2 Test Coverage and Test Stability

Test stability: Risk present. The failure path uses latch-controlled blocking rather than sleep, and validates both dumps and preserved timeout identity. Success and IOException paths are also checked. Issue 1 records the short scheduling windows. The already-existing teardown tests cover stop/volume failure handling. No test was run locally, and the current-head Build is queued.

Local analysis: fetched the head, created independent branch seatunnel-review-12446, read the complete 2-file diff and traced affected callers with git show/git grep. No local compilation, unit tests, integration tests, E2E, containers, or job execution was performed, as requested. These are source-analysis conclusions; execution evidence is the current-head CI below.

2.3 Documentation Updates

Test-only behavior needs no EN/ZH user migration guide. The Javadoc correctly separates host deadlines from container teardown; describe interruption as a best-effort request rather than guaranteed remote cleanup.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix at the owning harness boundary. Bound the diagnostic calls where the shared Flink test deadline is owned. A cross-engine timeout framework would expand the change unnecessarily.

3.2 Maintainability

Keep job timeout, diagnostic deadline and remote cleanup ownership separate. Improve test scheduling headroom without weakening the timeout assertions.

3.3 Extensibility

Other engines can adopt the approach later after their lifecycle contracts are examined; no need to generalize this PR.

3.4 Historical-Version Compatibility

No released configuration, serialized state or rolling-upgrade contract changes.

4. Issue Summary

Number Issue Location Severity
1 Allow scheduling headroom in the new timeout tests AbstractTestFlinkContainerTest.java:144-222,280-287 Medium

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers — must be fixed
    • No source blocker identified. Obtain successful current-head Build and independent write-capable maintainer approval. No source blocker remains.
  2. Recommended fixes — non-blocking
    • Issue 1: Allow scheduling headroom in the new timeout tests

Overall assessment: The prior source/coverage blockers are resolved. The non-blocking timing concern and pending CI remain visible.

Existing-review reconciliation: No independent technical findings or maintainer APPROVED/CHANGES_REQUESTED entry appears in the retrieved reviews and inline discussion. Daniel is the author, so this review is not independent approval. Author replies have been incorporated into this single full review.

Head d8f644bf6e7b5fc6b89da821a76f9cf9bbec0fd0. Live base dev at 3ac2d1cec6aa7b3741c4dacdd23020f778e23c02; comparison ahead, ahead 6 / behind 0; merge state BLOCKED. Behind/diverged alone is recorded metadata, not a request to synchronize upstream. Checks: No current-head checks reported.

No current-head upstream checks are reported. Exact-head fork Build is queued. Verified #12756 (07d6f22) and #12848 (2bc9d0e) are ancestors of this head; the old specific upstream-sync gate is fulfilled. Previous connector failures do not validate or disprove this new diagnostic branch.

Daniel has READ repository permission. This COMMENT records the technical conclusion; it is not an effective maintainer approval or a dismissal of any historical requested-changes entry. A write-capable maintainer owns the final repository approval gate.

@DanielLeens

Copy link
Copy Markdown
Contributor Author

The CI fact in my existing full review of this exact head has changed. That source review is already published; this is a gate clarification, not another full source review on the same version.

Source status: the existing review found no blocking source issue. Its non-blocking suggestions are unchanged.

The exact-head fork Build is now completed / cancelled, attempt 1. Job conclusions: success=84, cancelled=1, skipped=11. Cancelled targets include Run / connector-file-local-it (11, ubuntu-latest). The evidence does not identify why the workflow was cancelled; cancellation alone does not establish a source fix in dev. The run owner should check for a newer active attempt, then resume only the cancelled required jobs. Do not introduce unrelated source/dependency edits or assume branch synchronization repairs cancellation.

The current base comparison is recorded separately. Missing Apache check adoption is distinct from the fork conclusion, and neither is an effective independent approval. Daniel is the author and has READ repository permission.

Checked 2026-11-01T12:11:46.916415+00:00; unchanged head d8f644bf6e7b5fc6b89da821a76f9cf9bbec0fd0, base dev; compare diverged, ahead 6 / behind 9; merge blocked / BLOCKED; review decision REVIEW_REQUIRED. Behind/diverged is recorded independently and does not itself request a sync. Daniel has READ repository permission.

@DanielLeens

Copy link
Copy Markdown
Contributor Author

The CI fact cited previously has changed: exact-head fork Build 41162470372 is now successful, so the instruction to resume the cancelled connector-file-local-it JDK 11 lane is obsolete. My existing source conclusion remains clear. Apache still has no adopted current-head check, so check adoption and independent maintainer approval remain separate gates. No additional source patch or drift-only sync is requested; as author I cannot independently approve this PR.

This is an unchanged-head CI/merge clarification, not another full source review. No local runtime testing was performed. Daniel has READ permission; effective maintainer approval/dismissal remains separate.

@davidzollo davidzollo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@DanielLeens

Copy link
Copy Markdown
Contributor Author

Thanks, @davidzollo, for the independent approval. The exact-head Build remains successful, and my existing source conclusion is unchanged. As the PR author I cannot independently approve my own change. The remaining repository review/merge controls belong to a write-capable maintainer; no new code patch is requested here.

Checked unchanged head d8f644bf6e7b5fc6b89da821a76f9cf9bbec0fd0 against dev: compare diverged, ahead 6 / behind 122. This drift is recorded independently; it does not by itself request synchronization. This is a discussion/CI follow-up, not another full source review. No local build, test or runtime execution was performed. Daniel has READ repository permission; effective maintainer approval/dismissal remains a separate repository gate. Checked 2026-11-20T11:54:15.110727+00:00.

@davidzollo
davidzollo added this pull request to the merge queue Nov 22, 2026
Merged via the queue into apache:dev with commit 86bef76 Nov 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants