fix(lambda): leave out the children of a durable context closed without ReplayChildren (#8248)

Floci listed every operation in the invocation event and in
GetDurableExecutionState. AWS leaves out the operations under a child
context closed without ReplayChildren=true, and everything below them.
Both now use one filtered view, and a context closed without
ContextOptions shows ReplayChildren: false. The checkpoint answer is
unchanged.
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-11-13 22:37:23 -04:00
1 parent f0de926e02
commit 4313fc5fac
8 files changed
+190 -5

No files matched your search

@@ -270,9 +270,7 @@ final class DurableCheckpointApplier {
existing.setStatus(succeeded ? DurableOperationStatus.SUCCEEDED : DurableOperationStatus.FAILED);
existing.setResult(succeeded ? update.payload() : null);
existing.setError(succeeded ? null : update.error());
if (update.replayChildren() != null) {
existing.setReplayChildren(update.replayChildren());
}
existing.setReplayChildren(Boolean.TRUE.equals(update.replayChildren()));
existing.setEndTimestamp(now);
touch(existing);
event(existing, succeeded ? "ContextSucceeded" : "ContextFailed",
@@ -305,7 +305,7 @@ public class DurableExecutionService implements Resettable {
List<DurableOperation> operations;
synchronized (lockFor(arn)) {
DurableExecution execution = loadWithCurrentToken(arn, checkpointToken);
operations = new ArrayList<>(execution.getOperations().values());
operations = execution.replayedOperations();
}
List<Cursored<DurableOperation>> indexed = new ArrayList<>(operations.size());
for (int i = 0; i < operations.size(); i++) {
@@ -60,7 +60,7 @@ public final class DurableWire {
event.put("CheckpointToken", checkpointToken);
ObjectNode state = event.putObject("InitialExecutionState");
ArrayNode operations = state.putArray("Operations");
for (DurableOperation operation : execution.getOperations().values()) {
for (DurableOperation operation : execution.replayedOperations()) {
operations.add(operation(operation, true));
}
state.put("NextMarker", "");
@@ -6,8 +6,10 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
/**
* A durable execution with its checkpointed operations and history. One stored object per
@@ -66,6 +68,29 @@ public class DurableExecution {
return status.isClosed();
}
/** AWS leaves out the operations under a closed CONTEXT that did not ask to replay its children. */
public List<DurableOperation> replayedOperations() {
List<DurableOperation> replayed = new ArrayList<>(operations.size());
Set<String> leftOut = new HashSet<>();
for (DurableOperation operation : operations.values()) {
String parentId = operation.getParentId();
if (parentId != null) {
DurableOperation parent = operations.get(parentId);
boolean parentClosedWithoutReplay = parent != null
&& parent.getType() == DurableOperationType.CONTEXT
&& (parent.getStatus() == DurableOperationStatus.SUCCEEDED
|| parent.getStatus() == DurableOperationStatus.FAILED)
&& !Boolean.TRUE.equals(parent.getReplayChildren());
if (leftOut.contains(parentId) || parentClosedWithoutReplay) {
leftOut.add(operation.getId());
continue;
}
}
replayed.add(operation);
}
return replayed;
}
@JsonIgnore
public boolean hasUnseenChanges() {
return changeSequence > seenSequence;