Hey!
Where does the MongoDB driver in PHP get the machine ID part of the
ObjectID from? Would PHP workers running on the same physical machine
get the same MachineID part? I'm using OpenVZ, which is a OS-level
"virtualization" with zero performance overhead. OpenVZ simply
partitions (like partitions on HDDs) the host operating system into
several parts, each with it's own isolated processes (and PIDs).
Processes of all the running VPSs can be seen from the host system.
All the PIDs are unique when looking from host system, but some PIDs
of PHP processes can be identical if you're running several VPSs and
looking from the VPS (which Mongo driver will). Thats because each
process has 2 PIDs, 1 real (visible to host only) and 1 virtual (only
visible from inside of that VPS). You can have the same virtual PID
shared between several processes, as long as they're in different
VPSs.
So let's say we're in the same 1-second time window, same machine and
have a PID collision between 2 PHP workers, each running in separate
VPS. I presume the 3-byte counter starts from the same position every
time. If I'm correct, this would result in the same ObjectID being
generated by the both PHP workers, causing a collision.
The only solution I see to this problem (and keep using ObjectID) is
running insert() with safe mode enabled and if a collision is
detected, generate another ObjectID, which will increase the counter
and try inserting again.
Happy day,
Matic
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to
mongod...@googlegroups.com.
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/mongodb-user?hl=en.