简体   繁体   中英

why is the mongodb oplog is idempotent? Even for insert operation?

I am learning the replica set function of mongodb and when i read this article: replica set oplog

it said:

Each operation in the oplog is idempotent. That is, oplog operations produce the same results whether applied once or multiple times to the target dataset.

What does it mean? An insert or delete operation surely produce different result applying once than twice.

So maybe i am wrong or somebody explain it? Thanks!

An insert or delete operation surely produce different result applying once than twice.

You can't delete things twice. If you were to apply the same delete operation again, it would be a no-op.

As for the insert: it's been a while since I looked at oplog, but I'm quite sure that replicated insert operation includes value for _id . And so it too won't insert a second copy of a document (because _id must be unique)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM