diff options
author | Eliot Horowitz <eliot@10gen.com> | 2012-10-02 18:29:39 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2012-10-02 18:30:53 -0400 |
commit | 19ecdc680e49471bd88b17024c15795a6a080137 (patch) | |
tree | d4151b7b42ba8ec2beb96bbf1d5703deec158446 | |
parent | d168d1a3ee648c4dd39de70babed7a9945f75259 (diff) | |
download | mongo-19ecdc680e49471bd88b17024c15795a6a080137.tar.gz |
SERVER-7238 fix power of 2 allocation with documents > 8mb
-rw-r--r-- | src/mongo/db/namespace_details.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/pdfile.cpp | 3 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/mongo/db/namespace_details.cpp b/src/mongo/db/namespace_details.cpp index a830b1210e3..19f3eef4c49 100644 --- a/src/mongo/db/namespace_details.cpp +++ b/src/mongo/db/namespace_details.cpp @@ -753,9 +753,15 @@ namespace mongo { if ( isUserFlagSet( Flag_UsePowerOf2Sizes ) ) { - int x = bucket( minRecordSize ); - x = bucketSizes[x]; - return x; + int allocationSize = bucketSizes[ bucket( minRecordSize ) ]; + if ( allocationSize < minRecordSize ) { + // if we get here, it means we're allocating more than 8mb + // the highest bucket is 8mb, so the above code will never return more than 8mb for allocationSize + // if this happens, we are going to round up to the nearest megabyte + fassert( 16439, bucket( minRecordSize ) == MaxBucket ); + allocationSize = 1 + ( minRecordSize | ( ( 1 << 20 ) - 1 ) ); + } + return allocationSize; } return static_cast<int>(minRecordSize * _paddingFactor); diff --git a/src/mongo/db/pdfile.cpp b/src/mongo/db/pdfile.cpp index aea2b6dbafe..701616014e0 100644 --- a/src/mongo/db/pdfile.cpp +++ b/src/mongo/db/pdfile.cpp @@ -1450,7 +1450,8 @@ namespace mongo { } int lenWHdr = d->getRecordAllocationSize( len + Record::HeaderSize ); - + fassert( 16440, lenWHdr >= ( len + Record::HeaderSize ) ); + // If the collection is capped, check if the new object will violate a unique index // constraint before allocating space. if (d->nIndexes && |