1
votes

For GDPR reasons, I need to ensure that I don't store customer data which I no longer need. When looking at Service Fabric Actors, I am uncertain what "garbage collection" really means.

[StatePersistence(StatePersistence.Persisted)]
internal class Actor1 : Actor, IActor1
{
    public Actor1(ActorService actorService, ActorId actorId) 
        : base(actorService, actorId)
    {
    }

    public Task PingAsync(CancellationToken cancellationToken)
    {
        return Task.CompletedTask;
    }
}
IActorService actorServiceProxy = ActorServiceProxy.Create(
    new Uri("fabric:/MyApp/MyActorService"), partitionKey);
// ...
do
{
    PagedResult<ActorInformation> page = await actorServiceProxy.GetActorsAsync(continuationToken, cancellationToken);
// ...

When enumerating actor instances in a test environment, it seemed to me like actor information was kept for at least 2 months, even though the actors did not have any stored state.

I found multiple articles mentioning that I will need to delete the actors manually if they have leftover state, but in my case the only "state" would be the fact that the actorId "exists". If I were to use something sensitive like a user email address as an actorId, would Service Fabric ever delete the information about the actorId by itself?

1

1 Answers

0
votes

Garbage collection (in this context) means that an Actor object is removed from memory to free up resources. If the Actor has StatePersistence.Persisted its state will be written to disk on each replica of the underlying ActorService. Even if you're not explicitly storing anything in the StateManager, a record of the Actor (using ActorId as key) will exist.

It's up to you as a developer to manage the lifecycle of Actor state. Deleting an Actor explicitly, also deletes its state.

Garbage collection of deactivated actors only cleans up the actor object, but it does not remove data that is stored in an actor's State Manager. When an actor is reactivated, its data is again made available to it through the State Manager. In cases where actors store data in State Manager and are deactivated but never reactivated, it may be necessary to clean up their data.

More info here.