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

Detect writeConcernError from findAndModify() shell helper

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Won't Fix
    • 3.2.0
    • None
    • JavaScript, Shell
    • Server Tooling & Methods

    Description

      When using the shell helper db.collection.findAndModify(), you cannot determine if a write concern error has occurred. You can only do so via the dbcommand version of findAndModify:

      replset:PRIMARY> db.products.find()
      { "_id" : ObjectId("568eb38f3a04b65e35ff642c"), "sku" : 1, "field" : 9 }
      replset:PRIMARY> db.runCommand( { findAndModify: "products", query: { sku: 1 }, update: { $inc: { field: 1 } }, writeConcern: { w: 3, wtimeout: 5000 } } )
      {
              "lastErrorObject" : {
                      "updatedExisting" : true,
                      "n" : 1
              },
              "value" : {
                      "_id" : ObjectId("568eb38f3a04b65e35ff642c"),
                      "sku" : 1,
                      "field" : 9
              },
              "writeConcernError" : {
                      "code" : 64,
                      "errmsg" : "waiting for replication timed out"
              },
              "ok" : 1
      }
      replset:PRIMARY> db.products.findAndModify( { query: { sku: 1 }, update: { $inc: { field: 1 } }, writeConcern: { w: 3, wtimeout: 5000 } } )
      { "_id" : ObjectId("568eb38f3a04b65e35ff642c"), "sku" : 1, "field" : 10 }
      

      Attachments

        Issue Links

          Activity

            People

              backlog-server-stm Backlog - Server Tooling and Methods (STM) (Inactive)
              kyle.suarez@mongodb.com Kyle Suarez
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: