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

Mongodump should check collection metadata consistency

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Tools and Replicator
    • 116

      Problem Statement/Rationale

      Mongodump and mongorestore are exposed to a fundamental limitation of extended JSON.
      If a collection’s options contain a BSON Object with a $-prefixed field, and the field’s name is the same as a string used as a type indicator in extended JSON format, such as $date and $numberLong, mongodump could cause a dump file that results in a different collection from the original collection after being restored.

      Consider a collection’s option containing an BSON Object that has the structure of

      { "field1": { "$date": Int64(1257894000000) } }
      

      The value of “field1” is a BSON Object.

      Mongodump dumps the metadata of the collection including the objects to canonical extended JSON format:

      {"field1":{"$date":{"$numberLong":"1257894000000"}}}
      

      Mongorestore would restore the value of “field1” as a BSON Date type instead of a BSON Object as the restored collection’s metadata, due to ambiguity of the extended JSON format.

      Mongodump should unmarshal ext JSON collection metadata and do a BSON comparison with the original collection metadata to avoid producing a metadata file that would cause an inconsistency after being restored.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jian.guan@mongodb.com Jian Guan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: