How Replication works with bulk replace if some document was not changed

Hello! I’d like to know how replication works with bulk replace if some document was not changed. I know mongo does not replace document if new document is the same as old one. Will mongo replicate all bulk operations or only those which really updated on master?
For example I upsert 1000 documents like that:

var updates = doclist.Select(m => new ReplaceOneModel<MyClass>(filter.Eq(x => x.Id, m.Id), m) { IsUpsert = true }).ToList();
var res = await marketsCollection.BulkWriteAsync(updates, null, ct);

and as result I have res.ModifiedCount =1 (only one document was updated)
So only one document change will be replicated or mongo will send all bulk updates to replicas to apply them in replicas?

Replication is based on the oplog. In the first paragraph we can read:

If an operation do not create an entry in the oplog then this operation is not replicated.

1 Like

Is bulk operation is one operation for oplog? Or all operations in bulk is seporate operations and seporate records in oplog?

No. See details about updates to multiple documents

So it would seems that even a single updateMany results in multiple entries.

Oplog entries are at the document level.

Yes I saw this manual and this part in particular, but was still in doubt. Thank you.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.