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

mongorestore incorrectly ignores w=1, the default

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.3.2
    • Affects Version/s: None
    • Component/s: Tools
    • Labels:
      None
    • ALL

      Running mongorestore with no --w option, or using a version before it was introduced, works a lot faster than if I introduce --w 2. This feels wrong to me, the default behaviour, as per the docs, is to assume w=1:

      http://docs.mongodb.org/manual/reference/mongorestore/

      Looking at the source code, I can see that the member variable _w is set to the --w argument, and that it defaults to 1. But the code is ignoring this if the value is one, for example:

      // wait for insert to propagate to "w" nodes (doesn't warn if w used without replset)
      if ( _w > 1 )

      { conn().getLastErrorDetailed(false, false, _w); }

      The check should surely be if (_w > 0), the getLastError command still needs to run if w=1!

      The same happens in a few other places in the source code for mongorestore.

      I don't have time to play with this much more right now. We could simply fix it but it's going to slow things down. A better option would be to change the default to w=0 and update the documentation.

            Assignee:
            sverch Shaun Verch
            Reporter:
            jamespharaoh James Pharaoh
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: