[SERVER-13912] Capped collections with storageSize=0 can be created Created: 12/May/14  Updated: 10/Sep/14  Resolved: 23/May/14

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 2.7.1

Type: Bug Priority: Minor - P4
Reporter: Kamran K. Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: 28qa
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:

var myDB = db.getSiblingDB('newdb');
myDB.dropDatabase();
myDB.createCollection('foo', {size: 0, capped:true});
 
myDB.foo.storageSize();
myDB.foo.insert({});

Participants:

 Description   

If you create a capped collection with {size: 0} in 2.7.0 or 2.6.1, you get a collection with storageSize of 4096. In master, you get a collection with storageSize of 0, which leads to an assert when you attempt to insert a document.

2.7.0:

> var myDB = db.getSiblingDB('newdb');
> myDB.dropDatabase();
{ "dropped" : "newdb", "ok" : 1 }
 
> myDB.createCollection('foo', {size: 0, capped:true});
{ "ok" : 1 }
 
> myDB.foo.storageSize();
4096
 
> myDB.foo.insert({});
WriteResult({ "nInserted" : 1 })

master:

> var myDB = db.getSiblingDB('newdb');
> myDB.dropDatabase();
{ "dropped" : "newdb", "ok" : 1 }
 
> myDB.createCollection('foo', {size: 0, capped:true});
{ "ok" : 1 }
 
> myDB.foo.storageSize();
0
 
> myDB.foo.insert({});
WriteResult({
	"nInserted" : 0,
	"writeError" : {
		"code" : 8,
		"errmsg" : "assertion src/mongo/db/diskloc.h:85"
	}
})

Stack trace:

2014-05-12T16:47:15.750-0400 [conn1] Assertion failure !isNull() src/mongo/db/diskloc.h 85
2014-05-12T16:47:15.753-0400 [conn1] 0x10079b149 0x100744d4d 0x100732801 0x100563209 0x10058ece6 0x10058860f 0x1001064ac 0x10010614d 0x1001db4c4 0x1001d9bd3 0x1001d93ad 0x1001d7857 0x1001dfecf 0x1001ef4d9 0x1001f05e2 0x1001f1660 0x100435820 0x1002d0280 0x10000e544 0x100753af0 
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo15printStackTraceERSo+0x39) [0x10079b149]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo10logContextEPKc+0xcd) [0x100744d4d]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo12verifyFailedEPKcS1_j+0x1d1) [0x100732801]
 /Users/kk/code/mongo/mongo/./mongod(_ZNK5mongo19MmapV1ExtentManager9getExtentERKNS_7DiskLocEb+0x69) [0x100563209]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo19CappedRecordStoreV111allocRecordEPNS_21TransactionExperimentEii+0x56) [0x10058ece6]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo17RecordStoreV1Base12insertRecordEPNS_21TransactionExperimentEPKcii+0xcf) [0x10058860f]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo10Collection15_insertDocumentEPNS_21TransactionExperimentERKNS_7BSONObjEb+0x11c) [0x1001064ac]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo10Collection14insertDocumentEPNS_21TransactionExperimentERKNS_7BSONObjEb+0x23d) [0x10010614d]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo18WriteBatchExecutor13execOneInsertEPNS0_16ExecInsertsStateEPPNS_16WriteErrorDetailE+0x3d4) [0x1001db4c4]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo18WriteBatchExecutor11execInsertsERKNS_21BatchedCommandRequestEPSt6vectorIPNS_16WriteErrorDetailESaIS6_EE+0x383) [0x1001d9bd3]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo18WriteBatchExecutor11bulkExecuteERKNS_21BatchedCommandRequestEPSt6vectorIPNS_19BatchedUpsertDetailESaIS6_EEPS4_IPNS_16WriteErrorDetailESaISB_EE+0x1ad) [0x1001d93ad]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo18WriteBatchExecutor12executeBatchERKNS_21BatchedCommandRequestEPNS_22BatchedCommandResponseE+0x947) [0x1001d7857]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo8WriteCmd3runERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0x24f) [0x1001dfecf]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo12_execCommandEPNS_7CommandERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0x29) [0x1001ef4d9]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo7Command11execCommandEPS0_RNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb+0xc12) [0x1001f05e2]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo12_runCommandsEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x500) [0x1001f1660]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo11newRunQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_+0x2e0) [0x100435820]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE+0x5a0) [0x1002d0280]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE+0xb4) [0x10000e544]
 /Users/kk/code/mongo/mongo/./mongod(_ZN5mongo17PortMessageServer17handleIncomingMsgEPv+0x390) [0x100753af0]


Version: ce04ab3728edeff71f0c32590558cb980a07fdb3



 Comments   
Comment by Githook User [ 22/May/14 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-13912 Capped collections with size=0 are promoted to the minimum Extent size
Branch: master
https://github.com/mongodb/mongo/commit/a0d921a14d099242cc0587d177dddf6fd0749cc1

Comment by Githook User [ 16/May/14 ]

The following commit was meant for SERVER-13951

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-13912 Better write intents for RSV1Base::deleteRecord

Only declare intent to write to areas we actually write to, rather than the
entire Extent header. Most of the time (ie unless deleting the first or last
record) no write intents should be declared.
Branch: master
https://github.com/mongodb/mongo/commit/7b1fc98747bd70134da28c8991ddf6dd90d90c87

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