Erwan Rouchetchanged title from Stale read on CreateElementParent & CreateElementParents to Stale read on CreateElementParent & CreateElementTranscriptions
changed title from Stale read on CreateElementParent & CreateElementParents to Stale read on CreateElementParent & CreateElementTranscriptions
I updated my local backend config to add the existing database as a replica, so that I don't have to change anything in the architecture and I can use manage.py {shell,runserver}_plus --print-sql --print-sql-location to troubleshoot and see which queries are going through the replica.
Running CreateElementParent twice or running CreateElement with a parent + CreateElementParent can cause a stale read in which the first parent is just replaced by the second parent;
Running Element.add_parent in anyway with an element whose type or paths have not yet replicated could cause duplicate ElementPath orderings, which might be why we have so many duplicates detected in #762 (closed);
Moving a parent element immediately after adding children to it might result in the child elements not being properly moved because their paths have not yet been replicated;
Calling DestroyElementParent immediately after CreateElementParent might not delete the parent if the parent path has not yet been replicated, and no error will be thrown;
Calling DestroyElementParent immediately after CreateElementParent on an element that already had at least one parent might cause its child elements to be cut off from the grandparents, as if the element no longer has any parents;
Calling DestroyElementParent immediately after CreateElementParent on an element that already had at least one parent might just not update the child elements at all because their paths might not be replicated yet.
For CreateElementTranscriptions : This endpoint does not use Element.add_parent, it creates the paths itself in bulk, so the stale read has to be somewhere else. I will make a separate MR tomorrow as more investigation is required, but I'm already pretty sure where a seventh stale read is, I just need to test it, and there might be other stale reads in other similar endpoints.