Disclaimer This is all about me, so please do not crucify me if I am wrong. However, please correct me.
Why should they?
Assume true parallelism of the queries used. So, we have two requests arriving at the same time, and we will need to decide which one needs to be inserted into oplog first. The first one taking the lock will write first, right? There is also a problem. Suppose the first request is simple db.collection.update({_id:"foo"},{$set:{"bar":"baz"}}) , while the other request is more complex, and therefore for a proper assessment takes more time. Therefore, to prevent this, the lock had to be taken on arrival and released after recording the idempotent oplog record.
That's where I have to rely on my memory
However, queries are not applied in parallel. Requests are queued and evaluated in order of receipt. The database is blocked by the query application after starting the query optimizer. During this blocking, idempotent oplog requests are written to oplog. Since the databases are not interconnected, and only one query can be applied to the database at any given time, locking in the database is sufficient. At any time, two requests for changing data in one database cannot be applied simultaneously, so why should the lock be set to oplog? Apparently, the lock takes on a local database. However, since the lock is already taken on the data, I see no reason. * ScratchingMyHead *
Markus W Mahlberg
source share