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

reIndex command ignores writeConcern

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.4
    • Affects Version/s: 3.5.2
    • Component/s: Index Maintenance
    • Fully Compatible
    • ALL
    • Hide

      Using an older version of the shell (one that doesn't use OP_COMMAND?):

      rs:PRIMARY> db.test.find()
      { "_id" : 1 }
      rs:PRIMARY> db.test.getIndexes()
      [
              {
                      "v" : 2,
                      "key" : {
                              "_id" : 1
                      },
                      "name" : "_id_",
                      "ns" : "test.test"
              }
      ]
      rs:PRIMARY> db.runCommand({ reIndex : "test", writeConcern : { w : 9 } })
      {
              "nIndexesWas" : 1,
              "nIndexes" : 1,
              "indexes" : [
                      {
                              "v" : 2,
                              "key" : {
                                      "_id" : 1
                              },
                              "name" : "_id_",
                              "ns" : "test.test"
                      }
              ],
              "ok" : 1 // <=== the test was expecting an error back from the server
      }
      rs:PRIMARY>
      
      Show
      Using an older version of the shell (one that doesn't use OP_COMMAND?): rs:PRIMARY> db.test.find() { "_id" : 1 } rs:PRIMARY> db.test.getIndexes() [ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" , "ns" : "test.test" } ] rs:PRIMARY> db.runCommand({ reIndex : "test" , writeConcern : { w : 9 } }) { "nIndexesWas" : 1, "nIndexes" : 1, "indexes" : [ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" , "ns" : "test.test" } ], "ok" : 1 // <=== the test was expecting an error back from the server } rs:PRIMARY>
    • Storage 2017-03-27

      The .NET driver tests send the following command to a replica set primary:

      "{ \"reIndex\" : \"ReIndexOperationTests\", \"writeConcern\" : { \"w\" : 9 } }"
      

      It is expecting an error back because { w : 9 } is not valid for a replica set with 3 nodes.

      The response back from the server is:

      "{ \"nIndexesWas\" : 1, \"nIndexes\" : 1, \"indexes\" : [{ \"v\" : 2, \"key\" : { \"_id\" : 1 }, \"name\" : \"_id_\", \"ns\" : \"Tests02011550.ReIndexOperationTests\" }], \"ok\" : 1.0 }"
      

      This is probably an issue of which code path is being used in the server. If you try to reproduce this using the current shell you get the expected error. If you use an older shell you don't get the expected error.

      The .NET driver and older shells don't use OP_COMMAND, so the difference probably lies in that.

            Assignee:
            maria.vankeulen@mongodb.com Maria van Keulen
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: