In this article
Async actor methods can interleave at await points; threaded actors introduce another concurrency model, and neither makes compound state transitions atomic.
An actor checks that a partition has no assigned worker, awaits a remote lookup and then records an assignment. Another invocation passes the same check during the await. A single actor process has not made this multi-step transition atomic. The invariant must survive the actor’s chosen concurrency model.
Write the invariant before the method
Describe what must remain true, such as one accepted assignment per partition and configuration revision. Identify the state read before waiting and changed afterward. Preserve operation and partition identities in observations. The coherent configuration guide addresses a related state boundary during Serve updates; this case instead concerns competing Core actor methods that can observe and change the same mutable state within one process.
Identify the execution model
The actor concurrency guide describes async methods multiplexed on a single event loop and a separate threaded model. A single event-loop thread does not prevent another coroutine from progressing when the current method awaits. A threaded actor adds simultaneously active threads, including native work that may release the interpreter lock. Record the effective model and concurrency setting rather than deriving safety from the word actor or the presence of one operating-system process.
Review ordering without overclaiming it
The actor ordering reference distinguishes synchronous actor ordering from async and threaded execution. Do not rely on submission order to make an awaited read-modify-write indivisible. Distinguish start order, state-commit order and response order in the trace. A method returning earlier does not necessarily own an earlier logical transition. If the application requires order, express it through its state protocol rather than assuming callers share one serialized submission history.
Choose an explicit protected boundary
Possible designs include recording a provisional assignment before waiting, validating the state again before commit, or using a synchronization primitive compatible with the execution model. Specify timeout and cancellation cleanup for provisional state. Avoid holding an unsuitable blocking primitive across an await. The concurrency guide prohibits blocking ray.get or ray.wait inside async actor methods because they block the event loop. The shared-lock scope guide explains why lock ownership and protected resource scope must match.
Force the interleaving in a fixture
Use disposable partition identities and a controlled await point so competing calls both reach the vulnerable interval. Record observed state, provisional ownership, final commit and returned results. Include a failed lookup and cancellation after provisional assignment. Acceptance verifies the invariant and cleanup under those schedules, rather than merely seeing each method return in isolation. This proposed fixture does not claim a measured race frequency or a completed concurrency test of an existing deployment.
Preserve the distributed boundary
A local actor invariant does not automatically protect a separate database or another actor performing external writes. Restarts and method retries also require durable state and effect handling. Document where the authoritative assignment lives and how a stale caller is rejected there. The useful result is a defined transition protocol under the selected concurrency model. It is not an exactly-once promise, a universal ordering guarantee or evidence that increasing max_concurrency makes CPU-bound Python work run faster.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.