[SERVER-2639] Inserting into a capped collection an object larger than max size fails silently Created: 11/Feb/11  Updated: 12/Jul/16  Resolved: 06/Jun/12

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

Type: Bug Priority: Major - P3
Reporter: Jonas Lindholm Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: rn
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux 64 bit mongoDB 1.6.5


Issue Links:
Related
related to SERVER-5602 Insert on capped collection fails sil... Closed
Operating System: ALL
Participants:

 Description   

I have a capped collection with max: 1 and size :10000

If I insert/update an object that is larger than 10000 bytes the returned _id is a valid ID, i.e. the insert does not croak, but no data is inserted.
In my case the existing data was not replaced with the new data, instead the existing data was deleted but the new data was not inserted because it was larger than 10000 bytes.

I've not tried to insert data larger than max size of 10000 bytes with any other method so I'm not sure if it is a problem with the Perl driver or with mongoDB it self.

Of course it was easy to fix by increasing the size to more than 10000 but the insert should at least fail as I was not expecting to lose existing data and ending up with no data at all.



 Comments   
Comment by auto [ 03/Jun/12 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-2639 assert early when inserting something too big into capped collection
Branch: master
https://github.com/mongodb/mongo/commit/334b09b0bccd0d4475b92f17b81e5c532713aec8

Comment by Kristina Chodorow (Inactive) [ 28/Feb/11 ]

Example:

> db.createCollection("bar",

{capped : true, size : 100, max : 1}

)

{ "ok" : 1 }

> db.bar.insert(

{x:"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"}

)
> db.bar.find()
>

It throws an error in the log.

Mon Feb 28 13:41:58 [conn1] couldn't make room for new record (len: 148) in capped ns test.bar
Extent 0 (capExtent)
magic: 41424344 extent->ns: test.bar
fr: null lr: null extent->len: 256
insert: couldn't alloc space for object ns:test.bar capped:1

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