Skip to content

feat: Use per-context replay status #403

Open
ayushiahjolia wants to merge 1 commit into
mainfrom
per-context-replay-tracking
Open

feat: Use per-context replay status #403
ayushiahjolia wants to merge 1 commit into
mainfrom
per-context-replay-tracking

Conversation

@ayushiahjolia
Copy link
Copy Markdown
Contributor

@ayushiahjolia ayushiahjolia commented May 25, 2026

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Issue Link, if available

Fixes #383

Adds per-context replay tracking to the Java SDK. This is a prerequisite for the plugin hooks feature (#364) and OTel integration (#333).

Problem

Log suppression during replay used the global ExecutionManager.isReplaying() flag. When multiple branches run concurrently (parallel/map), the global flag flips to EXECUTION as soon as any branch encounters new work - causing logs in other branches that are still replaying to leak through.

The old per-context field (BaseContextImpl.isReplaying) was a one-shot transition guard used only by BaseDurableOperation.execute(). It was never used for log suppression and answered a different question ("has this context ever seen a non-cached op?") rather than ("is the next operation already checkpointed?").

Solution

Added proactive per-context replay tracking in DurableContextImpl:

  • replayMode field - initialized by checking if the next operation (via peekNextOperationId()) exists in checkpoint storage
  • updateReplayStatus() - called after nextOperationId() in each operation method; peeks at the following operation and transitions out of replay if it doesn't exist
  • isReplayingContext() - exposes the per-context replay status to the logger and future plugin hooks

This matches the Python SDK's _track_replay() pattern: after consuming the current operation's ID, peek at the next one - if it's not in storage, we're past the replay boundary.

Checklist

  • I have filled out every section of the PR template
  • I have thoroughly tested this change

Testing

Unit Tests

Have unit tests been written for these changes? Yes

Integration Tests

Have integration tests been written for these changes? N/A

Examples

Has a new example been added for the change? (if applicable) N/A

@ayushiahjolia ayushiahjolia requested a review from a team May 25, 2026 21:40
Comment thread sdk/src/test/java/software/amazon/lambda/durable/logging/DurableLoggerTest.java Outdated
@ayushiahjolia ayushiahjolia marked this pull request as draft May 26, 2026 00:25
@ayushiahjolia ayushiahjolia force-pushed the per-context-replay-tracking branch from 18745f5 to 216aae2 Compare May 27, 2026 05:31
@ayushiahjolia ayushiahjolia force-pushed the per-context-replay-tracking branch from 216aae2 to 3b35b3e Compare May 27, 2026 05:46
@ayushiahjolia ayushiahjolia changed the title feat(logging): Use per-context replay status for log suppression feat(logging): Use per-context replay status May 27, 2026
@ayushiahjolia ayushiahjolia changed the title feat(logging): Use per-context replay status feat: Use per-context replay status May 27, 2026
@ayushiahjolia ayushiahjolia marked this pull request as ready for review May 27, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: per-context replay tracking

3 participants