Skip to content

Commit

Permalink
SERVER-7238 fix power of 2 allocation with documents > 8mb
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Oct 2, 2012
1 parent d168d1a commit 19ecdc6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/mongo/db/namespace_details.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/mongo/db/pdfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit 19ecdc6

Please sign in to comment.