mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(lambda): list changed durable operations in creation order (#5328)
AWS lists the operations in a checkpoint answer, and the ids in UpdatedOperationIds, in the order they were created. Floci listed them in the order they changed, so a step finished after a newer one started, a wait that fell due, or a chained invoke that failed at once came out of place.
This commit is contained in:
1 parent
c8f16d2484
commit
9c2db353f1
2 files changed
+15
-2
No files matched your search
+1
-2
@@ -34,7 +34,6 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -1035,10 +1034,10 @@ public class DurableExecutionService implements Resettable {
|
||||
.orElseThrow(() -> new AwsException("ResourceNotFoundException", NOT_FOUND, 404));
|
||||
}
|
||||
|
||||
/** In creation order, as AWS lists them, not in the order they changed. */
|
||||
private static List<DurableOperation> unseenOperations(DurableExecution execution) {
|
||||
return execution.getOperations().values().stream()
|
||||
.filter(operation -> operation.getChangeSequence() > execution.getSeenSequence())
|
||||
.sorted(Comparator.comparingLong(DurableOperation::getChangeSequence))
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
+14
@@ -207,6 +207,20 @@ class DurableExecutionServiceTest {
|
||||
assertEquals("\"r\"", execution.getResult(), "the checkpointed result wins over the handler return");
|
||||
}
|
||||
|
||||
@Test
|
||||
void theCheckpointAnswerListsOperationsInCreationOrder() {
|
||||
invoker.script(event -> {
|
||||
String next = checkpoint(event, token(event), List.of(step("s1", DurableOperationAction.START, null, null)))
|
||||
.checkpointToken();
|
||||
CheckpointResult answer = checkpoint(event, next, List.of(step("s2", DurableOperationAction.START, null,
|
||||
null), step("s1", DurableOperationAction.SUCCEED, "1", null)));
|
||||
assertEquals(List.of("s1", "s2"), answer.newExecutionState().stream().map(DurableOperation::getId).toList());
|
||||
return succeeded("");
|
||||
});
|
||||
|
||||
start("exec-1", "{}", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aClosingCheckpointEndsTheInvocationAndTheHandlerReturnIsIgnored() {
|
||||
List<CheckpointResult> closing = new ArrayList<>();
|
||||
|
||||
Reference in new issue
Block a user