Parallel insert into MongoDB -


what happens, if 2 clients, working 1 mongodb instance, perform , insert operation @ same time without «forceserverobjectid: true». possible generated equal objectids, there may conflict?

there implied unique index on _id field of every collection makes impossible 2 objects same _id exist in same collection.

when 2 objects same _id value stored collection.save, 1 document replace other.

when stored collection.insert, 1 of inserts fail duplicate key error.

but note mongodb objectids include 24bit machine-id. makes impossible 2 clients generate same id, unless have same machine-id. , it's unlikely. that, of course, applies when let mongodb driver (or shell) auto-generate objectids. mongodb allows use value of type value _id field when set manually. when (you shouldn't), it's responsibility ensure uniqueness.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -