[SERVER-3210] Fields dropped when using update with $set Created: 06/Jun/11  Updated: 07/Mar/14  Resolved: 03/Sep/11

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

Type: Bug Priority: Major - P3
Reporter: Michael Cohen Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: insert
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu lucid deb from website, db version v1.8.1, pdfile version 4.5
Mon Jun 6 22:06:15 git version: a429cd4f535b2499cc4130b06ff7c26f41c00f04


Operating System: Linux
Participants:

 Description   

Certain key values are lost with no warning when using $set to update a document. The following snippet illustrates:

import pymongo

document = {}
for x in range(3000):
document['%04X' % x] = "Hello"

collection = pymongo.Connection().test_db.data
spec = dict(_id = "unique_id")

  1. Make sure document is empty
    collection.remove(spec)
  1. Make a new document
    collection.save(spec)

print "Length of document %s" % len(document)

collection.update(spec,

{"$set": document}

, upsert=False, safe=True)

result = collection.find_one(spec)
print "Length of stored data %s" % len(result)

for key in document:
if key not in result:
print "Key %s is missing" % key

This is the output

Length of document 3000
Length of stored data 2981
Key 00A7 is missing
Key 00A6 is missing
Key 00A5 is missing
Key 00A4 is missing
Key 00A3 is missing
Key 00A2 is missing
Key 00A1 is missing
Key 00A0 is missing
Key 00A9 is missing
Key 00A8 is missing
Key 00B2 is missing
Key 00B3 is missing
Key 00B0 is missing
Key 00B1 is missing
Key 00B6 is missing
Key 00B7 is missing
Key 00B4 is missing
Key 00B5 is missing
Key 00B8 is missing
Key 00B9 is missing

Changing the formatter from %04X to %04d seems to bypass the issue. So there is something about a pattern in the text.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 03/Sep/11 ]

See SERVER-3218

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