Page Tree Operations Locks
Explanation
When long tree refactoring operations are executed on a Page or a Page tree, such as a rename of a whole subtree, a copy or a delete of a Page and its children, it is important that other operations (of the same type) are not executed on those Pages at the same time, in order to prevent unexpected results.
In order to achieve this, a mechanism is used to "lock" a subtree while an operation is executed on it, and block all other refactoring operations that may impact the same Page tree. For example, it's not possible to delete a subtree while a move for the same Page tree or a parent of it is being executed. The rule of this lock mechanism is that if a Page tree is locked, no other operation that would need to lock the same Page tree, a supertree or a subtree of it can be executed.
For the 3 refactoring operations, the locks are as follows:
- delete operation: a lock on the Page tree to be deleted is placed;
- move / rename operation: a lock is placed on the first common ancestor of the impacted Page paths; "first" here is in the order from the bottom of the tree to the top, it has the meaning of "lowest" in the hierarchy, the closest to the Pages being moved;
- copy operation: as for move / rename, a lock is placed on the first common ancestor of the paths involved (source and destination).
Note: these kind of operations can end up being paused pending answers from the user (for example, in the case of a move, a question can be asked about overwriting a destination Page). If this happens, the operation is considered to still be running, and thus the lock it places is still active and can block other operations on the same Page tree.
FAQ
Why are all operations on the wiki blocked while a top level Page is being moved ?
As per the explanation above, a move operation will place a lock on the closest common ancestor of the Pages being moved. For a top level Page (a "root" of the wiki), the "parent" is the wiki, so this will place a lock on the whole wiki. Any other operation would need to lock the same Page tree or a subtree of the whole wiki, so all other operations are blocked pending finalization of this move.