Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-2246

--stopOnError and --maintainInsertionOrder do not work as expected

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.12
    • Affects Version/s: None
    • Component/s: None
    • None

      mongoimport and mongorestore both support the --stopOnError (SOE) and --maintainInsertionOrder (MIO) options. In both tools, their behavior is inconsistent.

      In mongorestore:

      • SOE behaves as expected
      • MIO is almost entirely ignored (it limits the number of goroutines streaming the input documents, but they're actually sent to the server in an unordered bulk write)

      In mongoimport:

      • see this doc for an overview of all the behavior

      These tools should be fixed to have consistent and expected behavior when using these options, even in combination.

      A proposal: SOE and MIO should both result in an ordered bulk write. If a write error occurs when one of them is specified, we MUST return a non-zero exit code if SOE is specified. We may want to return 0 if only MIO is specified, however.

      Another option: implement MIO as a series of single inserts (or ordered bulk inserts), stopping on error iff SOE is specified. This would decouple the not-so-apparent relationship between the two options but also result in many more round trips to the server.

      In either case, MIO does differ from SOE in that it needs to limit the number of workers consuming the input to guarantee order. I don't think SOE needs to guarantee order of consumption, but it does need to use ordered bulk writes for error reporting purposes.

            Assignee:
            patrick.freed@mongodb.com Patrick Freed
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: