hollywood icon indicating copy to clipboard operation
hollywood copied to clipboard

Fix race condition during actor startup sequence

Open troygilman opened this issue 1 year ago • 3 comments

This PR is intended to fix the issue #159.

The race condition occurs when a msg is sent to an actor while it is still processing the actor.Initialized or actor.Started msg. This can easily happen when loading some state from a db when processing one of these startup msgs.

I am proposing that the inbox only be started after the actor has processed all the startup msgs. This requires some changes to the inbox:

  • initialize the procStatus to "stopped"
  • when Start() is called, transition to "starting" and then "idle" status, and then call schedule() to process queued msgs

I have added a test case to test the proper ordering of msgs under this scenario.

troygilman avatar Jun 12 '24 17:06 troygilman

@anthdm

troygilman avatar Jun 17 '24 15:06 troygilman

@troygilman0 Thanks for this! Very good work.

anthdm avatar Jun 23 '24 11:06 anthdm

@anthdm please review

troygilman avatar Jul 08 '24 15:07 troygilman

@tprifti Can your add your review as well?

anthdm avatar Aug 18 '24 06:08 anthdm