[SERVER-27302] MongoDB 3.4 returns document with duplicate "roles" key for "rolesInfo" command. Created: 06/Dec/16  Updated: 06/Dec/16  Resolved: 06/Dec/16

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Christoph Husse Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-27271 rolesInfo command raises System.Inval... Closed
Operating System: ALL
Steps To Reproduce:

This PR demonstrates & fixes the issue on the java driver side. C & C++ drivers are not affected that much, but COULD be, if you were ever to iterate over the fields and bson_iter_next returns the key-value pair twice:

https://github.com/mongodb/mongo-java-driver/pull/382

Participants:

 Description   

When running

db.foo.runCommand({rolesInfo:1, showBuiltinRoles:true})

MongoDB 3.4 (but not any previous version I tested) will return a document with two "roles" fields:

{
    "roles": [<This is the data we want>],
    "roles": [],
    ...
}

Note that the above command will not actually produce a document with two "roles" keys, but on the "wire" (meaning the BSON binary chunk) it will be a duplicate that is then (maybe) disambiguated "in some way" by the driver you use.

Unfortunately, the first "roles" entry has the data, while the second one is empty. The java driver behaves differently compared to the C based drivers, since Map::put() will overwrite existing entries, thus making the last occurrence matter, while the C based drivers use a forward scan that will always return the first occurrence.

Further, I want to point out that this is NOT a bug in the java driver, but since the broken MongoDB has already been shipped to production, we still need a fix to deal with the broken MongoDBs that are in circulation.



 Comments   
Comment by Kelsey Schubert [ 06/Dec/16 ]

Hi ch3tmongo,

Thanks for reporting this issue. This issue has been fixed under SERVER-27271, and will be included in MongoDB 3.4.1.

Kind regards,
Thomas

Generated at Thu Feb 08 04:14:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.