[SERVER-7529] collection grows unexpectedly large Created: 01/Nov/12  Updated: 15/Feb/13  Resolved: 09/Nov/12

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

Type: Bug Priority: Major - P3
Reporter: Anton V. Volokhov Assignee: Eric Milkie
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

We use mongo 2.2.0, replica set of 3 instances, no sharding.
Seems, 44 times growth definitely looks like a bug, not a feature.
Collection is used as a fast cache, so it is write/remove intensive.
After we experienced this problem, we started to use power of 2 sizes. But it didn't help.

db.stats(1024*1024*1024);
{
"db" : "image-url",
"collections" : 10,
"objects" : 3324847,
"avgObjSize" : 401.2754499680737,
"dataSize" : 1,
"storageSize" : 44,
"numExtents" : 64,
"indexes" : 12,
"indexSize" : 0,
"fileSize" : 51,
"nsSizeMB" : 16,
"ok" : 1
}



 Comments   
Comment by Eric Milkie [ 06/Nov/12 ]

The current MongoDB storage engine design does not handle certain workloads very efficiently with respect to fragmentation. With PowerOf2Sizes, some of the fragmentation issues are ameliorated. So for your collection image-url.pictures, I think you'll see much slower growth, if any, if you turn on that feature.

Comment by Anton V. Volokhov [ 06/Nov/12 ]

I didn't set usePowerOf2Sizes flag.
The issue is that collection image-url.pictures is repeatedly growing up to 40-50GB with actual "size" of 1-2GB every 2-3monthes.
PowerOf2Sizes was not used, I apologize for the confusion.

Comment by Eric Milkie [ 06/Nov/12 ]

Hi Anton.
I'm still not sure where you've set the usePowerOf2Sizes flag. Your last comment shows userFlags is 0 for image-url.pictures.

Comment by Anton V. Volokhov [ 06/Nov/12 ]

Ooops. Sorry, I set in in dev instance. But still. The collection keeps growing:
{
"sharded" : false,
"primary" : "mongodb-sh2",
"ns" : "image-url.pictures",
"count" : 3134045,
"size" : 1257568172,
"avgObjSize" : 401.2604069182159,
"storageSize" : 52233957040,
"numExtents" : 45,
"nindexes" : 2,
"lastExtentSize" : 2146426864,
"paddingFactor" : 1,
"systemFlags" : 1,
"userFlags" : 0,
"totalIndexSize" : 253619520,
"indexSizes" :

{ "_id_" : 121479008, "_h_1" : 132140512 }

,
"ok" : 1
}
it gained two more GBs in four days.

Comment by Eric Milkie [ 02/Nov/12 ]

For usePowerOf2Sizes to be active on a collection, the "userFlags" field should be at least 1. Can you confirm you set the flag correctly?

Comment by Anton V. Volokhov [ 02/Nov/12 ]

I have one worker collection (pictures) and a bunch of tiny helper collections:
{
"sharded" : false,
"primary" : "mongodb-sh2",
"ns" : "image-url.pictures",
"count" : 3268394,
"size" : 1310752036,
"avgObjSize" : 401.0385638940715,
"storageSize" : 50087530176,
"numExtents" : 44,
"nindexes" : 2,
"lastExtentSize" : 2146426864,
"paddingFactor" : 1,
"systemFlags" : 1,
"userFlags" : 0,
"totalIndexSize" : 244037248,
"indexSizes" :

{ "_id_" : 122460128, "_h_1" : 121577120 }

,
"ok" : 1
}

{
"sharded" : false,
"primary" : "mongodb-sh2",
"ns" : "image-url.clusterizer",
"count" : 2048,
"size" : 53240,
"avgObjSize" : 25.99609375,
"storageSize" : 348160,
"numExtents" : 4,
"nindexes" : 1,
"lastExtentSize" : 262144,
"paddingFactor" : 1,
"systemFlags" : 1,
"userFlags" : 0,
"totalIndexSize" : 73584,
"indexSizes" :

{ "_id_" : 73584 }

,
"ok" : 1
}

{
"sharded" : false,
"primary" : "mongodb-sh2",
"ns" : "image-url.ext-data.chunks",
"count" : 0,
"size" : 0,
"storageSize" : 8192,
"numExtents" : 1,
"nindexes" : 2,
"lastExtentSize" : 8192,
"paddingFactor" : 1,
"systemFlags" : 1,
"userFlags" : 0,
"totalIndexSize" : 16352,
"indexSizes" :

{ "_id_" : 8176, "files_id_1_n_1" : 8176 }

,
"ok" : 1
}
{
"sharded" : false,
"primary" : "mongodb-sh2",
"ns" : "image-url.ext-data.files",
"count" : 0,
"size" : 0,
"storageSize" : 8192,
"numExtents" : 1,
"nindexes" : 2,
"lastExtentSize" : 8192,
"paddingFactor" : 1,
"systemFlags" : 1,
"userFlags" : 0,
"totalIndexSize" : 16352,
"indexSizes" :

{ "_id_" : 8176, "filename_1_uploadDate_1" : 8176 }

,
"ok" : 1
}

{
"sharded" : false,
"primary" : "mongodb-sh2",
"ns" : "image-url.indexConverter",
"count" : 2048,
"size" : 53280,
"avgObjSize" : 26.015625,
"storageSize" : 348160,
"numExtents" : 4,
"nindexes" : 1,
"lastExtentSize" : 262144,
"paddingFactor" : 1,
"systemFlags" : 1,
"userFlags" : 0,
"totalIndexSize" : 73584,
"indexSizes" :

{ "_id_" : 73584 }

,
"ok" : 1
}

{
"sharded" : false,
"primary" : "mongodb-sh2",
"ns" : "image-url.partition",
"count" : 2048,
"size" : 53280,
"avgObjSize" : 26.015625,
"storageSize" : 348160,
"numExtents" : 4,
"nindexes" : 1,
"lastExtentSize" : 262144,
"paddingFactor" : 1,
"systemFlags" : 1,
"userFlags" : 0,
"totalIndexSize" : 89936,
"indexSizes" :

{ "_id_" : 89936 }

,
"ok" : 1
}
{
"sharded" : false,
"primary" : "mongodb-sh2",
"ns" : "image-url.unifier",
"count" : 2048,
"size" : 53240,
"avgObjSize" : 25.99609375,
"storageSize" : 348160,
"numExtents" : 4,
"nindexes" : 1,
"lastExtentSize" : 262144,
"paddingFactor" : 1,
"systemFlags" : 1,
"userFlags" : 0,
"totalIndexSize" : 73584,
"indexSizes" :

{ "_id_" : 73584 }

,
"ok" : 1
}

Comment by Eric Milkie [ 02/Nov/12 ]

Hi Anton.
Can you attach the output from running stats() on each of your collections in the image-url database?

Comment by Anton V. Volokhov [ 02/Nov/12 ]

So, repair worked as expected. The collection have been growing to this volume for a month or two.

Comment by Anton V. Volokhov [ 02/Nov/12 ]

first, I've made a repair, then modified the collection.

Comment by Eliot Horowitz (Inactive) [ 01/Nov/12 ]

Did you start a new collection or repair after switch to power of 2?
Just switching won't fix the old fragmentation.

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