Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-31435

Creating an index through applyOps is not replicated

    • Fully Compatible
    • ALL
    • Hide

      On a 1-node replica set:

      > db.createCollection("c")
      > db.getCollectionInfos()
      [
      	{
      		"name" : "c",
      		"type" : "collection",
      		"options" : {
      			
      		},
      		"info" : {
      			"readOnly" : false,
      			"uuid" : UUID("44dd4cdb-4889-43e1-bd2c-f7375d92c8f8")
      		},
      		"idIndex" : {
      			"v" : 2,
      			"key" : {
      				"_id" : 1
      			},
      			"name" : "_id_",
      			"ns" : "test.c"
      		}
      	}
      ]
      > db.runCommand({applyOps: [{op: "c", ns: "test.c", ui: UUID("44dd4cdb-4889-43e1-bd2c-f7375d92c8f8"), o: {createIndexes: "c", v: 2, key: {a: 1}, name: "a_1"}}]})
      > db.c.getIndexes()
      [
      	{
      		"v" : 2,
      		"key" : {
      			"_id" : 1
      		},
      		"name" : "_id_",
      		"ns" : "test.c"
      	},
      	{
      		"v" : 2,
      		"key" : {
      			"a" : 1
      		},
      		"name" : "a_1",
      		"ns" : "test.c"
      	}
      ]
      > use local
      > db.oplog.rs.find().pretty()
      {
      	"ts" : Timestamp(1507299002, 1),
      	"h" : NumberLong("4324269916467276683"),
      	"v" : 2,
      	"op" : "n",
      	"ns" : "",
      	"o" : {
      		"msg" : "initiating set"
      	}
      }
      {
      	"ts" : Timestamp(1507299004, 1),
      	"t" : NumberLong(1),
      	"h" : NumberLong("8480815567193554397"),
      	"v" : 2,
      	"op" : "n",
      	"ns" : "",
      	"wall" : ISODate("2017-10-06T14:10:04.886Z"),
      	"o" : {
      		"msg" : "new primary"
      	}
      }
      {
      	"ts" : Timestamp(1507299004, 2),
      	"t" : NumberLong(1),
      	"h" : NumberLong("1378629489624595755"),
      	"v" : 2,
      	"op" : "c",
      	"ns" : "config.$cmd",
      	"ui" : UUID("87ad6081-0db2-46cb-9d00-149ecb46d6d1"),
      	"wall" : ISODate("2017-10-06T14:10:04.952Z"),
      	"o" : {
      		"create" : "transactions",
      		"idIndex" : {
      			"v" : 2,
      			"key" : {
      				"_id" : 1
      			},
      			"name" : "_id_",
      			"ns" : "config.transactions"
      		}
      	}
      }
      {
      	"ts" : Timestamp(1507299029, 1),
      	"t" : NumberLong(1),
      	"h" : NumberLong("-7494492021434764735"),
      	"v" : 2,
      	"op" : "c",
      	"ns" : "admin.$cmd",
      	"ui" : UUID("c46411b5-27fa-4a07-869f-0ab592b27245"),
      	"wall" : ISODate("2017-10-06T14:10:29.769Z"),
      	"o" : {
      		"create" : "system.keys",
      		"idIndex" : {
      			"v" : 2,
      			"key" : {
      				"_id" : 1
      			},
      			"name" : "_id_",
      			"ns" : "admin.system.keys"
      		}
      	}
      }
      {
      	"ts" : Timestamp(1507299029, 2),
      	"t" : NumberLong(1),
      	"h" : NumberLong("-3000009358249085337"),
      	"v" : 2,
      	"op" : "i",
      	"ns" : "admin.system.keys",
      	"ui" : UUID("c46411b5-27fa-4a07-869f-0ab592b27245"),
      	"wall" : ISODate("2017-10-06T14:10:29.769Z"),
      	"o" : {
      		"_id" : NumberLong("6473799927473373186"),
      		"purpose" : "HMAC",
      		"key" : BinData(0,"ysjEJXM2UXNCJ9GepIlvYuvq+KM="),
      		"expiresAt" : Timestamp(1515075004, 0)
      	}
      }
      {
      	"ts" : Timestamp(1507299029, 3),
      	"t" : NumberLong(1),
      	"h" : NumberLong("4654173349023495145"),
      	"v" : 2,
      	"op" : "i",
      	"ns" : "admin.system.keys",
      	"ui" : UUID("c46411b5-27fa-4a07-869f-0ab592b27245"),
      	"wall" : ISODate("2017-10-06T14:10:29.783Z"),
      	"o" : {
      		"_id" : NumberLong("6473799927473373187"),
      		"purpose" : "HMAC",
      		"key" : BinData(0,"GVzdBk6CjLMjVMo9aZId1oBxOb4="),
      		"expiresAt" : Timestamp(1522851004, 0)
      	}
      }
      {
      	"ts" : Timestamp(1507299095, 1),
      	"t" : NumberLong(1),
      	"h" : NumberLong("2281830126279321321"),
      	"v" : 2,
      	"op" : "c",
      	"ns" : "test.$cmd",
      	"ui" : UUID("44dd4cdb-4889-43e1-bd2c-f7375d92c8f8"),
      	"wall" : ISODate("2017-10-06T14:11:35.888Z"),
      	"o" : {
      		"create" : "c",
      		"idIndex" : {
      			"v" : 2,
      			"key" : {
      				"_id" : 1
      			},
      			"name" : "_id_",
      			"ns" : "test.c"
      		}
      	}
      }
      
      Show
      On a 1-node replica set: > db.createCollection( "c" ) > db.getCollectionInfos() [ { "name" : "c" , "type" : "collection" , "options" : { }, "info" : { "readOnly" : false , "uuid" : UUID( "44dd4cdb-4889-43e1-bd2c-f7375d92c8f8" ) }, "idIndex" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" , "ns" : "test.c" } } ] > db.runCommand({applyOps: [{op: "c" , ns: "test.c" , ui: UUID( "44dd4cdb-4889-43e1-bd2c-f7375d92c8f8" ), o: {createIndexes: "c" , v: 2, key: {a: 1}, name: "a_1" }}]}) > db.c.getIndexes() [ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" , "ns" : "test.c" }, { "v" : 2, "key" : { "a" : 1 }, "name" : "a_1" , "ns" : "test.c" } ] > use local > db.oplog.rs.find().pretty() { "ts" : Timestamp(1507299002, 1), "h" : NumberLong( "4324269916467276683" ), "v" : 2, "op" : "n" , "ns" : "", "o" : { "msg" : "initiating set" } } { "ts" : Timestamp(1507299004, 1), "t" : NumberLong(1), "h" : NumberLong( "8480815567193554397" ), "v" : 2, "op" : "n" , "ns" : "", "wall" : ISODate( "2017-10-06T14:10:04.886Z" ), "o" : { "msg" : " new primary" } } { "ts" : Timestamp(1507299004, 2), "t" : NumberLong(1), "h" : NumberLong( "1378629489624595755" ), "v" : 2, "op" : "c" , "ns" : "config.$cmd" , "ui" : UUID( "87ad6081-0db2-46cb-9d00-149ecb46d6d1" ), "wall" : ISODate( "2017-10-06T14:10:04.952Z" ), "o" : { "create" : "transactions" , "idIndex" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" , "ns" : "config.transactions" } } } { "ts" : Timestamp(1507299029, 1), "t" : NumberLong(1), "h" : NumberLong( "-7494492021434764735" ), "v" : 2, "op" : "c" , "ns" : "admin.$cmd" , "ui" : UUID( "c46411b5-27fa-4a07-869f-0ab592b27245" ), "wall" : ISODate( "2017-10-06T14:10:29.769Z" ), "o" : { "create" : "system.keys" , "idIndex" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" , "ns" : "admin.system.keys" } } } { "ts" : Timestamp(1507299029, 2), "t" : NumberLong(1), "h" : NumberLong( "-3000009358249085337" ), "v" : 2, "op" : "i" , "ns" : "admin.system.keys" , "ui" : UUID( "c46411b5-27fa-4a07-869f-0ab592b27245" ), "wall" : ISODate( "2017-10-06T14:10:29.769Z" ), "o" : { "_id" : NumberLong( "6473799927473373186" ), "purpose" : "HMAC" , "key" : BinData(0, "ysjEJXM2UXNCJ9GepIlvYuvq+KM=" ), "expiresAt" : Timestamp(1515075004, 0) } } { "ts" : Timestamp(1507299029, 3), "t" : NumberLong(1), "h" : NumberLong( "4654173349023495145" ), "v" : 2, "op" : "i" , "ns" : "admin.system.keys" , "ui" : UUID( "c46411b5-27fa-4a07-869f-0ab592b27245" ), "wall" : ISODate( "2017-10-06T14:10:29.783Z" ), "o" : { "_id" : NumberLong( "6473799927473373187" ), "purpose" : "HMAC" , "key" : BinData(0, "GVzdBk6CjLMjVMo9aZId1oBxOb4=" ), "expiresAt" : Timestamp(1522851004, 0) } } { "ts" : Timestamp(1507299095, 1), "t" : NumberLong(1), "h" : NumberLong( "2281830126279321321" ), "v" : 2, "op" : "c" , "ns" : "test.$cmd" , "ui" : UUID( "44dd4cdb-4889-43e1-bd2c-f7375d92c8f8" ), "wall" : ISODate( "2017-10-06T14:11:35.888Z" ), "o" : { "create" : "c" , "idIndex" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" , "ns" : "test.c" } } }
    • Storage 2017-10-23, Storage 2017-11-13

      Running applyOps with a createIndexes-style oplog entry (which is produced in featureCompatibilityVersion 3.6) does not produce an oplog entry, so it is not replicated.

            Assignee:
            maria.vankeulen@mongodb.com Maria van Keulen
            Reporter:
            tess.avitabile@mongodb.com Tess Avitabile (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: