You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by gi...@apache.org on 2026/09/20 12:18:13 UTC
(seatunnel) 01/01: [Test][E2E] Add multi-pipeline restore slot-contention probe for Zeta (#12109)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/dev/pr-12109-5f7f5c1dbbb490436605cef37b47a5b30d5acdd1
in repository https://gitbox.apache.org/repos/asf/seatunnel.git
commit 957e014f68b28886d0144689c384d2f0b0923c5f
Author: David Zollo <da...@gmail.com>
AuthorDate: Sun Sep 20 12:17:47 2026 +0000
[Test][E2E] Add multi-pipeline restore slot-contention probe for Zeta (#12109)
Co-authored-by: Claude Sonnet 5 <no...@anthropic.com>
---
.../engine/e2e/SplitClusterFaultToleranceIT.java | 292 +++++++++++++++++++++
...fake_to_localfile_slot_contention_template.conf | 132 ++++++++++
2 files changed, 424 insertions(+)
diff --git a/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/SplitClusterFaultToleranceIT.java b/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/SplitClusterFaultToleranceIT.java
index 665bb340a1..8bb8848c08 100644
--- a/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/SplitClusterFaultToleranceIT.java
+++ b/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/SplitClusterFaultToleranceIT.java
@@ -28,6 +28,7 @@ import org.apache.seatunnel.engine.client.job.ClientJobProxy;
import org.apache.seatunnel.engine.common.config.ConfigProvider;
import org.apache.seatunnel.engine.common.config.JobConfig;
import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
+import org.apache.seatunnel.engine.common.config.server.ScheduleStrategy;
import org.apache.seatunnel.engine.common.exception.SeaTunnelEngineException;
import org.apache.seatunnel.engine.common.job.JobResult;
import org.apache.seatunnel.engine.common.job.JobStatus;
@@ -1658,4 +1659,295 @@ public class SplitClusterFaultToleranceIT {
return false;
}
}
+
+ /**
+ * Verified-fragile-architecture probe (not a fix regression test): {@link
+ * org.apache.seatunnel.engine.server.dag.physical.ResourceUtils#applyResourceForPipeline}
+ * throws {@code NoEnoughResourceException} synchronously and immediately if it cannot obtain
+ * every slot a pipeline needs in a single pass -- the method has an explicit {@code TODO}
+ * acknowledging there is no wait/backoff at that layer. {@link
+ * org.apache.seatunnel.engine.server.dag.physical.SubPlan#stateProcess()}'s {@code SCHEDULED}
+ * case turns that single exception into one consumed unit of the pipeline's fixed {@code
+ * pipelineMaxRestoreNum} (default 3, from {@code job.retry.times}) restore budget, sleeping
+ * {@code pipelineRestoreIntervalSeconds} (default 3, from {@code job.retry.interval.seconds})
+ * before every restore attempt. A pipeline that races several siblings for a
+ * momentarily-shrunken slot pool can therefore burn its entire retry budget on pure allocation
+ * timing and permanently fail, even though the contention would have resolved moments later.
+ *
+ * <p>This test engineers genuine (not lucky/racy) multi-pipeline contention rather than relying
+ * on placement luck: the job config declares 4 independent, unrelated FakeSource -> LocalFile
+ * chains, so the planner splits them into 4 separate pipelines (SubPlans), each with its own
+ * restore budget. Every simple 1-parallelism pipeline here needs exactly 3 slots (1
+ * source-enumerator coordinator + 1 sink-committer coordinator -- LocalFile's sink always
+ * registers an aggregated file-commit coordinator, independent of is_enable_transaction -- + 1
+ * fused reader/writer task group) -- 4 pipelines x 3 slots = 12 total slot demand. Both workers
+ * are pinned to a fixed pool (dynamic-slot=false) of 8 slots each: 16 total capacity
+ * comfortably admits the initial 12-slot demand (4 spare), but no single 8-slot worker can ever
+ * host all 4 pipelines (4 x 3 = 12 > 8: at most 2 full pipelines, using 6 of 8 slots, fit on
+ * one worker with only 2 spare -- not enough for a 3rd pipeline's 3 slots). So killing either
+ * worker is guaranteed, by construction rather than chance, to strand part of more than one
+ * pipeline at once and force them to restore-race the survivor's remaining fixed capacity.
+ * Every LocalFile sink also sets is_enable_transaction=true, so a canceled attempt's
+ * in-progress writes stay in an uncommitted temp location and never surface in the output
+ * directory this test counts -- without that, a stranded pipeline's aborted attempt could leak
+ * partial rows into the count and the exact-equality assertion below would be unsound
+ * regardless of the restore-budget outcome.
+ *
+ * <p>Whether today's fixed 9-second guaranteed-sleep budget (3 attempts x 3s, before any real
+ * cancel/checkpoint-cancel/resource-release/RPC overhead per attempt) is enough patience for
+ * that contention to resolve -- as the deliberately tiny, fast FakeSource pipelines finish and
+ * free their slots for whoever is still waiting -- is exactly the open question this test
+ * answers empirically: either the job finishes (today's behavior tolerates this contention
+ * level) or some pipeline permanently fails with its restore budget exhausted purely on
+ * allocation timing (the bug this item describes). Either outcome is a valid, honest finding;
+ * this test only documents production behavior and never modifies production code.
+ *
+ * <p>The assertions below accept both outcomes explicitly instead of hard-gating on {@code
+ * FINISHED} alone, so this probe cannot go red simply because the gap it exists to document
+ * actually manifested: a {@code FINISHED} job is verified by its exact row count, while a
+ * {@code FAILED} job is only accepted as the second finding once its recorded error confirms
+ * the failure is this specific {@code NoEnoughResourceException}-driven restore-budget
+ * exhaustion, not an unrelated regression. Any other terminal status, or a {@code FAILED} job
+ * whose error does not confirm that root cause, still fails the test.
+ *
+ * <p>Currently disabled, tracked by apache/seatunnel#12202. With {@code ScheduleStrategy.WAIT}
+ * set below, the job reliably reaches {@code RUNNING} and the worker kill happens as intended,
+ * but the job then never reaches a terminal state: the 5-minute post-kill wait on {@code
+ * objectCompletableFuture.isDone()} below times out with an Awaitility {@code
+ * ConditionTimeoutException}, and the client's {@code waitForJobCompleteV2()} only resolves
+ * minutes later with the job ending in {@code JobStatus.UNKNOWABLE} rather than {@code
+ * FINISHED} or {@code FAILED}, on both JDK 8 and JDK 11 (davidzollo/seatunnel CI run
+ * 34226272462, attempt 2, on head 40373e75c). That is the engine gap tracked by #12202 -- the
+ * CoordinatorService job-scheduling completion chain wedging on the
+ * pending-job-schedule-runner, which leaves the job absent from every tracking structure and
+ * therefore unknowable to the client -- surfacing inside this probe; it is not a defect of the
+ * test, and the test cannot go green until that gap is fixed. Before re-enabling, confirm
+ * #12202 is resolved on the target branch and that a run of this test then reaches one of the
+ * two accepted terminal outcomes described above within the existing budget.
+ */
+ @Test
+ @Disabled(
+ "Tracked by apache/seatunnel#12202: after the worker kill the job ends UNKNOWABLE instead of a terminal state (job-scheduling completion chain wedges); re-enable once #12202 is fixed")
+ public void testManyPipelinesRestoreContentionInWorkerDown() throws Exception {
+ String testCaseName = "testManyPipelinesRestoreContentionInWorkerDown";
+ String testClusterName =
+ "SplitClusterFaultToleranceIT_testManyPipelinesRestoreContentionInWorkerDown";
+ long testRowNumber = 5000;
+ int pipelineNum = 4;
+ // Fixed per-worker slot pool (dynamic-slot disabled below makes this a hard ceiling, not
+ // a hint). 8 < (pipelineNum * 3 slots-per-pipeline = 12), so a single worker can never
+ // host all 4 pipelines -- see the class-level Javadoc above for the full arithmetic.
+ int slotNumPerWorker = 8;
+
+ HazelcastInstanceImpl masterNode1 = null;
+ HazelcastInstanceImpl workerNode1 = null;
+ HazelcastInstanceImpl workerNode2 = null;
+ SeaTunnelClient engineClient = null;
+
+ SeaTunnelConfig seaTunnelConfig = getSeaTunnelConfig(testClusterName);
+ SeaTunnelConfig masterNode1Config = getSeaTunnelConfig(testClusterName);
+ SeaTunnelConfig workerNode1Config = getSeaTunnelConfig(testClusterName);
+ SeaTunnelConfig workerNode2Config = getSeaTunnelConfig(testClusterName);
+ for (SeaTunnelConfig workerConfig :
+ new SeaTunnelConfig[] {workerNode1Config, workerNode2Config}) {
+ workerConfig.getEngineConfig().getSlotServiceConfig().setDynamicSlot(false);
+ workerConfig.getEngineConfig().getSlotServiceConfig().setSlotNum(slotNumPerWorker);
+ }
+ // CoordinatorService binds its schedule strategy once, from the active master's own
+ // EngineConfig (see CoordinatorService#scheduleStrategy / #isWaitStrategy), so only
+ // masterNode1Config -- the only master this test starts -- needs this. The engine
+ // default is REJECT, under which a resource pre-application attempt that cannot obtain
+ // every slot a pipeline needs in one pass fails the job immediately with no retry (see
+ // CoordinatorService#pendingJobSchedule). This job's very first pre-application (12
+ // slots across both fresh workers) can transiently race the two workers still
+ // registering their slot pools with the master's ResourceManager right after cluster
+ // startup, so a partial grant here is possible under CI load. Switching to WAIT makes
+ // that first attempt retry (3s sleep + requeue, unconditionally, no attempt cap) instead
+ // of failing terminally, so the job reliably reaches RUNNING and this test can exercise
+ // its actual target scenario: post-worker-kill restore contention over the fixed 8-slot
+ // survivor pool, using the still-tight 12-of-16 slot budget described in the class-level
+ // Javadoc above. This is unrelated to, and does not fix or mask, the separate confirmed
+ // engine gap in CoordinatorService's job-scheduling epoch handling (silent job loss on
+ // scheduler-epoch changes under REJECT, see pendingJobSchedule's own Javadoc) -- that gap
+ // is tracked and handled independently of this test.
+ masterNode1Config.getEngineConfig().setScheduleStrategy(ScheduleStrategy.WAIT);
+
+ try {
+ masterNode1 = SeaTunnelServerStarter.createMasterHazelcastInstance(masterNode1Config);
+
+ workerNode1 = SeaTunnelServerStarter.createWorkerHazelcastInstance(workerNode1Config);
+
+ workerNode2 = SeaTunnelServerStarter.createWorkerHazelcastInstance(workerNode2Config);
+
+ // waiting all node added to cluster (1 master + 2 workers)
+ HazelcastInstanceImpl finalNode = masterNode1;
+ Awaitility.await()
+ .atMost(10000, TimeUnit.MILLISECONDS)
+ .untilAsserted(
+ () ->
+ Assertions.assertEquals(
+ 3, finalNode.getCluster().getMembers().size()));
+
+ log.warn(
+ "===================================All node is running==========================");
+ Common.setDeployMode(DeployMode.CLIENT);
+ ImmutablePair<String, String> testResources =
+ createManyPipelineTestResources(testCaseName, testRowNumber, pipelineNum);
+ JobConfig jobConfig = new JobConfig();
+ jobConfig.setName(testCaseName);
+
+ ClientConfig clientConfig = ConfigProvider.locateAndGetClientConfig();
+ clientConfig.setClusterName(TestUtils.getClusterName(testClusterName));
+ engineClient = new SeaTunnelClient(clientConfig);
+ ClientJobExecutionEnvironment jobExecutionEnv =
+ engineClient.createExecutionContext(
+ testResources.getRight(), jobConfig, seaTunnelConfig);
+ ClientJobProxy clientJobProxy = jobExecutionEnv.execute();
+
+ // Catch the job genuinely mid-flight (all 4 pipelines deployed and running across
+ // both workers) before killing a worker. A tight poll minimizes the race against
+ // these deliberately tiny/fast pipelines finishing on their own before we can react;
+ // JobStatus only reaches RUNNING after every pipeline's own DEPLOYING step succeeds,
+ // so by the time this is observed all 12 slots are already assigned on real workers.
+ Awaitility.await()
+ .atMost(60000, TimeUnit.MILLISECONDS)
+ .pollInterval(200, TimeUnit.MILLISECONDS)
+ .untilAsserted(
+ () ->
+ Assertions.assertEquals(
+ JobStatus.RUNNING, clientJobProxy.getJobStatus()));
+
+ CompletableFuture<JobResult> objectCompletableFuture =
+ CompletableFuture.supplyAsync(clientJobProxy::waitForJobCompleteV2);
+
+ // Kill one worker while several pipelines are running on it: every pipeline that had
+ // any slot on this worker (coordinator or task group) must release ALL of its slots,
+ // not just the lost one, and restore-race the survivor's fixed 8-slot pool.
+ log.warn(
+ "=====================================shutdown workerNode1=================================");
+ workerNode1.shutdown();
+
+ Awaitility.await()
+ .atMost(10000, TimeUnit.MILLISECONDS)
+ .untilAsserted(
+ () ->
+ Assertions.assertEquals(
+ 2, finalNode.getCluster().getMembers().size()));
+
+ // Generous terminal-state budget: pipelineMaxRestoreNum(3) *
+ // pipelineRestoreIntervalSeconds(3) = 9s of guaranteed sleep alone is the theoretical
+ // floor; real cancel/checkpoint-cancel/resource-release/RPC overhead per attempt (plus
+ // this being a shared CI runner) makes the actual wall-clock budget considerably
+ // larger, so this timeout is generous on purpose in both directions.
+ Awaitility.await()
+ .atMost(300000, TimeUnit.MILLISECONDS)
+ .pollInterval(1000, TimeUnit.MILLISECONDS)
+ .untilAsserted(() -> Assertions.assertTrue(objectCompletableFuture.isDone()));
+
+ JobResult jobResult = objectCompletableFuture.get();
+ JobStatus finalStatus = jobResult.getStatus();
+ Long fileLineNumberFromDir =
+ FileUtils.getFileLineNumberFromDir(testResources.getLeft());
+ log.warn(
+ "==================final job status: {}, output line count: {}, error: {}==================",
+ finalStatus,
+ fileLineNumberFromDir,
+ jobResult.getError());
+
+ // Both terminal outcomes documented in the class-level Javadoc above are accepted as
+ // valid findings here -- this probe is not a hard regression gate on a single required
+ // outcome, so it must not go red simply because the gap it exists to document actually
+ // manifested:
+ // 1) FINISHED: today's restore budget tolerated this contention level. Every row from
+ // every pipeline must be present, since every sink has is_enable_transaction=true,
+ // which guarantees a stranded/canceled attempt cannot have leaked partial output
+ // into this same count.
+ // 2) FAILED with a NoEnoughResourceException surfacing in the job's recorded error: the
+ // documented gap actually manifested and some pipeline burned its entire restore
+ // budget purely on ResourceUtils#applyResourceForPipeline's synchronous,
+ // backoff-free allocation racing its siblings. This is only accepted once the error
+ // confirms that exact root cause, so this probe can never silently swallow an
+ // unrelated regression (e.g. a NullPointerException elsewhere) as if it were the
+ // finding it documents.
+ // Any other terminal status, or a FAILED job whose error does not confirm the
+ // NoEnoughResourceException root cause, is not one of the two documented findings and
+ // still fails the test below.
+ if (finalStatus == JobStatus.FINISHED) {
+ log.warn(
+ "==========Finding: contention resolved within the restore budget, job FINISHED==========");
+ Assertions.assertEquals(testRowNumber * pipelineNum, fileLineNumberFromDir);
+ } else if (finalStatus == JobStatus.FAILED
+ && jobResult.getError() != null
+ && jobResult.getError().contains("NoEnoughResourceException")) {
+ log.warn(
+ "==========Finding: a pipeline permanently failed with its restore budget exhausted purely on allocation timing, as this probe documents==========");
+ } else {
+ Assertions.fail(
+ "Unexpected terminal outcome, neither documented finding occurred: status="
+ + finalStatus
+ + ", error="
+ + jobResult.getError());
+ }
+ } finally {
+ if (engineClient != null) {
+ engineClient.close();
+ }
+
+ if (masterNode1 != null) {
+ masterNode1.shutdown();
+ }
+
+ if (workerNode1 != null) {
+ workerNode1.shutdown();
+ }
+
+ if (workerNode2 != null) {
+ workerNode2.shutdown();
+ }
+ }
+ }
+
+ /**
+ * Create the test job config file based on {@code
+ * cluster_batch_fake_to_localfile_slot_contention_template.conf}, which declares {@code
+ * pipelineNum} independent (unrelated) FakeSource -> LocalFile chains so the planner splits
+ * them into that many separate pipelines/SubPlans. It deletes the test sink target path before
+ * returning the final job config file path, matching the sibling {@code createTestResources}
+ * helpers in this class.
+ *
+ * @param testCaseName testCaseName, also used as the sink output directory name
+ * @param rowNumber row.num for every FakeSource (parallelism is fixed at 1 in the template)
+ * @param pipelineNum number of independent pipelines the template declares; must match the
+ * template file's actual source/sink count since this method only substitutes values, it
+ * does not generate the template's pipeline count
+ */
+ private ImmutablePair<String, String> createManyPipelineTestResources(
+ @NonNull String testCaseName, long rowNumber, int pipelineNum) throws IOException {
+ checkArgument(rowNumber > 0, "rowNumber must greater than 0");
+ checkArgument(pipelineNum > 0, "pipelineNum must greater than 0");
+ Map<String, String> valueMap = new HashMap<>();
+ valueMap.put(DYNAMIC_TEST_CASE_NAME, testCaseName);
+ valueMap.put(DYNAMIC_TEST_ROW_NUM_PER_PARALLELISM, String.valueOf(rowNumber));
+
+ String targetDir = "/tmp/hive/warehouse/" + testCaseName;
+ targetDir = targetDir.replace("/", File.separator);
+
+ // clear target dir before test
+ FileUtils.createNewDir(targetDir);
+
+ String targetConfigFilePath =
+ File.separator
+ + "tmp"
+ + File.separator
+ + "test_conf"
+ + File.separator
+ + testCaseName
+ + ".conf";
+ TestUtils.createTestConfigFileFromTemplate(
+ "cluster_batch_fake_to_localfile_slot_contention_template.conf",
+ valueMap,
+ targetConfigFilePath);
+
+ return new ImmutablePair<>(targetDir, targetConfigFilePath);
+ }
}
diff --git a/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/resources/cluster_batch_fake_to_localfile_slot_contention_template.conf b/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/resources/cluster_batch_fake_to_localfile_slot_contention_template.conf
new file mode 100644
index 0000000000..8ca6b06772
--- /dev/null
+++ b/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/resources/cluster_batch_fake_to_localfile_slot_contention_template.conf
@@ -0,0 +1,132 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+######
+###### This config file deliberately declares 4 independent (unrelated) source->sink
+###### chains so the planner splits them into 4 separate pipelines/SubPlans, each with
+###### its own pipelineMaxRestoreNum budget. Used to engineer genuine multi-pipeline
+###### slot contention during restore against a deliberately tight, fixed slot pool.
+######
+
+env {
+ job.mode = "BATCH"
+ checkpoint.interval = 5000
+ # Pin today's actual defaults explicitly so this test's timing arithmetic (documented
+ # in the IT class) stays correct even if the framework defaults change in the future.
+ job.retry.times = 3
+ job.retry.interval.seconds = 3
+}
+
+source {
+ FakeSource {
+ plugin_output = table1
+ row.num = ${dynamic_test_row_num_per_parallelism}
+ split.num = 1
+ parallelism = 1
+ schema = {
+ fields {
+ name = "string"
+ age = "int"
+ }
+ }
+ }
+ FakeSource {
+ plugin_output = table2
+ row.num = ${dynamic_test_row_num_per_parallelism}
+ split.num = 1
+ parallelism = 1
+ schema = {
+ fields {
+ name = "string"
+ age = "int"
+ }
+ }
+ }
+ FakeSource {
+ plugin_output = table3
+ row.num = ${dynamic_test_row_num_per_parallelism}
+ split.num = 1
+ parallelism = 1
+ schema = {
+ fields {
+ name = "string"
+ age = "int"
+ }
+ }
+ }
+ FakeSource {
+ plugin_output = table4
+ row.num = ${dynamic_test_row_num_per_parallelism}
+ split.num = 1
+ parallelism = 1
+ schema = {
+ fields {
+ name = "string"
+ age = "int"
+ }
+ }
+ }
+}
+
+transform {
+}
+
+sink {
+ LocalFile {
+ plugin_input = table1
+ path = "/tmp/hive/warehouse/${dynamic_test_case_name}" # dynamic_test_case_name will be replace to the final file name before test run
+ field_delimiter = "\t"
+ row_delimiter = "\n"
+ file_name_expression = "${transactionId}_${now}"
+ file_format_type = "text"
+ filename_time_format = "yyyy.MM.dd"
+ is_enable_transaction = true
+ save_mode = "error"
+ }
+ LocalFile {
+ plugin_input = table2
+ path = "/tmp/hive/warehouse/${dynamic_test_case_name}" # dynamic_test_case_name will be replace to the final file name before test run
+ field_delimiter = "\t"
+ row_delimiter = "\n"
+ file_name_expression = "${transactionId}_${now}"
+ file_format_type = "text"
+ filename_time_format = "yyyy.MM.dd"
+ is_enable_transaction = true
+ save_mode = "error"
+ }
+ LocalFile {
+ plugin_input = table3
+ path = "/tmp/hive/warehouse/${dynamic_test_case_name}" # dynamic_test_case_name will be replace to the final file name before test run
+ field_delimiter = "\t"
+ row_delimiter = "\n"
+ file_name_expression = "${transactionId}_${now}"
+ file_format_type = "text"
+ filename_time_format = "yyyy.MM.dd"
+ is_enable_transaction = true
+ save_mode = "error"
+ }
+ LocalFile {
+ plugin_input = table4
+ path = "/tmp/hive/warehouse/${dynamic_test_case_name}" # dynamic_test_case_name will be replace to the final file name before test run
+ field_delimiter = "\t"
+ row_delimiter = "\n"
+ file_name_expression = "${transactionId}_${now}"
+ file_format_type = "text"
+ filename_time_format = "yyyy.MM.dd"
+ is_enable_transaction = true
+ save_mode = "error"
+ }
+}