Search code examples
azureactorazure-service-fabricstateful

Diagnosing Azure stateful actors


I'm still trying to get my mind around Azure Service Fabric Stateful Actors. So, my (current) problem is best put into an example like this:

  • I've got a helpdesk system, where each ticket is a stateful actor. The actor knows about the state it's in (posted, dealt with, rejected, ...), can access the associated data and all that.
  • I find I have made a mistake and a bunch of those 50.000 tickets are in the wrong state. So, I need to
    • fix the code
    • publish the solution
    • fix the data content of a subset of those 50.000 actors.

Now, how can I query the state of those actors, like "give me each actor that is in "rejected" and belongs to a user whose name starts with a german ümlaut"? How can I then patch the state data of those actors?

Do I really have to add a query method to each actor and wake up each single actor? Or is there a way to query those state dictionaries outside of the actors sitting on top of them?


Solution

  • The short answer is yes, in a situation like that you'd have to wake up each single actor (eventually).

    If you are already in that state, I think JoshL's suggestion makes sense.

    To avoid this sort of situations, you could keep an index dictionary in a stateful service, holding the information you'll want to query on e.g. the actor id and the status (posted, dealt with, etc.). You then only have to wake up those actors that are relevant.

    There are two approaches you can take for that:

    • Have the stateful service direct the flow of information - be responsible for updating the index dictionary and telling actors what to do (e.g. change status).
    • Have the actors responsible for notifying the stateful service for state updates (this could be done periodically through reminders for example).