Fix doc creation race condition

two doc objects could be created if two clients open the doc simultaneously