Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27302

MongoDB 3.4 returns document with duplicate "roles" key for "rolesInfo" command.

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL
    • Hide

      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

      Show
      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

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ch3tmongo Christoph Husse
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: