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

2.6 shell silently ignores duplicate key error when connecting to 2.4 server

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.0-rc0
    • Component/s: Shell
    • ALL

      When connecting with a 2.6.0-rc0 mongo shell to a 2.4.9 server and causing a duplicate key error due to a unique index, the insert or update is silently ignored and no error is printed. This is different behavior to both 2.4.9 shell with 2.4.9 server and 2.6.0 shell with 2.6.0 server.

      Behavior with 2.4.9 shell and server:

      MongoDB shell version: 2.4.9
      connecting to: test
      > db.serverStatus()['version']
      2.4.9
      > db.moo.update({a: 2}, {a: 1})
      E11000 duplicate key error index: test.moo.$a_1  dup key: { : 1.0 }
      

      Behavior with 2.6.0-rc0 shell and server:

      MongoDB shell version: 2.6.0-rc0
      connecting to: test
      > db.serverStatus()['version']
      2.6.0-rc0
      > db.moo.update({a: 2}, {a: 1})
      WriteResult({
      	"nMatched" : 0,
      	"nUpserted" : 0,
      	"nModified" : 0,
      	"writeError" : {
      		"code" : 11000,
      		"errmsg" : "E11000 duplicate key error index: test.moo.$a_1  dup key: { : 1.0 }"
      	}
      })
      

      Behavior with 2.6.0-rc0 shell, 2.4.9 server:

      MongoDB shell version: 2.6.0-rc0
      connecting to: test
      > db.serverStatus()['version']
      2.4.9
      > db.moo.update({a: 2}, {a: 1})
      > db.moo.update({a: 2}, {a: 1}); db.getLastError()
      E11000 duplicate key error index: test.moo.$a_1  dup key: { : 1.0 }
      

      The error only gets printed when calling db.getLastError() directly on the same line.

            Assignee:
            Unassigned Unassigned
            Reporter:
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: