[SERVER-13914] 'no space in capped collection' error when inserting document close to the collection's size Created: 12/May/14  Updated: 22/Dec/14  Resolved: 22/Dec/14

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: 2.6.1, 2.7.0
Fix Version/s: 2.8.0-rc3

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
is related to SERVER-6981 maxPasses assertion (on allocation fa... Closed
Operating System: ALL
Steps To Reproduce:

var myDB = db.getSiblingDB('anotherdb');
myDB.dropDatabase();
 
myDB.createCollection('foo', {capped: true, size: 8192, usePowerOf2Sizes: false});
myDB.foo.insert({ a: new Array(8000).join('a') });
myDB.foo.insert({ a: new Array(8200).join('a') });

Participants:

 Description   

In 2.6 and master, inserting a document that's almost as large as the entire capped collection results in a 'no space in capped collection' error. There are two potential issues with this:

  1. The status message uses ErrorCodes::InternalError, which makes me think this scenario shouldn't be easily triggered by user input.
  2. The error message is slightly misleading because the capped collection actually does have some space in it. 'no space' implies that the collection is full even though it might be completely empty.

Output from master:

> var myDB = db.getSiblingDB('anotherdb');
> myDB.dropDatabase();
{ "dropped" : "anotherdb", "ok" : 1 }
 
> myDB.createCollection('foo', {capped: true, size: 8192, usePowerOf2Sizes: false});
{ "ok" : 1 }
 
> myDB.foo.insert({ a: new Array(8000).join('a') });
WriteResult({
	"nInserted" : 0,
	"writeError" : {
		"code" : 1,
		"errmsg" : "no space in capped collection"
	}
})
 
> myDB.foo.insert({ a: new Array(8200).join('a') });
WriteResult({
	"nInserted" : 0,
	"writeError" : {
		"code" : 2,
		"errmsg" : "document is larger than capped size 8248 > 8192"
	}
})


Version: ce04ab3728edeff71f0c32590558cb980a07fdb3



 Comments   
Comment by Kamran K. [ 22/Dec/14 ]

Mathias removed this error message as part of his fix for SERVER-6981:

https://github.com/mongodb/mongo/commit/545b4f727d2b74f1a50034cf63f22911a2dd0962#diff-4115ea89bc1f7ca38b2bf3b4801253a3L162

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