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

Query results edited in javascript can create duplicate elements in the same document.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical - P2
    • Resolution: Duplicate
    • 2.4.1
    • None
    • JavaScript, Querying
    • None
    • Windows

    Description

      After obtaining a set of documents from my MongoDB, I attempted to iterate through and add the element "Name" to each result, e.g.:

      ...
      {
      "_id" : 01234567890
      },
      ...

      becomes

      ...
      {
      "_id" : 01234567890,
      "Name" : "Joe"
      },
      ...

      This was run on tens of thousands of entries. It almost always worked as expected, however it occasionally (1 - 5 across the entire dataset) produced entries which looked like this:

      ...
      {
      "_id" : 01234567890,
      "Name" : "Joe",
      "Name" : "Joe"
      },
      ...

      This data would then cause a corrupt entry when committed back to the DB.

      I viewed this information printed directly from javascript, before committing back to the DB. I also noticed that if I explicitly set the variable "Name" twice back to back, it went ahead and duplicated the key every time, setting the values of both instances to the one most recently specified.

      This does not happen if I create an array of test data right in JS, it ONLY occurred when modifying the results of a MongoDB query.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kwingham Kevin Wingham
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: