Lock transitive_closure table to prevent simultaneous writes, due to a potential issue where a node acquires ancestors and descendants at the same time