[SERVER-8665] PowerOf2 sizes can allow a document to grow in size inside a Capped Collection Created: 22/Feb/13  Updated: 11/Jul/16  Resolved: 27/Feb/13

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 2.4.0-rc2

Type: Bug Priority: Major - P3
Reporter: Andre de Frere Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

It should not be possible for a document to grow in size inside a capped collection. If usePowerOf2Sizes is set to true then documents can grow inside a Capped Collection

// Can grow the document with usePowerOf2Sizes
db.qwerty.drop()
db.createCollection("qwerty", {capped:true, size:100000})
db.runCommand( {collMod: "qwerty", usePowerOf2Sizes : true })
db.qwerty.insert({"test":"onetwothreefourfive", "foo" : "bar"})
db.qwerty.insert({"test":"fivesixseveneight", "foo" : "bar"})
db.qwerty.update({"test":"onetwothreefourfive", "foo" : "bar"}, {"test":"onetwothreefourfive", "foo" : "bar", "qwerty":"dvorak"})
db.qwerty.find()
 
// Can't grow the document without usePowerOf2Sizes
db.qwerty.drop()
db.createCollection("qwerty", {capped:true, size:100000})
db.qwerty.insert({"test":"onetwothreefourfive", "foo" : "bar"})
db.qwerty.insert({"test":"fivesixseveneight", "foo" : "bar"})
db.qwerty.update({"test":"onetwothreefourfive", "foo" : "bar"}, {"test":"onetwothreefourfive", "foo" : "bar", "qwerty":"dvorak"})
db.qwerty.find()



 Comments   
Comment by auto [ 27/Feb/13 ]

Author:

{u'date': u'2013-02-27T14:40:25Z', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-8665 - don't use padding or power of 2 for capped collections
Branch: master
https://github.com/mongodb/mongo/commit/a5e5bcf541657ae8e6ac587a224504085688f4a1

Comment by Eric Milkie [ 27/Feb/13 ]

Right, that ability can break replication because cloner does not copy records with their padding.

Comment by Dwight Merriman [ 27/Feb/13 ]

wonder if this is really a "problem" or just something one can do that doesn't make a ton of sense.

for example you could always i believe do something like this and there is a "grow"

db.mycapped.insert({_id:1,x:"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"});
db.mycapped.update({_id:1},{$set:{x:"z"}});
db.mycapped.update({_id:1},{$set:{x:"zzzzzzzzzzzzzzz"}}); // grows over last state

Comment by Eric Milkie [ 27/Feb/13 ]

This situation was present in 2.2 as well – backport?

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