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

Get rid of the `getPrevError` command

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.1.7
    • None
    • Fully Compatible
    • v4.0
    • Sharding 2018-12-17, Sharding 2018-12-31, Sharding 2019-01-14

    Description

      The getPrevError command is a command which allowed callers to do several writes with getLastError and offers the ability to read the last error which occurred and how many commands back it was. getLastError refers to result of the last write where getPreviousError refers to last error that happened.

      Example:

      db.foo.insert({_id:1})
      WriteResult({ "nInserted" : 1 })
      db.foo.insert({_id:1})
      WriteResult({
      	"nInserted" : 0,
      	"writeError" : {
      		"code" : 11000,
      		"errmsg" : "insertDocument :: caused by :: 11000 E11000 duplicate key error index: test.foo.$_id_  dup key: { : 1.0 }"
      	}
      })
      db.foo.insert({_id:2})
      WriteResult({ "nInserted" : 1 })
      db.foo.insert({_id:3})
      WriteResult({ "nInserted" : 1 })
      db.foo.insert({_id:4})
      WriteResult({ "nInserted" : 1 })
      db.getLastError()
      null   // last write did not have an error
      db.getPrevError()
      {  
      	"err" : "insertDocument :: caused by :: 11000 E11000 duplicate key error index: test.foo.$_id_  dup key: { : 1.0 }",
      	"code" : 11000,
      	"n" : 1,
      	"nPrev" : 4,   // last error was four commands ago
      	"ok" : 1
      }
      

      This functionality is not used by any MongoDB driver and with the availability of write commands and OP_MSG is not necessary as well, so we should remove it.

      Attachments

        Issue Links

          Activity

            People

              kimberly.tao@mongodb.com Kim Tao
              kaloian.manassiev@mongodb.com Kaloian Manassiev
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: