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

Upsert with $db is failing

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.2
    • Affects Version/s: None
    • Component/s: Write Ops
    • Labels:
      None
    • Fully Compatible
    • ALL

      A similar problem was reported a while back as SERVER-627. The fix covered $id and $ref cases, but didn't fix it for references containing a $db value. If you check https://github.com/mongodb/mongo/blame/master/db/jsobj.cpp @ line 847 and 847 you'll see that it checks for $ref and $id, but not for $db. This is causing certain upserts to fail with "not okForStorage". Removing the $db value from the references before attempting to upsert avoids the problem, so I'm using that as a workaround for now.

      Also, it took me ages to riddle out what was causing this. Is there any way you could give more specific information about the invalid syntax? Something like "okForStorage failed with message: key '$db' is not allowed. Check your record and try again." would have saved an incredible amount of time. "not okForStorage" is just cryptic and unhelpful.

            Assignee:
            scotthernandez Scott Hernandez (Inactive)
            Reporter:
            bugslayer John Crenshaw
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: