[SERVER-14115] cannot perform an in-place update on oplog Created: 30/May/14  Updated: 06/Dec/22  Resolved: 19/Jan/16

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

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-11983 Update on document without _id, in ca... Closed
related to SERVER-20529 WiredTiger allows capped collection o... Closed
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

Can make updates on capped collections, including without Id index, but on oplog.rs in local:

db.getSiblingDB("local").oplog.rs.find({ "ts" : Timestamp(1401418539, 1), "h" : NumberLong("-4571530663222791900")})
{ "ts" : Timestamp(1401418539, 1), "h" : NumberLong("-4571530663222791900"), "v" : 2, "op" : "i", "ns" : "blog.docs", "o" : { "_id" : ObjectId("5387f32bad47a6460bac5994"), "docId" : 999 } }
> db.getSiblingDB("local").oplog.rs.update({ "ts" : Timestamp(1401418539, 1), "h" : NumberLong("-4571530663222791900")},
{$set:{op:"c"}})
WriteResult({
	"nMatched" : 0,
	"nUpserted" : 0,
	"nModified" : 0,
	"writeError" : {
		"code" : 10003,
		"errmsg" : "failing update: objects in a capped ns cannot grow"
	}
})
> db.getSiblingDB("local").oplog.rs.update({ "ts" : Timestamp(1401418539, 1), "h" : NumberLong("-4571530663222791900")},
{$inc:{v:1}})
WriteResult({
	"nMatched" : 0,
	"nUpserted" : 0,
	"nModified" : 0,
	"writeError" : {
		"code" : 10003,
		"errmsg" : "failing update: objects in a capped ns cannot grow"
	}
})
> db.getSiblingDB("local").oplog.rs.update({ "ts" : Timestamp(1401418539, 1), "h" : NumberLong("-4571530663222791900")},
{$inc:{"o.docId":1}})
WriteResult({
	"nMatched" : 0,
	"nUpserted" : 0,
	"nModified" : 0,
	"writeError" : {
		"code" : 10003,
		"errmsg" : "failing update: objects in a capped ns cannot grow"
	}
})

As it turns out, if I shrink the new doc by A LOT I can get it in (but not shrinking by a little). So somewhere there's a calculation that's maybe adding ts and h twice or something like that.

/* shrink by 15 bytes and it doesn't fit still */
db.getSiblingDB("local").oplog.rs.update({ "ts" : Timestamp(1401418539, 1), "h" : NumberLong("-4571530663222791900")},{ "ts" : Timestamp(1401418539, 1), "h" : NumberLong("-4571530663222791900"), "v" : NumberInt(2), "op" : "i", "ns" : "b.d", "o" : { "_id" : NumberInt(0), "doc1" : NumberLong(999) } })
WriteResult({
	"nMatched" : 0,
	"nUpserted" : 0,
	"nModified" : 0,
	"writeError" : {
		"code" : 10003,
		"errmsg" : "failing update: objects in a capped ns cannot grow"
	}
})
/* shrink by 16 bytes and it "fits" */
db.getSiblingDB("local").oplog.rs.update({ "ts" : Timestamp(1401418539, 1), "h" : NumberLong("-4571530663222791900")},
  { "ts" : Timestamp(1401418539, 1), "h" : NumberLong("-4571530663222791900"), "v" : NumberInt(2), "op" : "i", "ns" : "b.d", "o" : { "_id" : NumberInt(0), "doc": NumberLong(888) } })
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })



 Comments   
Comment by Scott Hernandez (Inactive) [ 19/Jan/16 ]

Closing as dup of SERVER-11983.

Comment by Scott Hernandez (Inactive) [ 31/May/14 ]

In 2.6 an _id field is now ensured for all documents when updated/inserted by users. That is what you are seeing most likely. There are no exceptions.

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