Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-13912

Capped collections with storageSize=0 can be created

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.7.1
    • Affects Version/s: None
    • Component/s: Storage
    • Fully Compatible
    • ALL
    • Hide
      var myDB = db.getSiblingDB('newdb');
      myDB.dropDatabase();
      myDB.createCollection('foo', {size: 0, capped:true});
      
      myDB.foo.storageSize();
      myDB.foo.insert({});
      
      Show
      var myDB = db.getSiblingDB('newdb'); myDB.dropDatabase(); myDB.createCollection('foo', {size: 0, capped:true}); myDB.foo.storageSize(); myDB.foo.insert({});

      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

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            kamran.khan Kamran K.
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: