The implementation of getWriteLock in DefaultDOManager was changed a while ago to allow for improved ingest throughput:
However, since the write lock for an object is obtained after reading and deserializing an object, adding relationships to an object from multiple threads at the same time can result in lost updates, because a later thread may modify a datastream using stale data. Previously, if two threads tried to obtain a writer on the same object at the same time, an exception would be thrown.
A possible fix is to obtain the write lock before reading and deserializing the object. I've prepared a unit test and a small patch here: