I am seeing some unexplained behavior when working with a Fully Sync’d Realm Object Server. Let me give a 10k foot overview first.
The use case is a multi-user ‘Tasks’ app where the UI is just a list of tasks and user names who is responsible for each task. The task details can be viewed and edited in another window (like Sheet or a detail view)
For this example when a task detail view opens, the first thing that happens is realm.beginWrite to put realm in a write transaction. Then when the details window closes with realm.commitWrite.
Overlooking that app design for a minute, that should put Realm inside a transaction the whole time the details view is open.
But here’s what we are seeing.
If User A opens a task detail view and then user B opens a task detail view, then user B closes it, their client crashes with
The Realm is already in a write transaction
That’s to be expected and the call throws, so it can be handled.
However, Client A closes their window and they also get a crash with the same error.
and here’s the concerning behavior. Sometimes when Client A starts a write transaction, Client B can add, edit delete objects at the same time.
If Realm is ACID compliant, we shouldn’t be seeing that behavior as that’s not really atomic: where a transaction is either succeeds completely, or fails completely. It’s also not Isolation as it seems the transactions are not executed sequentially; one client accessing a Realm within a transaction and the other is accessing (writing/deleting) the exact same data - even editing the same object
This is pretty easy to duplicate in code and I am probably overlooking a mechanic.