test(stepfunctions): pin that a failing Map iteration stops the .sync job of another (#4712)

* test(stepfunctions): pin that a failing Map iteration stops the .sync job of another

The Run a Job guide names an uncaught failure in a Map iteration, next to a
Parallel branch failure, as a reason a .sync job is aborted. #4660 covers it
through the same InterruptedException catch, because MapIterationScheduler
cancels the sibling iterations with cancel(true), but only Parallel was named
in step-functions.md and no test held the Map case. One executor test now runs
an inline Map whose "fail" item fails while the other item's Task waits on a
child execution, and asserts the child is aborted with the AWS cause. Without
the catch it fails (child never stopped). The doc names the Map case beside
the Parallel one, and the gaps paragraph no longer says a cut Parallel branch
is unrecorded, which #4660 changed.

Follow-up from the review of #4660.

* docs(stepfunctions): record what AWS writes for a Map iteration it cuts

Measured in ap-northeast-1: an inline Map iteration that fails records a
MapIterationAborted for each iteration it cuts and the *StateAborted of the
state it was in, all chained to the failing iteration's last event and before
MapIterationFailed and MapStateFailed. The child the cut Task waited on is
aborted within about 0.15 s with the Task-state cause, with or without a Catch
on the Map. The gaps paragraph and the test's javadoc now say so.

---------

Co-authored-by: mitsukado-shinagawa <mitsukado-shinagawa@users.noreply.github.com>
This commit is contained in:
mitsukado-shinagawaandmitsukado-shinagawa authored and GitHub committed 2026-09-29 23:47:30 -04:00
1 parent 6b7d17698c
commit ae710c04d0
2 files changed
+43 -10

No files matched your search

@@ -50,7 +50,10 @@ import static org.mockito.Mockito.when;
* cause below, and records one {@code TaskStateAborted} (or {@code WaitStateAborted}) per cut
* branch, each chained to the failing branch's last event and recorded before
* {@code ParallelStateFailed}, which is chained to that same event. When the execution's budget
* cuts the Parallel instead, the child is aborted as well and no such event is recorded.
* cuts the Parallel instead, the child is aborted as well and no such event is recorded. An
* iteration of an inline Map that fails cuts the other iterations the same way, and the job one of
* them waits on is aborted too (measured: within about 0.15 s, with the same cause, whether or not
* a Catch on the Map keeps the execution going).
*
* <p>The failing branch pauses in a Wait that the sleeper holds until every other branch is
* parked on its own wait, so the cut always lands while the others are mid-state.
@@ -81,6 +84,16 @@ class AslExecutorParallelCutTest {
{"StartAt":"Done","States":{"Done":{"Type":"Pass","End":true}}}""";
private static final String LONG_WAIT_BRANCH = """
{"StartAt":"Long","States":{"Long":{"Type":"Wait","Seconds":20,"End":true}}}""";
/** An inline Map whose "fail" item runs the failing branch and whose other items run the nested one. */
private static final String MAP_WITH_A_FAILING_ITERATION = """
{"Type":"Map","End":true,"ItemProcessor":{"ProcessorConfig":{"Mode":"INLINE"},
"StartAt":"Route","States":{
"Route":{"Type":"Choice","Default":"Nest",
"Choices":[{"Variable":"$.kind","StringEquals":"fail","Next":"Pause"}]},
"Pause":{"Type":"Wait","Seconds":1,"Next":"Boom"},
"Boom":{"Type":"Fail","Error":"Boom","Cause":"sibling failed"},
"Nest":{"Type":"Task","Resource":"arn:aws:states:::states:startExecution.sync:2",
"Parameters":{"StateMachineArn":"%s"},"End":true}}}}""".formatted(CHILD_SM_ARN);
private final ObjectMapper objectMapper = new ObjectMapper();
private StepFunctionsService sfnService;
@@ -151,6 +164,18 @@ class AslExecutorParallelCutTest {
assertTrue(types().stream().noneMatch(type -> type.endsWith("StateAborted")), types().toString());
}
@Test
void aMapIterationFailureAbortsTheChildAnotherIterationWaitsOn() {
Execution execution = run(MAP_WITH_A_FAILING_ITERATION, sleeper(1), 0,
"[{\"kind\":\"nest\"},{\"kind\":\"fail\"}]");
assertEquals("FAILED", execution.getStatus());
assertEquals("Boom", execution.getError());
assertEquals("sibling failed", execution.getCause());
assertEquals(1, eventsOfType("MapIterationFailed").size(), types().toString());
verify(sfnService, timeout(5_000)).stopExecution(eq(CHILD_ARN), eq(ABORT_CAUSE), isNull());
}
@Test
void executionBudgetCuttingTheParallelAbortsTheChildAndRecordsNoAbortedState() {
Execution execution = run(parallel(NESTED_SYNC_BRANCH), 0, 1);
@@ -228,10 +253,15 @@ class AslExecutorParallelCutTest {
}
private Execution run(String parallelState, AslExecutor.Sleeper sleeper, int executionTimeoutSeconds) {
return run(parallelState, sleeper, executionTimeoutSeconds, "{}");
}
private Execution run(String state, AslExecutor.Sleeper sleeper, int executionTimeoutSeconds,
String input) {
String budget = executionTimeoutSeconds > 0
? "\"TimeoutSeconds\":%d,".formatted(executionTimeoutSeconds)
: "";
String definition = "{" + budget + "\"StartAt\":\"P\",\"States\":{\"P\":" + parallelState + "}}";
String definition = "{" + budget + "\"StartAt\":\"P\",\"States\":{\"P\":" + state + "}}";
StateMachine stateMachine = new StateMachine();
stateMachine.setName("parent");
@@ -243,7 +273,7 @@ class AslExecutorParallelCutTest {
execution.setName("parent-run");
execution.setExecutionArn(PARENT_ARN);
execution.setStateMachineArn(stateMachine.getStateMachineArn());
execution.setInput("{}");
execution.setInput(input);
history = new ArrayList<>();
newExecutor(sleeper).executeSync(stateMachine, execution, history, (updated, events) -> { });