[SERVER-12327] Update with $text only updates half of matching docs if docs have moved Created: 10/Jan/14  Updated: 11/Jul/16  Resolved: 29/Jan/14

Status: Closed
Project: Core Server
Component/s: Text Search, Write Ops
Affects Version/s: None
Fix Version/s: 2.5.5

Type: Bug Priority: Major - P3
Reporter: Tyler Brock Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Can't reproduce on 2.5.4, can reproduce on master: 9cfca59caf6426bf3c14fa3730aa58003b223386

db.test.drop()
db.test.insert({ a: "dog" })
db.test.insert({ a: "dog" })
db.test.ensureIndex({ a: "text" })
db.test.update(
    { $text: { $search: "dog" } },
    { $set: { b: 1 } },
    { multi: true }
)
assert.eq(db.test.count({ b: 1 }), 2)

Participants:

 Description   

Updates with a text predicate does not update all of the matched documents if the update results in moves. It seems to update half of those that matched (if 8 match 4 get updated, if 2 match 1 gets updated).



 Comments   
Comment by Githook User [ 29/Jan/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-12327 converted DiskLoc-based results to owned copies in working set on invalidation.
Branch: master
https://github.com/mongodb/mongo/commit/fc72190963cb527ece46ee407c04c1f99d0c461d

Comment by Tyler Brock [ 20/Jan/14 ]

Same thing happens with remove:

> db.test.find({$text: {$search: "dog"}})
{ "_id" : 1, "words" : "dog" }
{ "_id" : 4, "words" : "dog cat cat", "num" : 2, "loc" : [ 40, 40 ] }
{ "_id" : 3, "words" : "dog cat cat", "num" : 1, "loc" : [ 20, 20 ] }
{ "_id" : 2, "words" : "dog cat" }
> db.test.remove({$text: {$search: "dog"}})
SingleWriteResult({
	"writeErrors" : [ ],
	"writeConcernErrors" : [ ],
	"nInserted" : 0,
	"nUpserted" : 0,
	"nUpdated" : 0,
	"nModified" : 0,
	"nRemoved" : 2,
	"upserted" : [ ]
})
> db.test.find({$text: {$search: "dog"}})
{ "_id" : 4, "words" : "dog cat cat", "num" : 2, "loc" : [ 40, 40 ] }
{ "_id" : 2, "words" : "dog cat" }

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