fix(insight): schedule exports off the hook threads (#703)
- fix(insight): schedule exports off the hook threads
Exporter I/O previously ran inline inside onInvocationStart, onOperationChange, and onInvocationEnd, so a slow exporter delayed the SDK’s checkpoint callbacks in ON_CHANGE mode.
Records are now handed to a background scheduler that exports at most one record at a time. Each record is a complete snapshot, so updates arriving while an export is in flight coalesce into a single pending slot and only the latest is exported next. Exporters for one record run concurrently and independently. onInvocationEnd drains the scheduler and then flushes every exporter once, so the final record is always delivered before the invocation returns; if no worker can be started, the drain exports the pending record itself at that boundary.
- fix(insight): harden invocation-end delivery guarantees
- Reject operation-change hooks once invocation end has begun. A checkpoint for an unawaited asynchronous operation can complete while the end record is draining; its RUNNING snapshot must not replace or follow the final record. The closed flag and the final schedule are set under one lock.
- Complete the pump handle when worker submission fails, so a drain() that already observed the handle wakes up and exports the pending record inline instead of blocking forever.
- Flush exporters concurrently and independently, matching how exports fan out, so one slow or failing flush never delays the others.
Co-authored-by: Alex Wang wangyb@amazon.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
AWS Lambda Durable Execution SDK for Java
Build resilient, long-running AWS Lambda functions that automatically checkpoint progress and resume after failures. Durable functions can run for up to one year while you pay only for active compute time.
Key Features
map(), with per-item error isolation and configurable completion criteriaHow It Works
Your durable function extends
DurableHandler<I, O>and implementshandleRequest(I input, DurableContext ctx). TheDurableContextis your interface to durable operations:ctx.step()– Execute code and checkpoint the resultctx.wait()– Suspend execution without compute chargesctx.createCallback()– Wait for external events (approvals, webhooks)ctx.waitForCallback()– Simplify callback handling by combining callback creation and submission in one operationctx.invoke()– Invoke another Lambda function, durable or standard, and wait for the resultctx.runInChildContext()– Run an isolated child context with its own checkpoint logctx.map()– Apply a function to each item in a collection concurrentlyctx.parallel()- Run multiple operations concurrently with optional concurrency controlctx.waitForCondition()– Poll a condition function until it signals done, suspending between pollsQuick Start
Installation
Your First Durable Function
Deployment
See examples/README.md for complete instructions on local testing and running cloud integration tests.
See Deploy and invoke Lambda durable functions with the AWS CLI for more information on deploying and invoking durable functions.
See Deploy Lambda durable functions with Infrastructure as Code for more information on deploying durable functions using infrastructure-as-code.
Documentation
Core Operations
Examples
Advanced Topics
v1.2.1Related SDKs
Security
See CONTRIBUTING for information about reporting security issues.
License
This project is licensed under the Apache-2.0 License. See LICENSE for details.