The ReferenceCountingAssertionError in your case is caused by the use of max_calls=2 on your remote function. When a Ray worker reaches its max_calls limit, it is terminated and any objects it owns (including ObjectRefs it created) are also deleted—even if other tasks or actors still hold references to those objects. This leads to the ReferenceCountingAssertionError when you try to access an ObjectRef whose owner (the worker) has already exited (GitHub issue 18456, Ray Discourse: getting reference counting assertion error).
Workaround:
To avoid this, you should ensure that the owner of the ObjectRef is a long-lived actor (such as your PlasmaStoreActor) and that the ObjectRef is passed to and stored by this actor before the worker that created it exits. Specifically, after creating the ObjectRef with ray.put(data, _owner=actor), call a method on the actor to store the reference, and only then allow the worker to exit. This ensures the reference count is properly updated and the object is not prematurely deleted. Avoid using max_calls on remote functions that create and return ObjectRefs unless you are certain the references will not be needed after the worker exits.
Would you like a code example of this pattern?
Sources:
Hint: Mention @RunLLM in the post for followups.