Idempotency means repeated application produces the same resulting state as a single application. MongoDB uses idempotent oplog operations so secondaries can replay writes consistently while replicating asynchronously. section 9.1.3
The oplog applies idempotency through ordered logical writes:
- The primary executes database operations and records successful data-changing writes in its oplog. section 9.1.3
- Secondaries receive and execute those operations asynchronously, using local oplog copies to track database state. section 9.1.3
- Writes that neither change data nor succeed do not generate oplog entries. section 9.1.3
Replayable delete operation
An oplog delete records the operation type, namespace, collection UUID, document _id, timestamp, election term, format version, and wall-clock time. Applying that recorded operation once or repeatedly leaves the target dataset in the same state. section 9.1.3
Listing 9.3 A single document from the oplog collection
{
op: 'd',
ns: ' sample_mflix.sessions',
ui: new UUID("99f8f10f-e144-4419-a543-da211dd1a2de"),
o: { _id: ObjectId("65b1a0a4edf7e1f8d9ccc396") },
ts: Timestamp({ t: 1710267182, i: 5 }),
t: Long("38"),
v: Long("2"),
wall: ISODate("2024-03-12T18:13:02.838Z")
},
Inspect a concrete oplog document showing a delete operation and its replay-relevant metadata. section 9.1.3
















