[DOCS-2158] Clarify applyOps Oplog behavior Created: 28/Oct/13  Updated: 11/Jan/17  Resolved: 04/Sep/14

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: 01112017-cleanup

Type: Task Priority: Major - P3
Reporter: Philipp Heinze Assignee: Sam Kleinman (Inactive)
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 10 years, 16 weeks, 2 days ago

 Description   

Please explicitly mention that the applyOps operation doesn't add the given Oplog Records to the local Oplog.

Having two nodes with in different Clusters and executing this:

  • aabb:PRIMARY> db.collection.save( {b:1}

    )

    • Oplog Record

       { "ts" : Timestamp(1382985958, 1), "h" : NumberLong("-1797539322905744578"), "v" : 2, "op" : "i", "ns" : "test.collection", "o" : { "_id" : ObjectId("526eb0e682a153834ab771e8"), "b" : 1 } }

  • Executing the oplog record on second node
    • Command

      bbbb:PRIMARY> use local
      switched to db local
      bbbb:PRIMARY> db.runCommand({"applyOps":[{ "ts" : Timestamp(1382985958, 1), "h" : NumberLong("-1797539322905744578"), "v" : 2, "op" : "i", "ns" : "test.collection", "o" : { "_id" : ObjectId("526eb0e682a153834ab771e8"), "b" : 1 } }]})
      { "applied" : 1, "results" : [ true ], "ok" : 1 }

Does not add the oplog record to node twos Oplog, which I would expect to happen if this node is replicated as well.

bbbb:PRIMARY> db.oplog.rs.find()
{ "ts" : Timestamp(1382984560, 1), "h" : NumberLong(0), "v" : 2, "op" : "n", "ns" : "", "o" : { "msg" : "initiating set" } }



 Comments   
Comment by Philipp Heinze [ 28/Oct/13 ]

I just saw that the Oplog record isn't created if I execute the command for the local db, but it's created if I execute it for some other db:

bbbb:PRIMARY> db.runCommand({"applyOps":[{ "ts" : Timestamp(1382985958, 1), "h" : NumberLong("-1797539322905744578"), "v" : 2, "op" : "i", "ns" : "test.collection", "o" : { "_id" : ObjectId("526eb0e682a153834ab771e8"), "b" : 1 } }]})
{ "applied" : 1, "results" : [ true ], "ok" : 1 }
bbbb:PRIMARY> use local
switched to db local
bbbb:PRIMARY> db.oplog.rs.find()
{ "ts" : Timestamp(1382984560, 1), "h" : NumberLong(0), "v" : 2, "op" : "n", "ns" : "", "o" : { "msg" : "initiating set" } }
{ "ts" : Timestamp(1382987681, 1), "h" : NumberLong("2662222984365773812"), "v" : 2, "op" : "c", "ns" : "test.$cmd", "o" : { "applyOps" : [ 	{ 	"ts" : Timestamp(1382985958, 1), 	"h" : NumberLong("-1797539322905744578"), 	"v" : 2, 	"op" : "i", 	"ns" : "test.collection", 	"o" : { 	"_id" : ObjectId("526eb0e682a153834ab771e8"), 	"b" : 1 } } ] } }

Generated at Thu Feb 08 07:42:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.