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?
Garbage collection (in this context) means that an Actor object is removed from memory to free up resources. If the Actor has
StatePersistence.Persistedits state will be written to disk on each replica of the underlyingActorService. Even if you're not explicitly storing anything in theStateManager, a record of the Actor (usingActorIdas 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.
More info here.