[SERVER-8706] Wrong BinData written with mongoimport Created: 25/Feb/13  Updated: 11/Jul/16  Resolved: 26/Feb/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.4.0-rc0
Fix Version/s: 2.4.0-rc1

Type: Bug Priority: Major - P3
Reporter: Gianfranco Palumbo Assignee: Shaun Verch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-8297 Remove three argument constructor fro... Closed
Operating System: ALL
Participants:

 Description   

Using this:

t = new ToolTest( "jsonparser" );
 
c = t.startDB("testcollection");
 
data = 'data/jsonparser';
 
key = "bindata";
key_value = BinData(5, "nhB9nTcrtoJr2B01QqQZ1g==");
c=t.db.getCollection("testcollection");
// true is to enable field names to start with $
// e.g. $undefined
c.insert({key: key_value}, true);
t.runTool( "export" , "--version");
t.runTool( "export" , "--out" , data , "-d" , t.baseName, "-c" , "testcollection");
c.drop();
assert.eq( 0 , c.count() , "after drop" );
t.runTool( "import" , "--version");
t.runTool( "import" , "--file" , data , "-d" , t.baseName, "-c" , "testcollection2");
c2=t.db.getCollection("testcollection2");
assert.soon( "c2.findOne()" , "read imported document" );
assert.eq( 1 , c2.count() , "1 doc after import" );
 
var doc = c2.findOne();
assert.eq( key_value , doc.key , "assert data type" );
 
c2.drop();
assert.eq( 0 , c2.count() , "after drop" );

It works fine on 2.2.2.

But not on 2.3.2 and 2.4.0-rc0

assert: [BinData(5,"nhB9nTcrtoJr2B01QqQZ1g==")] != [BinData(5,"77+9EH3vv703K++/ve+/vQ==")] are not equal : assert data type
Error: Printing Stack Trace
    at printStackTrace (src/mongo/shell/utils.js:37:7)
    at doassert (src/mongo/shell/assert.js:6:1)
    at Function.assert.eq (src/mongo/shell/assert.js:32:1)
    at test_round_trip (jsonparser-undefined.js:22:16)
    at jsonparser-undefined.js:31:1
Wed Feb 20 16:38:16.332 [BinData(5,"nhB9nTcrtoJr2B01QqQZ1g==")] != [BinData(5,"77+9EH3vv703K++/ve+/vQ==")] are not equal : assert data type src/mongo/shell/assert.js:7
failed to load: jsonparser-undefined.js

mongoimport and mongoexport v2.4.0-rc0

commandline:
mongodb-osx-x86_64-2.4.0-rc0/bin/mongo --nodb --norc jsonparser.js

mongoexport is saving

{ "_id" : { "$oid" : "5124fd42876fdb24f52e5722" }, "bindata" : { "$binary" : "nhB9nTcrtoJr2B01QqQZ1g==", "$type" : "05" } }

but after running mongoimport, this is what appears on the shell

{
  "_id": ObjectId("512503b4c35f6f6101d2b9c6"),
  "key": BinData(5, "77+9EH3vv703K++/ve+/vQ==")
}

note: even the objectid is different

This doesn't occur with MaxKey(), NumberLong()



 Comments   
Comment by Gianfranco Palumbo [ 27/Feb/13 ]

You're correct, I must have confused tests or mongod instances.

Comment by Shaun Verch [ 26/Feb/13 ]

gianfranco Note: I could not reproduce the difference in ObjectIDs. Feel free to open a new ticket if you still find that this is a problem.

Comment by Shaun Verch [ 26/Feb/13 ]

This issue was fixed by: https://github.com/mongodb/mongo/commit/0e0b5016ab80630666277790adbd8042b2c5bb68

Generated at Thu Feb 08 03:18:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.