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

Upserts to config servers incorrectly set "n" to 0 in getlasterror.

    • ALL
    • Hide

      Set up a sharded cluster, and point a shell at a mongos instance.

      > use admin;
      > db.foo.drop();
      > db.foo.update({_id:1}, {$set:{b:1}}, true); res = db.getLastErrorObj();
      Updated 0 record(s) in 136ms
      {
      	"singleShard": "ubuntu:30001,ubuntu:30002,ubuntu:30003",
      	"n": 0,
      	"lastOp": {
      		"t": 1383168612,
      		"i": 1
      	},
      	"connectionId": 8,
      	"err": null,
      	"ok": 1
      }
      > db.foo.find()
      { "_id": 1, "b": 1 }
      
      Show
      Set up a sharded cluster, and point a shell at a mongos instance. > use admin; > db.foo.drop(); > db.foo.update({_id:1}, {$set:{b:1}}, true); res = db.getLastErrorObj(); Updated 0 record(s) in 136ms { "singleShard": "ubuntu:30001,ubuntu:30002,ubuntu:30003", "n": 0, "lastOp": { "t": 1383168612, "i": 1 }, "connectionId": 8, "err": null, "ok": 1 } > db.foo.find() { "_id": 1, "b": 1 }
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      The object returned by the getlasterror command on an upsert that converts to an insert should report n = 1. However, when the upsert is targeted via a mongos at a collection on a config server, it instead sets n = 0. This is an error.

            Assignee:
            spencer@mongodb.com Spencer Brody (Inactive)
            Reporter:
            schwerin@mongodb.com Andy Schwerin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: