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

Mongodump hangs if StdOut not read concurently

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: 3.0.2
    • Component/s: mongodump
    • None
    • Environment:
      Windows Server 2012 R2.

      Azure D1 Instance

      When using mongorestore from command line it works flawlessly for a given database.

      Cmd : mongodump.exe /db my-db-name /o some-path

      Upon automating the call to the binary via a C# Process it would hang after a few collections.

      This hanging only occours to v3.0+ Older v2 binariers work fine.

      There are a number of way to execute external C# process, the notable different is when the call to the process is either a blocking call or not.

      When executing a blocking Process.Start(), and waiting for the process to end before reading StdOut/Err via :

      var stdOut = Process.StandardOutput.ReadToEnd();
      var stdErr = Process.StandardError.ReadToEnd();

      As I mentioned above, this worked with v2 binaries.

      I've resolved it by using a non-blocking tread to start the process; passing delegates the read StdOut/Err as mongodump writes to the StdIO buffers.

      It appears that the windows mongodump.exe binaries require the StdOut buffer to be read before continuing/compleating the dump.

            Assignee:
            gabriel.russell@mongodb.com Gabriel Russell (Inactive)
            Reporter:
            AndyScott Andrew Scott [X]
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: