Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
2.0.4, 2.1.0
-
None
-
None
-
ALL
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.
Attachments
Issue Links
- duplicates
-
SERVER-5285 Either disallow or fix capped collections with more than 2^32 docs
-
- Closed
-