DanielLeens commented on issue #13344: URL: https://github.com/apache/seatunnel/issues/13344#issuecomment-7035229194
<!-- static-slot-validation:20261120:e2597998a991:13344 --> I ran this on 2026-11-20 on the Linux validation host `bigdata03`: Ubuntu 24.04, 8 vCPU / 16 GiB, OpenJDK 21.0.13.1, `-Xms128m -Xmx256m -XX:ActiveProcessorCount=2`. The unmodified runtime was built from `dev` commit [`e2597998a991`](https://github.com/apache/seatunnel/tree/e2597998a991f30fd7c13a634cdd07c7a0a5db44) (3.1.1-SNAPSHOT). Each probe used its own loopback-only Zeta cluster and was shut down afterwards. These are current-development-snapshot results, not a released-version matrix. The normal coordinator-submitted FakeSource → Console control reached `RUNNING`, and normal cancellation returned assigned slots to zero. No product fix was applied for these probes. **Confirmed for the pending-cancellation branch, using real slot RPCs, JobMaster, and Hazelcast IMaps.** The scheduler handoff window was held deterministically by invoking the production lifecycle methods in order; this is not a randomly timed CLI cancellation. Steps (`bash run-probe.sh pending 2` with the harness below): 1. Start one fixed-slot member with `dynamic-slot=false`, `slot-num=2`. 2. Parse the supplied parallelism-1 FakeSource → Console job. Initialize its JobMaster and set its persisted job state to `PENDING`, as the coordinator does before admission. 3. Call `preApplyResources()` and stop before `JobMaster.run()`. Both slots have been granted; `preApplyResourceFutures.size()==2`, while the pipeline-owned-slot IMap is empty. 4. Call `cancelJob()`, wait 1.5 seconds, and request one slot for a different job. Observed: ```text beforeCancel jobStatus=PENDING assigned=2 preApplied=2 ownedMapSize=0 afterCancel jobStatus=CANCELED assigned=2 ownedMapSize=0 followingOneSlotRequestRejected=true ``` Expected: cancellation should return both acquired slots, allowing the next one-slot request. The stale-scheduler-epoch and restored-owner rejection variants were not exercised in this run. For reproducibility, the collapsed appendix contains the exact shared harness used for this issue and the sibling slot probes. It performs controlled boundary tests; it is not an engine patch or a master-kill acceptance suite. <details> <summary>Exact shared probe source, configuration, runner, and build steps</summary> Save the three files below into an empty validation directory. `job-large.conf`, needed only for the admission probe, is `job.conf` with `parallelism = 4` instead of `1`. Use a complete JDK 11+ and Maven (the observed run used JDK 21, targeting Java 11): ```bash git clone https://github.com/apache/seatunnel.git src git -C src checkout e2597998a991f30fd7c13a634cdd07c7a0a5db44 cd src ./mvnw -B -nsu -Dmaven.gitcommitid.skip=true -T 3C \ -pl :seatunnel-starter,:connector-console,:checkpoint-storage-local-file -am \ -DskipTests -Dmaven.test.skip=true -Dskip.ui=true \ -Dskip.spotless=true -Dcheckstyle.skip=true install cd .. mkdir -p runtime/lib runtime/connectors runtime/config probe-classes cp src/seatunnel-engine/seatunnel-engine-storage/checkpoint-storage-plugins/checkpoint-storage-local-file/target/checkpoint-storage-local-file-*.jar runtime/lib/ cp "$HOME/.m2/repository/org/apache/seatunnel/seatunnel-shade-hadoop3-uber/3.1.4-3.0.1/seatunnel-shade-hadoop3-uber-3.1.4-3.0.1.jar" runtime/lib/ cp src/seatunnel-connectors-v2/connector-fake/target/connector-fake-*.jar runtime/connectors/ cp src/seatunnel-connectors-v2/connector-console/target/connector-console-*.jar runtime/connectors/ javac -proc:none --release 11 \ -cp src/seatunnel-core/seatunnel-starter/target/seatunnel-starter.jar \ -d probe-classes StaticSlotProbe.java export PROBE_JAVA="$JAVA_HOME/bin/java" bash run-probe.sh job 4 live-control4 bash run-probe.sh pending 2 pending2 ``` The build skips ordinary tests and frontend asset compilation; the observations below come from the explicit integration probes. The optional UI artifact is in the reactor because the server depends on it; no UI acceptance is claimed. The runtime Hadoop JAR is required even for the local-file checkpoint control. `StaticSlotProbe.java` ```java /* * 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. */ import org.apache.seatunnel.common.config.Common; import org.apache.seatunnel.engine.common.utils.IdGenerator; import org.apache.seatunnel.engine.common.utils.concurrent.CompletableFuture; import org.apache.seatunnel.common.config.DeployMode; import org.apache.seatunnel.engine.core.parse.MultipleTableJobConfigParser; import org.apache.seatunnel.engine.common.config.EngineConfig; import org.apache.seatunnel.engine.common.config.SeaTunnelConfig; import org.apache.seatunnel.engine.common.config.server.AllocateStrategy; import org.apache.seatunnel.engine.common.config.server.ScheduleStrategy; import org.apache.seatunnel.engine.common.job.JobStatus; import org.apache.seatunnel.engine.server.utils.NodeEngineUtil; import org.apache.seatunnel.engine.core.dag.logical.LogicalDag; import org.apache.seatunnel.engine.core.dag.logical.LogicalDagGenerator; import org.apache.seatunnel.engine.core.job.JobImmutableInformation; import org.apache.seatunnel.api.common.JobContext; import org.apache.seatunnel.engine.common.config.JobConfig; import org.apache.seatunnel.engine.server.SeaTunnelServer; import org.apache.seatunnel.engine.server.SeaTunnelServerStarter; import org.apache.seatunnel.engine.server.dag.physical.SubPlan; import org.apache.seatunnel.engine.server.dag.physical.PhysicalVertex; import org.apache.seatunnel.engine.server.dag.physical.ResourceUtils; import org.apache.seatunnel.engine.core.job.PipelineStatus; import org.apache.seatunnel.engine.server.execution.ExecutionState; import org.apache.seatunnel.engine.server.master.JobMaster; import org.apache.seatunnel.engine.server.resourcemanager.ResourceManager; import org.apache.seatunnel.engine.server.resourcemanager.AbstractResourceManager; import org.apache.seatunnel.engine.server.resourcemanager.ResourceRequestHandler; import org.apache.seatunnel.engine.server.resourcemanager.allocation.strategy.RandomStrategy; import org.apache.seatunnel.engine.server.resourcemanager.allocation.strategy.SlotRatioStrategy; import org.apache.seatunnel.engine.server.resourcemanager.opeartion.RequestSlotOperation; import org.apache.seatunnel.engine.server.resourcemanager.opeartion.ResetResourceOperation; import org.apache.seatunnel.engine.server.resourcemanager.resource.CPU; import org.apache.seatunnel.engine.server.resourcemanager.resource.Memory; import org.apache.seatunnel.engine.server.resourcemanager.resource.ResourceProfile; import org.apache.seatunnel.engine.server.resourcemanager.resource.SlotProfile; import org.apache.seatunnel.engine.server.resourcemanager.worker.WorkerProfile; import org.apache.seatunnel.engine.server.service.slot.SlotAndWorkerProfile; import org.apache.seatunnel.engine.server.service.slot.SlotService; import com.hazelcast.config.Config; import com.hazelcast.instance.impl.HazelcastInstanceImpl; import com.hazelcast.internal.serialization.Data; import com.hazelcast.spi.impl.NodeEngine; import com.hazelcast.spi.impl.operationservice.Operation; import com.hazelcast.cluster.Address; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; /** Runs controlled integration probes on a real, isolated Zeta member; no product patches. */ public class StaticSlotProbe { private static HazelcastInstanceImpl hz; private static NodeEngine node; private static SeaTunnelServer server; private static SeaTunnelConfig config; private static ResourceManager rm; private static SlotService slots; private static final ExecutorService JOB_EXECUTOR = Executors.newFixedThreadPool(4); public static void main(String[] args) throws Exception { String scenario = args[0]; int count = Integer.parseInt(args[1]); try { boot(count, scenario.equals("strategy") ? AllocateStrategy.SLOT_RATIO : AllocateStrategy.RANDOM, scenario.equals("admission")); switch (scenario) { case "base": base(count); break; case "lost": lost(); break; case "reset": reset(); break; case "size": size(count); break; case "pending": pending(args[2]); break; case "strategy": strategy(args[2]); break; case "finished": finished(args[2]); break; case "callback": callback(); break; case "restore": restore(args[2]); break; case "blocking": blocking(); break; case "job": liveJob(args[2]); break; case "stale": stale(args[2]); break; case "reuse": reuse(args[2]); break; case "admission": admission(args[2]); break; default: throw new IllegalArgumentException(scenario); } } finally { JOB_EXECUTOR.shutdownNow(); if (hz != null) hz.shutdown(); } System.out.println("PROBE_COMPLETE " + scenario); System.exit(0); } /** Uses loopback discovery, an exclusive cluster name, and bounded thread pools. */ private static void boot(int count, AllocateStrategy strategy, boolean waitStrategy) throws Exception { config = new SeaTunnelConfig(); Config hc = config.getHazelcastConfig(); hc.setClusterName("static-slot-probe-20261120-" + UUID.randomUUID()); hc.getNetworkConfig().setPort(35481).setPortAutoIncrement(true).setPortCount(10); hc.getNetworkConfig().getInterfaces().setEnabled(true).addInterface("127.0.0.1"); hc.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false); hc.getNetworkConfig().getJoin().getAutoDetectionConfig().setEnabled(false); hc.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true).addMember("127.0.0.1:35481"); hc.setProperty("hazelcast.operation.thread.count", "2"); hc.setProperty("hazelcast.operation.generic.thread.count", "4"); hc.setProperty("hazelcast.io.input.thread.count", "2"); hc.setProperty("hazelcast.io.output.thread.count", "2"); hc.setProperty("hazelcast.logging.type", "jdk"); config.getEngineConfig().getSlotServiceConfig().setDynamicSlot(false); config.getEngineConfig().getSlotServiceConfig().setSlotNum(count); config.getEngineConfig().getSlotServiceConfig().setAllocateStrategy(strategy); if (waitStrategy) config.getEngineConfig().setScheduleStrategy(ScheduleStrategy.WAIT); config.getEngineConfig().getHttpConfig().setEnabled(false); config.getEngineConfig().getTelemetryConfig().getMetric().setEnabled(false); config.getEngineConfig().getCheckpointConfig().getStorage().setStorage("localfile"); config.getEngineConfig().getCheckpointConfig().getStorage().setStoragePluginConfig( Collections.singletonMap("namespace", System.getProperty("seatunnel.home") + "/checkpoints")); hz = SeaTunnelServerStarter.createHazelcastInstance(config); node = hz.node.nodeEngine; server = node.getService(SeaTunnelServer.SERVICE_NAME); long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(30); while (System.nanoTime() < deadline) { try { rm = server.getCoordinatorService().getResourceManager(); if (rm.workerCount(null) == 1 && rm.getUnassignedSlots(null).size() == count) break; } catch (RuntimeException waiting) { } Thread.sleep(100); } slots = server.getSlotService(); check(rm != null && rm.getUnassignedSlots(null).size() == count, "worker ready"); out("environment", "java=" + System.getProperty("java.version") + " maxHeap=" + Runtime.getRuntime().maxMemory() + " slots=" + count + " address=" + node.getThisAddress()); } private static void base(int count) throws Exception { WorkerProfile p = slots.getWorkerProfile(); out("13353", "cpu=" + p.getProfile().getCpu().getCore() + " slotHeap=" + p.getUnassignedSlots()[0].getResourceProfile().getHeapMemory().getBytes()); check(slots.requestSlot(9101, new ResourceProfile(CPU.of(1), Memory.of(0))).getSlotProfile() == null, "CPU request cannot fit"); long slice = p.getUnassignedSlots()[0].getResourceProfile().getHeapMemory().getBytes(); check(slots.requestSlot(9101, new ResourceProfile(CPU.of(0), Memory.of(slice + 1))).getSlotProfile() == null, "request larger than one slice cannot fit"); out("13353", "CPU=1 and heap=slotHeap+1 rejected while freeSlots=" + slots.getWorkerProfile().getUnassignedSlots().length); List<SlotProfile> acquired = rm.applyResources(9102, Collections.nCopies(count, new ResourceProfile()), null).get(10, TimeUnit.SECONDS); p = slots.getWorkerProfile(); out("13354", "freeSlots=" + p.getUnassignedSlots().length + " unassignedHeap=" + p.getUnassignedResource().getHeapMemory().getBytes() + " remainder=" + Runtime.getRuntime().maxMemory() % count); check(p.getUnassignedSlots().length == 0, "all fixed slots occupied"); rm.releaseResources(9102, acquired).get(10, TimeUnit.SECONDS); refresh(); var empty = rm.applyResources(9103, Collections.emptyList(), null); try { empty.get(1, TimeUnit.SECONDS); throw new AssertionError("empty request completed"); } catch (TimeoutException expected) { out("13356", "emptyFutureDone=" + empty.isDone() + " after=1000ms (contract requires nonempty list)"); } int success = 0; for (int i = 0; i < 100; i++) { refresh(); List<SlotProfile> result = rm.applyResources(9200 + i, Collections.nCopies(count, new ResourceProfile()), null).get(10, TimeUnit.SECONDS); check(new HashSet<>(result).size() == count, "distinct allocations"); rm.releaseResources(9200 + i, result).get(10, TimeUnit.SECONDS); success++; } out("13349", "oneWorkerExactCapacitySuccess=" + success + "/100 requestedEachRound=" + count); } /** Discards one successful RPC result from the caller's tracked allocation set. */ private static void lost() throws Exception { SlotAndWorkerProfile first = (SlotAndWorkerProfile) NodeEngineUtil.sendOperationToMemberNode( node, new RequestSlotOperation(9301, new ResourceProfile()), node.getThisAddress()).get(); SlotProfile discarded = copy(first.getSlotProfile()); SlotAndWorkerProfile second = (SlotAndWorkerProfile) NodeEngineUtil.sendOperationToMemberNode( node, new RequestSlotOperation(9301, new ResourceProfile()), node.getThisAddress()).get(); SlotProfile known = copy(second.getSlotProfile()); out("13346", "discardedSlot=" + discarded.getSlotID() + " secondSlot=" + known.getSlotID() + " assigned=" + slots.getWorkerProfile().getAssignedSlots().length); check(discarded.getSlotID() != known.getSlotID(), "repeated request is not idempotent"); rm.releaseResource(9301, known).get(10, TimeUnit.SECONDS); Thread.sleep(16000); out("13346", "afterReleasingKnownAnd16Seconds assigned=" + slots.getWorkerProfile().getAssignedSlots().length + " ownerMapSize=" + hz.getMap("probe-owned").size()); check(slots.getWorkerProfile().getAssignedSlots().length == 1, "orphan remains across heartbeats"); slots.releaseSlot(9301, discarded); } /** Sends the actual reset RPC after allocation, without injecting a network partition. */ private static void reset() throws Exception { SlotProfile before = copy(rm.applyResource(9401, new ResourceProfile(), null).get(10, TimeUnit.SECONDS)); Object context = slots.getSlotContext(before); NodeEngineUtil.sendOperationToMemberNode(node, new ResetResourceOperation(), node.getThisAddress()).get(); boolean missing = false; try { slots.getSlotContext(before); } catch (RuntimeException expected) { missing = true; } out("13347", "beforeAssigned=1 afterAssigned=" + slots.getWorkerProfile().getAssignedSlots().length + " oldContextMissing=" + missing + " hadContext=" + (context != null)); check(missing && slots.getWorkerProfile().getAssignedSlots().length == 0, "reset invalidates live allocation"); } private static void size(int count) { WorkerProfile p = slots.getWorkerProfile(); int bytes = node.getSerializationService().toData(p).dataSize(); long started = System.nanoTime(); List<SlotProfile> allocated = new ArrayList<>(); for (int i = 0; i < count; i++) allocated.add(copy(slots.requestSlot(9501, new ResourceProfile()).getSlotProfile())); long elapsed = System.nanoTime() - started; out("13355", "slots=" + count + " serializedWorkerProfileBytes=" + bytes + " directAllocationTotalMicros=" + elapsed / 1000); for (SlotProfile s : allocated) slots.releaseSlot(9501, s); } /** Stops precisely between successful pre-apply and JobMaster.run, with real slot RPCs/IMaps. */ private static void pending(String file) throws Exception { JobMaster jm = job(9601, file); jm.init(System.currentTimeMillis(), false); jm.getRunningJobStateIMap().put(9601L, JobStatus.PENDING); check(jm.preApplyResources(), "preapply succeeds"); int allocated = slots.getWorkerProfile().getAssignedSlots().length; int futures = jm.getPhysicalPlan().getPreApplyResourceFutures().size(); out("13344", "beforeCancel jobStatus=" + jm.getJobStatus() + " assigned=" + allocated + " preApplied=" + futures + " ownedMapSize=" + hz.getMap("probe-owned").size()); jm.cancelJob(); Thread.sleep(1500); out("13344", "afterCancel jobStatus=" + jm.getJobStatus() + " assigned=" + slots.getWorkerProfile().getAssignedSlots().length + " ownedMapSize=" + hz.getMap("probe-owned").size()); check(jm.getJobStatus() == JobStatus.CANCELED && slots.getWorkerProfile().getAssignedSlots().length == allocated, "pending cancel leaves acquired slots"); refresh(); if (slots.getWorkerProfile().getUnassignedSlots().length == 0) { boolean rejected = false; try { rm.applyResource(9602, new ResourceProfile(), null).get(10, TimeUnit.SECONDS); } catch (ExecutionException expected) { rejected = true; } out("13344", "followingOneSlotRequestRejected=" + rejected); check(rejected, "leaked capacity blocks subsequent allocation"); } for (var f : jm.getPhysicalPlan().getPreApplyResourceFutures().values()) slots.releaseSlot(9601, f.join()); } /** Seeds a terminal vertex in a running pipeline, then exercises real failover pre-apply. */ private static void finished(String file) throws Exception { JobMaster original = job(9801, file); original.init(System.currentTimeMillis(), false); SubPlan pipeline = original.getPhysicalPlan().getPipelineList().get(0); PhysicalVertex terminal = pipeline.getCoordinatorVertexList().get(0); original.getRunningJobStateIMap().put(9801L, JobStatus.RUNNING); original.getRunningJobStateIMap().put(pipeline.getPipelineLocation(), PipelineStatus.RUNNING); original.getRunningJobStateIMap().put(terminal.getTaskGroupLocation(), ExecutionState.FINISHED); JobMaster restored = master(9801, node.getSerializationService().toData(original.getJobImmutableInformation())); restored.init(System.currentTimeMillis(), true); SubPlan restoredPipeline = restored.getPhysicalPlan().getPipelineList().get(0); PhysicalVertex restoredTerminal = restoredPipeline.getCoordinatorVertexList().get(0); check(restoredTerminal.getExecutionState() == ExecutionState.FINISHED, "persisted terminal vertex restored"); check(restored.preApplyResources(), "failover preapply succeeds"); boolean allocated = restored.getPhysicalPlan().getPreApplyResourceFutures().containsKey(restoredTerminal.getTaskGroupLocation()); out("13345", "fixturePipeline=" + restoredPipeline.getPipelineState() + " vertex=" + restoredTerminal.getExecutionState() + " allocatedToFinishedVertex=" + allocated + " assigned=" + slots.getWorkerProfile().getAssignedSlots().length + " ownedMapSize=" + hz.getMap("probe-owned").size()); check(allocated, "preapply allocates for a finished vertex"); for (var f : restored.getPhysicalPlan().getPreApplyResourceFutures().values()) slots.releaseSlot(9801, f.join()); restored.neverNeedRestore(); original.neverNeedRestore(); } /** Records the executor used by actual RequestSlotOperation invocation completions. */ private static void callback() throws Exception { Set<String> names = new HashSet<>(); for (int i = 0; i < 20; i++) { var observed = new CompletableFuture<String>(); var invocation = NodeEngineUtil.<SlotAndWorkerProfile>sendOperationToMemberNode( node, new RequestSlotOperation(9901, new ResourceProfile()), node.getThisAddress()); invocation.whenComplete((p, e) -> observed.complete(Thread.currentThread().getName())); SlotAndWorkerProfile result = invocation.get(); names.add(observed.get(10, TimeUnit.SECONDS)); slots.releaseSlot(9901, result.getSlotProfile()); } out("13350", "actualInvocationCompletionThreads=" + names + " (no retry failure injected)"); } /** Forces a resource-starved restore through public lifecycle methods, without running a connector. */ private static void restore(String file) throws Exception { JobMaster jm = job(9951, file); jm.init(System.currentTimeMillis(), false); jm.getRunningJobStateIMap().put(9951L, JobStatus.RUNNING); SubPlan pipeline = jm.getPhysicalPlan().getPipelineList().get(0); List<SlotProfile> blocker = rm.applyResources(9952, Collections.nCopies(slots.getWorkerProfile().getUnassignedSlots().length, new ResourceProfile()), null).get(10, TimeUnit.SECONDS); pipeline.updatePipelineState(PipelineStatus.FAILED); pipeline.startSubPlanStateProcess(); long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(45); while (!(pipeline.getPipelineRestoreNum() >= 3 && pipeline.getPipelineState().isEndState()) && System.nanoTime() < deadline) Thread.sleep(100); out("13348", "resourceStarvedRestoreAttempts=" + pipeline.getPipelineRestoreNum() + " pipelineState=" + pipeline.getPipelineState() + " canRestore=" + pipeline.canRestorePipeline()); check(pipeline.getPipelineRestoreNum() == 3 && pipeline.getPipelineState() == PipelineStatus.FAILED, "resource shortfall exhausts restore budget and ends pipeline"); jm.neverNeedRestore(); pipeline.stopSubPlanStateProcess(); rm.releaseResources(9952, blocker).get(10, TimeUnit.SECONDS); } private static void liveJob(String file) throws Exception { Common.setDeployMode(DeployMode.CLIENT); JobConfig jc = new JobConfig(); jc.setName("static-slot-live-control"); jc.setJobContext(new JobContext(9961L)); IdGenerator generator = new IdGenerator(); var parsed = new MultipleTableJobConfigParser(file, generator, jc).parse(null); LogicalDag dag = new LogicalDagGenerator(parsed.getLeft(), jc, generator).generate(); JobImmutableInformation info = new JobImmutableInformation(9961L, "probe", node.getSerializationService(), dag, Collections.emptyList(), Collections.emptyList()); server.getCoordinatorService().submitJob(9961L, node.getSerializationService().toData(info), false).get(10, TimeUnit.SECONDS); long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(30); JobStatus status = null; while (System.nanoTime() < deadline) { status = server.getCoordinatorService().getJobStatus(9961L); if (status == JobStatus.RUNNING || status.isEndState()) break; Thread.sleep(100); } out("control", "submittedFakeToConsoleJobStatus=" + status + " assigned=" + slots.getWorkerProfile().getAssignedSlots().length); check(status == JobStatus.RUNNING || status == JobStatus.FINISHED, "real job executes"); if (!status.isEndState()) server.getCoordinatorService().cancelJob(9961L).get(10, TimeUnit.SECONDS); deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(20); while (slots.getWorkerProfile().getAssignedSlots().length != 0 && System.nanoTime() < deadline) Thread.sleep(100); out("control", "afterNormalJobCleanup assigned=" + slots.getWorkerProfile().getAssignedSlots().length); check(slots.getWorkerProfile().getAssignedSlots().length == 0, "ordinary job cleanup returns slots"); } /** Exercises the stale-future boundary without deploying a task into the blocker's slots. */ private static void stale(String file) throws Exception { JobMaster jm = job(9971, file); jm.init(System.currentTimeMillis(), false); check(jm.preApplyResources(), "initial allocation succeeds"); SubPlan pipeline = jm.getPhysicalPlan().getPipelineList().get(0); ResourceUtils.applyResourceForPipeline(jm, pipeline); jm.releasePipelineResource(pipeline); refresh(); List<SlotProfile> blocker = rm.applyResources(9972, Collections.nCopies(slots.getWorkerProfile().getUnassignedSlots().length, new ResourceProfile()), null).get(10, TimeUnit.SECONDS); check(!jm.preApplyResources(pipeline), "reallocation fails while pool occupied"); Map<?, SlotProfile> retained = ResourceUtils.applyResourceForPipeline(jm, pipeline); long active = retained.values().stream().filter(p -> p.getOwnerJobID() == 9971).filter(rm::slotActiveCheck).count(); out("12509", "failedPreapplyThenApplyPipelineReturned=" + retained.size() + " activeSlotsOwnedByOriginalJob=" + active + " returnedOwnerJobIDs=" + retained.values().stream().map(SlotProfile::getOwnerJobID).collect(Collectors.toSet())); check(retained.size() == 2 && active == 0, "resource utility accepts allocations not owned by original job"); rm.releaseResources(9972, blocker).get(10, TimeUnit.SECONDS); jm.neverNeedRestore(); } private static void reuse(String file) throws Exception { JobMaster original = job(9981, file); original.init(System.currentTimeMillis(), false); check(original.preApplyResources(), "original allocation succeeds"); SubPlan pipeline = original.getPhysicalPlan().getPipelineList().get(0); Map<?, SlotProfile> old = ResourceUtils.applyResourceForPipeline(original, pipeline); refresh(); List<SlotProfile> blocker = rm.applyResources(9982, Collections.nCopies(slots.getWorkerProfile().getUnassignedSlots().length, new ResourceProfile()), null).get(10, TimeUnit.SECONDS); JobMaster restored = master(9981, node.getSerializationService().toData(original.getJobImmutableInformation())); restored.init(System.currentTimeMillis(), true); boolean reused = restored.preApplyResources(); out("9589", "allSlotsOccupied=true restoredPreapplySucceeded=" + reused + " originalActiveAllocations=" + old.values().stream().filter(rm::slotActiveCheck).count()); check(reused, "current dev reuses active persisted slots"); rm.releaseResources(9982, blocker).get(10, TimeUnit.SECONDS); original.releasePipelineResource(pipeline); original.neverNeedRestore(); restored.neverNeedRestore(); } /** Uses the actual coordinator queue, then removes its oversized head to test causality. */ private static void admission(String file) throws Exception { var coordinator = server.getCoordinatorService(); coordinator.submitJob(10001L, definition(10001, file.replace("job.conf", "job-large.conf")), false).get(10, TimeUnit.SECONDS); Thread.sleep(1000); coordinator.submitJob(10002L, definition(10002, file), false).get(10, TimeUnit.SECONDS); Thread.sleep(10000); out("12985", "after10Seconds head=" + coordinator.getJobStatus(10001L) + " fittingFollower=" + coordinator.getJobStatus(10002L) + " freeFixedSlots=" + slots.getWorkerProfile().getUnassignedSlots().length); check(coordinator.getJobStatus(10001L) == JobStatus.PENDING && coordinator.getJobStatus(10002L) == JobStatus.PENDING, "oversized FIFO head blocks follower"); coordinator.cancelJob(10001L).get(10, TimeUnit.SECONDS); long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(20); JobStatus status; do { status = coordinator.getJobStatus(10002L); if (status == JobStatus.RUNNING || status.isEndState()) break; Thread.sleep(100); } while (System.nanoTime() < deadline); out("12985", "afterCancelingHead follower=" + status); check(status == JobStatus.RUNNING || status == JobStatus.FINISHED, "removing head admits fitting follower"); if (!status.isEndState()) coordinator.cancelJob(10002L).get(10, TimeUnit.SECONDS); deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(20); while (slots.getWorkerProfile().getAssignedSlots().length != 0 && System.nanoTime() < deadline) Thread.sleep(100); check(slots.getWorkerProfile().getAssignedSlots().length == 0, "admission control cleanup returns slots"); } /** Delays a real retry RPC while observing its completing thread; response delivery is real. */ private static void blocking() throws Exception { WorkerProfile stale = slots.getWorkerProfile(); List<SlotProfile> blockers = new ArrayList<>(); for (int i = 0; i < stale.getUnassignedSlots().length; i++) blockers.add(copy(slots.requestSlot(9992, new ResourceProfile()).getSlotProfile())); RetryProbeManager test = new RetryProbeManager(stale, blockers); var firstLocked = new CountDownLatch(1); var firstRelease = new CountDownLatch(1); Thread firstHolder = hold(firstLocked, firstRelease); check(firstLocked.await(5, TimeUnit.SECONDS), "first RPC gate held"); var result = new ResourceRequestHandler(9991L, Collections.singletonList(new ResourceProfile()), test.registerWorker, test, new RandomStrategy()).request(null); firstRelease.countDown(); check(test.retryLocked.await(5, TimeUnit.SECONDS), "retry gate held"); Thread.sleep(250); boolean found = false; for (var entry : Thread.getAllStackTraces().entrySet()) { boolean handler = Arrays.stream(entry.getValue()).anyMatch(f -> f.getClassName().endsWith("ResourceRequestHandler")); boolean waiting = Arrays.stream(entry.getValue()).anyMatch(f -> f.getClassName().equals("java.util.concurrent.CompletableFuture") && f.getMethodName().equals("get")); if (handler && waiting) { found = true; out("13350", "blockedCompletionThread=" + entry.getKey().getName()); for (StackTraceElement frame : entry.getValue()) System.out.println("BLOCKED_STACK " + frame); } } test.retryRelease.countDown(); List<SlotProfile> known = result.get(10, TimeUnit.SECONDS); check(found && test.requests == 2, "retry blocks completion callback until real RPC can finish"); out("13350", "realRequestRPCs=" + test.requests + " resultSlots=" + known.size()); for (SlotProfile p : known) slots.releaseSlot(9991, p); for (SlotProfile p : blockers) slots.releaseSlot(9992, p); firstHolder.join(1000); } private static Thread hold(CountDownLatch locked, CountDownLatch release) { Thread t = new Thread(() -> { synchronized (slots) { locked.countDown(); try { release.await(10, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }, "probe-slot-delay"); t.start(); return t; } /** Controls only cached capacity and RPC timing; RequestSlotOperation still executes normally. */ private static class RetryProbeManager extends AbstractResourceManager { final List<SlotProfile> blockers; final CountDownLatch retryLocked = new CountDownLatch(1); final CountDownLatch retryRelease = new CountDownLatch(1); int responses; volatile int requests; RetryProbeManager(WorkerProfile stale, List<SlotProfile> blockers) { super(node, config.getEngineConfig()); this.blockers = blockers; registerWorker.put(stale.getAddress(), stale); } @Override public void heartbeat(WorkerProfile p) { if (responses++ == 0) { slots.releaseSlot(9992, blockers.remove(0)); p = slots.getWorkerProfile(); hold(retryLocked, retryRelease); try { if (!retryLocked.await(5, TimeUnit.SECONDS)) throw new AssertionError("retry lock not held"); } catch (InterruptedException e) { throw new RuntimeException(e); } } registerWorker.put(p.getAddress(), p); } @Override protected <E> CompletableFuture<E> sendToMember(Operation operation, Address address) { if (operation instanceof RequestSlotOperation) requests++; return super.sendToMember(operation, address); } } private static void strategy(String file) throws Exception { SlotRatioStrategy strategy = (SlotRatioStrategy) ((AbstractResourceManager) rm).getSlotAllocationStrategy(); boolean npe = false; try { strategy.selectWorker(Collections.singletonList(slots.getWorkerProfile())); } catch (NullPointerException expected) { npe = true; } strategy.setWorkerAssignedSlots(new ConcurrentHashMap<>()); strategy.selectWorker(Collections.singletonList(slots.getWorkerProfile())); Map<?, ?> old = strategy.getWorkerAssignedSlots(); JobMaster jm = job(9701, file); jm.init(System.currentTimeMillis(), false); check(jm.preApplyResources(), "strategy preapply succeeds"); out("13352", "uninitializedDirectSelectionNPE=" + npe + " sharedMapReplaced=" + (old != strategy.getWorkerAssignedSlots()) + " priorMapEntries=" + old.size()); check(old != strategy.getWorkerAssignedSlots(), "job resets resource-manager strategy map"); for (var f : jm.getPhysicalPlan().getPreApplyResourceFutures().values()) slots.releaseSlot(9701, f.join()); } private static JobMaster job(long id, String file) throws Exception { return master(id, definition(id, file)); } private static Data definition(long id, String file) throws Exception { Common.setDeployMode(DeployMode.CLIENT); JobConfig jc = new JobConfig(); jc.setName("static-slot-probe"); jc.setJobContext(new JobContext(id)); IdGenerator generator = new IdGenerator(); var parsed = new MultipleTableJobConfigParser(file, generator, jc).parse(null); LogicalDag dag = new LogicalDagGenerator(parsed.getLeft(), jc, generator).generate(); JobImmutableInformation info = new JobImmutableInformation(id, "probe", node.getSerializationService(), dag, Collections.emptyList(), Collections.emptyList()); Data data = node.getSerializationService().toData(info); return data; } private static JobMaster master(long id, Data data) { return new JobMaster(id, data, node, JOB_EXECUTOR, rm, server.getCoordinatorService().getJobHistoryService(), hz.getMap("probe-state"), hz.getMap("probe-timestamps"), hz.getMap("probe-owned"), hz.getMap("probe-job-info"), config.getEngineConfig(), server); } private static SlotProfile copy(SlotProfile p) { return node.getSerializationService().toObject(node.getSerializationService().toData(p)); } private static void refresh() { rm.heartbeat(slots.getWorkerProfile()); } private static void out(String issue, String message) { System.out.println("RESULT " + issue + " " + message); } private static void check(boolean condition, String message) { if (!condition) throw new AssertionError(message); } } ``` `job.conf` ```hocon # 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. env { parallelism = 1 job.mode = "STREAMING" checkpoint.interval = 60000 } source { FakeSource { plugin_output = "fake" row.num = 10 split.num = 1 split.read-interval = 1000 schema = { fields { id = "int" } } } } sink { Console { plugin_input = ["fake"] } } ``` `run-probe.sh` ```bash #!/usr/bin/env bash # 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. set -euo pipefail task_root=$(cd -- "$(dirname -- "$0")" && pwd) scenario=$1 slot_count=$2 run_name=${3:-$scenario-$slot_count} probe_java=${PROBE_JAVA:-$task_root/tooling/runtime21/bin/java} mkdir -p "$task_root/runs/$run_name" cd "$task_root/runs/$run_name" set +e timeout 180 "$probe_java" -Xms128m -Xmx256m \ -XX:ActiveProcessorCount=2 -Dseatunnel.home="$task_root/runtime" \ -cp "$task_root/probe-classes:$task_root/src/seatunnel-core/seatunnel-starter/target/seatunnel-starter.jar:$task_root/runtime/lib/*:$task_root/runtime/connectors/*" \ StaticSlotProbe "$scenario" "$slot_count" "$task_root/job.conf" > console.log 2>&1 task_rc=$? printf '%s\n' "$task_rc" > exit-code.txt grep -E 'RESULT|PROBE_COMPLETE|Exception|Error' console.log | tail -25 exit "$task_rc" ``` </details> Validation and wording were AI-assisted; the outputs above are from the actual host runs. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
