Service fabric - manual deactivation of an actor for debugging / testing purposes

I am working on a Service Fabric project using ReliableActors with state. I save and delete things in the state of an actor and have some re-activation logic that I want to test.

Is there a way to manually deactivate or garbage collect an actor? I would optimally have the test data load into the actor, deactivate it, and then run some functions to ensure that the actor still works as intended.

+6
source share
2 answers

You can adjust the time when an actor is considered inactive to force frequent garbage collection. Code from the documentation:

ActorRuntime.RegisterActorAsync<MyActor>((context, actorType) => new ActorService(context, actorType, settings: new ActorServiceSettings() { ActorGarbageCollectionSettings = new ActorGarbageCollectionSettings(idleTimeoutInSeconds: 20, scanIntervalInSeconds:20) })) .GetAwaiter() .GetResult(); 

As you can see, there are two parameters: idleTimeoutInSeconds - after this, an actor who does nothing can be considered for deactivation; scanIntervalInSeconds - time interval during which the service fabric checks actors for their inactivity.

+3
source

If you mean deletion, when you say "deactivate", you can use the following:

 await myActorServiceProxy.DeleteActorAsync(actorToDelete, cancellationToken) 

The actor is activated the first time any of its methods is called. An actor is deactivated (garbage collected during Actors execution) if it is not used for a custom period of time. An actor and his condition can also be deleted manually at any time.

https://github.com/Azure/azure-content/blob/master/articles/service-fabric/service-fabric-reliable-actors-lifecycle.md

0
source

All Articles