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

mongodump (2.6) produces corrupt BSON on Windows when run with "--out -"

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: Legacy C++ Implementation
    • Component/s: mongodump
    • None
    • Environment:
      Windows 10, mongod 2.6.3 (x64), mongodump 2.6.3 & 2.7.6
    • Platforms 2016-11-21
    • Needed
    • v2.6

      The legacy C++ implementation seems to output directly to the C standard output stream stdout, without setting binary mode. On Windows, if the written data includes line-feed 0x0A (\n) bytes, they will get automatically prefixed with a carriage return character 0x0D (\r), resulting in extra bytes in the output.

      To reproduce, have some documents in a mongo collection with data containing line feed characters e.g.:

      {
          "testfield" : "A\nB"
      }
      

      open a command line prompt and run:

      mongodump.exe --db mydb --collection mycollection --out testdump
      mongodump.exe --db mydb --collection mycollection --out - > testdump.bson
      

      Then observe 1-byte size difference between the files testdump\mydb\mycollection.bson & testdump.bson and confirm that there is an extra 0x0D byte in the latter file.

            Assignee:
            gabriel.russell@mongodb.com Gabriel Russell (Inactive)
            Reporter:
            samikyt Sami Kytönen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: