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

mongoexport can produce content that can't be imported via mongoimport

      When creating subtypes for binary objects > 127 then mongoexport exports in a format that mongoimport can't import.

      To reproduce:

      1) Save some objects in the shell

       
      > use pymongo_test 
      switched to db pymongo_test 
      > db.bin_test.find() 
      db.bin_test.save({'127': BinData(127,"aGVsbG8=")}) 
      db.bin_test.save({'128': BinData(128,"aGVsbG8=")}) 
      db.bin_test.save({'129': BinData(129,"aGVsbG8=")}) 
      

      2) mongoexport -d pymongo_test -c bin_test

       
      connected to: 127.0.0.1 
      { "_id" : { "$oid" : "50b871febfe8b9ae25f4e6d5" }, "127" : { "$binary" : "aGVsbG8=", "$type" : "7f" } } 
      { "_id" : { "$oid" : "50b87205bfe8b9ae25f4e6d6" }, "128" : { "$binary" : "aGVsbG8=", "$type" : "ffffff80" } } 
      { "_id" : { "$oid" : "50b87215bfe8b9ae25f4e6d7" }, "129" : { "$binary" : "aGVsbG8=", "$type" : "ffffff81" } } 
      

      3) Try to import:

       
      mongoexport -d pymongo_test -c bin_test | mongoimport -d pymongo_test -c bin_test2 
      connected to: 127.0.0.1connected to: 127.0.0.1 
      
      exported 3 records 
      Fri Nov 30 08:55:59 Assertion: 10338:Invalid use of reserved field name: $binary 
      0xaccb91 0x6796fb 0x67987c 0xa882ba 0xa7ff3d 0xa8b73a 0xa8f065 0xa802cf 0xa8b73a 0xa788f3 0xa780fa 0x56121d 0x562d04 0xb3ea62 0x5542cc 0x7ffbc78e176d 0x554159 
       mongoimport(_ZN5mongo15printStackTraceERSo+0x21) [0xaccb91] 
       mongoimport(_ZN5mongo11msgassertedEiPKc+0x9b) [0x6796fb] 
       mongoimport() [0x67987c] 
       mongoimport(_ZNK5boost6spirit4impl15concrete_parserINS0_11alternativeINS3_INS0_6actionINS0_4ruleINS0_7scannerIPKcNS0_16scanner_policiesINS0_24skipper_iteration_policyINS0_16iteration_policyEEENS0_12match_policyENS0_13action_policyEEEEENS0_5nil_tESH_EEN5mongo12fieldNameEndEEESL_EENS4_ISI_NSJ_20unquotedFieldNameEndEEEEESG_SH_E16do_parse_virtualERKSG_+0x1ba) [0xa882ba] 
       mongoimport(_ZNK5boost6spirit4impl15concrete_parserINS0_11list_parserINS0_8sequenceINS4_INS0_4ruleINS0_7scannerIPKcNS0_16scanner_policiesINS0_24skipper_iteration_policyINS0_16iteration_policyEEENS0_12match_policyENS0_13action_policyEEEEENS0_5nil_tESH_EENS0_5chlitIcEEEESI_EESK_NS0_16no_list_endtokenENS0_22binary_parser_categoryEEESG_SH_E16do_parse_virtualERKSG_+0x1dd) [0xa7ff3d] 
      ... 
       mongoimport(__gxx_personality_v0+0x421) [0x554159] 
      Fri Nov 30 08:55:59 exception:BSON representation of supplied JSON is too large: Invalid use of reserved field name: $binary 
      Fri Nov 30 08:55:59 
      Fri Nov 30 08:55:59 imported 1 objects 
      Fri Nov 30 08:55:59 ERROR: encountered 2 errors 
      

      So only type 127 got exported and reimported.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ross@mongodb.com Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: