Skip to content

Release streamed history snapshots after test-host work items complete - #811

Merged
wangbill (YunchuWang) merged 1 commit into
mainfrom
yunchuwang-release-test-host-history-buffers
Oct 6, 2026
Merged

wangbill (YunchuWang) merged 1 commit into
mainfrom
yunchuwang-release-test-host-history-buffers

Conversation

@YunchuWang

@YunchuWang wangbill (YunchuWang) commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

What changed?

Release the in-process test host's streamed worker-replay snapshot when its ExecuteOrchestrator call finishes. One owner-scoped finally spans dispatch and the awaited final response, and removes only that invocation's snapshot.

Keep snapshots available during active episodes, history reads, and partial responses. Add deterministic lifetime regressions and real public-client tests that reuse one host for two large instances, including ContinueAsNew, and clarify the lifetime in the test-host README.

Why is this change needed?

Episodes with more than 1 MiB of encoded past events leave a redundant protobuf history list strongly referenced after completion or dispatch failure. These snapshots accumulate as the test host is reused, even after public purge removes the authoritative instance state. Cleanup belongs to the episode's lifetime, not instance completion or purge.

Issues / work items

  • Resolves: N/A
  • Related: N/A

Project checklist

  • Release notes are not required for the next release
    • Otherwise: Notes added to release_notes.md
  • Backport is not required
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • All required tests have been added/updated (unit tests, E2E tests)
  • Breaking change?
    • If yes:
      • Impact:
      • Migration guidance:

AI-assisted code disclosure (required)

Was an AI tool used? (select one)

  • No
  • Yes, AI helped write parts of this PR (e.g., GitHub Copilot)
  • Yes, an AI agent generated most of this PR

If AI was used:

  • Tool(s): GitHub Copilot
  • AI-assisted areas/files: TaskHubGrpcServer.cs, the in-process test-host README, OrchestrationHistoryTests.cs, and WorkerHistorySnapshotTests.cs.
  • What you changed after AI output: N/A; agent-authored implementation and tests. Human review is pending.

AI verification (required if AI was used):

  • I understand the code and can explain it
  • I verified referenced APIs/types exist and are correct
  • I reviewed edge cases/failure paths (timeouts, retries, cancellation, exceptions)
  • I reviewed concurrency/async behavior
  • I checked for unintended breaking or behavior changes

Testing

Automated tests

  • Result: Passed locally.
  • Focused regressions: 8/8 passed. Before the fix, 7 failed on retained snapshot counts and the small nonstreaming control passed.
  • InProcessTestHost.Tests, Release: 57/57 passed; no failures or skips.
  • InProcessTestHost, Release: net6.0, net8.0, and net10.0 builds passed with 0 errors and 84 nullable, obsolete-API, analyzer, and style warnings in unchanged code.
  • git diff --check origin/main...HEAD: passed.

The regressions cover active snapshot availability, partial and final responses, generic send failure, closed/disconnected streams, another active instance, an already-started reader, and the next episode's snapshot. Public-client tests verify actual worker streaming above 1 MiB, no retained snapshots before purge, queryable committed history, and successful purge on a reused host.

Manual validation (only if runtime/behavior changed)

  • Environment (OS, .NET version, components): Local automated runs used Windows, .NET SDK 10.0.401, net10.0 tests, the real localhost gRPC sidecar, and the in-memory store.
  • Steps + observed results: No separate manual run; the runtime checks described above are automated.
  • Evidence (optional): The owning tests include the real public-client reproduction and controlled episode-lifetime assertions.

Notes for reviewers

  • Scoped to standalone preview test infrastructure. No public SDK API, worker SDK, protobuf, serialization, or production-backend changes. Committed-history reads remain independent of worker replay snapshots.
  • Existing no-response timeout and disconnect/abandon behavior are outside this change.
  • Encoded protobuf size verifies the streaming threshold; it is not a managed-heap or RSS measurement.
  • Full-solution validation, DTS emulator tests, Azure Functions smoke tests, and CodeQL were not run locally. No hosted CI checks are claimed as passed.

Release each worker replay snapshot when its orchestration episode finishes or dispatch fails, while retaining it through history reads and partial responses. Preserve independently stored management history and purge behavior.

Add deterministic server lifetime coverage and public-client reused-host and ContinueAsNew regressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6bdf65c9-fecb-407f-ae60-016e81eb28c0
Copilot AI balanced review requested due to automatic review settings October 6, 2026 19:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The localized cleanup preserves active readers and committed history, with focused regression coverage and no identified blocking issues.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes retained worker-replay history snapshots in the in-process test host without changing public SDK behavior.

Changes:

  • Releases invocation-owned snapshots after the final response or dispatch failure.
  • Adds lifetime regressions and reused-host tests, including ContinueAsNew.
  • Documents snapshot lifetime separately from committed history.
File Description
test/​InProcessTestHost.Tests/​WorkerHistorySnapshotTests.cs Tests cleanup, partial responses, active readers, and episode isolation.
test/​InProcessTestHost.Tests/​OrchestrationHistoryTests.cs Tests host reuse, streaming, committed history, and purge.
src/​InProcessTestHost/​Sidecar/​Grpc/​TaskHubGrpcServer.cs Adds owner-scoped snapshot cleanup in finally.
src/​InProcessTestHost/​README.md Clarifies replay snapshot lifetime.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@YunchuWang
wangbill (YunchuWang) merged commit fb044a3 into main Oct 6, 2026
11 checks passed
@YunchuWang
wangbill (YunchuWang) deleted the yunchuwang-release-test-host-history-buffers branch October 6, 2026 21:05
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.

4 participants