Working with replicas is not completely foolproof. In the debugging build, the Core tries to check all operations with replicas and throws an exception whenever programmer tries to perform an illegal operation. Some of these tests are expensive and are not done in the release build.
The following operations are illegal:
Referencing replicas from strong pointers, unless the pointer is owned by a replica.
Writing to properties of a replica.
Reading unitialized properties of a replica (properties that are not replicated because of the value of their repflags property attribute are unitialized).
Using synchronous RPC from method called on a replica.
The following operations are potentially dangerous:
Calling a non-const method of a replica. It will probably write to the replica.
Calling a const method of a replica. It may still write to properties of other objects in replication group of the replica, but you should probably not mark such methods as const. The method may try to construct strong pointer to the replica (this), or perform another illegal operation. Const methods may try to affect the simulation in any way - create and destroy other objects, migrate them, etc. It's recommended to add hope( !is_replica() ); to all const methods that can't be called on replicas, and document that.
Using synchronous RPC while working with replicas, because their state may change in any way during the call. They may be updated (which may be a problem if you iterate over a replicated structure), become inconsistent, or even be destroyed by the Core. There is no way to pin a replica, and such operation won't be implemented in the future versions of the Massiv, because it could stall both replication and migration protocols.
Working with inconsistent replicas, obviously.
The following operations are safe:
Replica-optimized SRPC (see Section 8.5.2, “Synchronous RPC Optimizations”). The call will not be performed locally if the replica of the callee object is inconsistent.
Calling method deliver_asap_to() of an Object with parameter can_deliver_to_replica set to true. It will never deliver the object to an inconsistent replica.
![]() | Warning |
---|---|
The lists above are not exhaustive. |