[SERVER-6772] After update, json elements reordered with _class element written by SpringData appearing before _id element. This was causing issues updating documents. Created: 15/Aug/12  Updated: 10/Dec/14  Resolved: 13/Jan/14

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

Type: Question Priority: Major - P3
Reporter: Brian Bientz Assignee: Ron Avnur
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

EC2 SLES 11


Participants:

 Description   

After running JS to atomically update a number of documents, document data was moved and JSON elements re-ordered. I think this is expected. When this happened, the _class element appeared before the _id element. This seemed to impacting the ability to update existing records. Updates were silently failing with no update to the document.

Here's a snippet of the JSON:

{
   "_class": "com.riskchecknow.datafactory.model.person.impl.PersonWatchImpl",
   "_id": "ObjectId("50254761e4b01356f16783f9")",
   "active": true,
   "createdAt": "ISODate("2012-08-10T17: 39: 45.226Z")",
   "shardk": {
     "value": "47onmsprlrvjrqtmbvgf29tuk8",
     "date": "ISODate("2012-08-01T04: 00: 00.0Z")" 
  },
   "updatedAt": "ISODate("2012-08-10T17: 39: 49.299Z")", ...

Work around was to rename the collection, read through the renamed collection writing everything back the original collection.

Is there a known bug that would prevent proper update behavior when _id is not the first element in the document?



 Comments   
Comment by Ian Whalen (Inactive) [ 08/Nov/12 ]

Hi Brian, do you have any further updates? Were you able to generate a test case to confirm this was an issue with springdata?

Comment by Brian Bientz [ 15/Aug/12 ]

Thanks for your input. Tomorrow we are going to try to generate a test case using spring-data as the problem most certainly seems to be there and not in MongoDB.

I'll update when we have more information.

Comment by Scott Hernandez (Inactive) [ 15/Aug/12 ]

No, that is not a requirement to have the _id field first.

Do you have an example of the failing update on this document?

I would suggest taking this up with the spring-data folks as it might be related to data types and how classes are mapped re/data-types.

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