[SERVER-5503] All capped collections are implicitly limited to 2^31 - 1 documents Created: 04/Apr/12  Updated: 15/Aug/12  Resolved: 04/Apr/12

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.0.4, 2.1.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Daniel Crosta Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-5285 Either disallow or fix capped collect... Closed
Operating System: ALL
Participants:

 Description   

If you attempt to create a capped collection with a maximum number of documents greater than 2^31 - 1, Mongo silently lowers this to exactly 2^31-1:

> db.runCommand({create: "cappedWithMax", capped: true, size: 10000000, max: 4294967296})
{ "ok" : 1 }
> db.cappedWithMax.stats().max
2147483647

If you leave the "max" field out of the creation command, you still get 2^31 - 1 as max:

> db.runCommand({create: "cappedWithoutMax", capped: true, size: 10000000})
{ "ok" : 1 }
> db.cappedWithoutMax.stats().max
2147483647

This seems to be due to this section of _userCreateNS in pdfile.cpp (at line 259 on current master):

        if( options["capped"].trueValue() ) {
            newCapped = true;
            BSONElement e = options.getField("max");
            if ( e.isNumber() ) {
                mx = e.numberInt();
            }
        }

I would expect that the range of valid values for max should be either a long (2^63 - 1), unsigned long (2 ^ 64 - 1); or alternately that not specifying max leaves the number of documents unbounded.



 Comments   
Comment by Daniel Crosta [ 04/Apr/12 ]

Somehow didn't find SERVER-5285 when I created this ticket.

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