Skip to content

[Journaling] Auto-retire & purge state machines#9684

Merged
ReubenBond merged 36 commits intodotnet:mainfrom
ledjon-behluli:retire-state-machines
Oct 31, 2025
Merged

[Journaling] Auto-retire & purge state machines#9684
ReubenBond merged 36 commits intodotnet:mainfrom
ledjon-behluli:retire-state-machines

Conversation

@ledjon-behluli
Copy link
Contributor

@ledjon-behluli ledjon-behluli commented Sep 17, 2025

Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond requested a review from Copilot October 23, 2025 03:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements automatic retirement and purging of state machines in the journaling system. When a state machine is no longer registered with the manager, it enters a grace period before being permanently removed, allowing for potential resurrection if re-registered within that timeframe.

Key Changes

  • Introduced StateMachineManagerOptions with configurable RetirementGracePeriod (default: 1 hour)
  • Implemented retirement tracking system that monitors unregistered state machines and purges them after the grace period
  • Added RetiredStateMachineVessel to buffer data for retired machines during the grace period, supporting resurrection

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Orleans.Journaling/StateMachineManagerOptions.cs New options class defining retirement grace period configuration
src/Orleans.Journaling/StateMachineManager.cs Core implementation of retirement tracking, vessel buffering, and purging logic
src/Orleans.Journaling/DurableDictionary.cs Made ApplyRemove internal and GetStorage virtual to support retirement tracker
src/Orleans.Journaling/HostingExtensions.cs Added StateMachineManagerOptions registration to DI container
test/Orleans.Journaling.Tests/StateMachineManagerTests.cs Comprehensive test covering full retirement lifecycle including grace period and resurrection
test/Orleans.Journaling.Tests/StateMachineTestBase.cs Updated test infrastructure to support TimeProvider injection and ManagerOptions
test/Orleans.Journaling.Tests/LogSegmentTests.cs Updated StateMachineManager instantiations with new constructor parameters
test/Orleans.Journaling.Tests/Orleans.Journaling.Tests.csproj Added Microsoft.Extensions.TimeProvider.Testing package reference
Orleans.slnx Cleaned up project type attributes

Copy link
Member

@ReubenBond ReubenBond left a comment

Choose a reason for hiding this comment

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

I left a couple of comments that I think we should address. Looks great, this is a very nice addition!

@ReubenBond
Copy link
Member

Ah, sorry, my fix to StateMachineManager caused a conflict

ledjon-behluli and others added 5 commits October 26, 2025 16:28
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ReubenBond
Copy link
Member

Can you rebase on main @ledjon-behluli?

egil and others added 4 commits October 26, 2025 21:47
…et#9696)

The `CreateIfNotExistsAsync` method's response will have a 409-statuscode if the table already exists and will always return the `TableItem` if the call is successful.
…image (dotnet#9699)

* Initial plan

* Fix ZooKeeper CI tests: correct service name and use specific image tag

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

* Use official ZooKeeper Docker image instead of bitnami

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>
* Fix Consul key format to comply with allowed characters

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

* Use custom encoding for Consul keys instead of URL encoding

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

* Simplify encoding logic to handle both IPv4 and IPv6

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

* Revert breaking changes and use older Consul version for tests

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>
…metry specification (dotnet#9703)

* Initial plan

* Remove explicit ActivityStatusCode.Ok per OpenTelemetry spec

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>
dependabot bot and others added 15 commits October 26, 2025 21:47
Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 9.0.303 to 9.0.305.
- [Release notes](https://github.com/dotnet/sdk/releases)
- [Commits](dotnet/sdk@v9.0.303...v9.0.305)

---
updated-dependencies:
- dependency-name: dotnet-sdk
  dependency-version: 9.0.305
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
fix potentiall NRE in the activation repartioner
* Timeout.InfiniteTimeSpan is not allowed for reminders

* Specifically check for InfiniteTimeSpan to make clear it's usage is not allowed (and to allow for an eventual future change of the InfiniteTimeSpan value)

---------

Co-authored-by: Jerremy Koot <jerremy.koot@gmail.com>
Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 9.0.305 to 9.0.306.
- [Release notes](https://github.com/dotnet/sdk/releases)
- [Commits](dotnet/sdk@v9.0.305...v9.0.306)

---
updated-dependencies:
- dependency-name: dotnet-sdk
  dependency-version: 9.0.306
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Changed isSynchronousAdoNetImplementation from true to false for PostgreSQL thanks to updates in Npgsql 8.0.
npgsql/npgsql#1130
Add missing validation for the Nats stream provider
…eduler (dotnet#9726)

* ActivationDataActivatorProvider: always run grain constructor on ActivationTaskScheduler

* ActivationDataActivatorProvider: always run grain constructor on ActivationTaskScheduler
@ReubenBond ReubenBond added this pull request to the merge queue Oct 31, 2025
Merged via the queue into dotnet:main with commit 181f9f8 Oct 31, 2025
29 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

Comments