-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Tools and Replicator
-
77
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.
- is related to
-
TOOLS-3641 dump and restore collection metadata as BSON
- Accepted