Skip to content

Commit eb205ce

Browse files
committed
add presuspend sanity check
1 parent e8fe528 commit eb205ce

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

sdk/src/main/java/software/amazon/lambda/durable/execution/ExecutionManager.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,26 @@ public void deregisterActiveThread(String threadId) {
223223

224224
if (activeThreads.isEmpty()) {
225225
logger.info("No active threads remaining - suspending execution");
226+
preSuspendCheck();
226227
suspendExecution();
227228
}
228229
}
229230
}
230231

232+
private void preSuspendCheck() {
233+
if (executionExceptionFuture.isDone()) {
234+
throw new IllegalStateException("Execution already suspended");
235+
}
236+
237+
operationStorage.values().stream()
238+
.filter(op -> !isTerminalStatus(op.status()))
239+
.findFirst()
240+
.ifPresentOrElse(op -> logger.debug("Some operations pending"), () -> {
241+
logger.warn("There is no operation still in progress");
242+
throw new IllegalStateException("Cannot suspend execution without an operation in progress");
243+
});
244+
}
245+
231246
// ===== Checkpointing =====
232247

233248
// This method will checkpoint the operation updates to the durable backend and return a future which completes

0 commit comments

Comments
 (0)