I set one shard's maxsize
to 20GB and keep remove data every day. but I see one db in this shard's storageSize
is about 18G, but its data file on the disk is about 33GB and it keep growing. I know mongo is just sign deleted data, but should it reuse that space? Or I need configure something?

- 8,356
- 19
- 50
- 61

- 1
- 4
-
1Do you know that mongo preallocate some amount of disk space for you? – Salvador Dali Mar 28 '14 at 02:36
-
http://stackoverflow.com/questions/4555938/auto-compact-the-deleted-space-in-mongodb/4560096#4560096 – Tony Zhu Mar 28 '14 at 02:37
1 Answers
I would not run repair
on your database as suggested whenever you feel like getting back your space; this would result in disastrous performance problems for one.
The problem you have is that documents are not "fitting" into the spaces you have in your deleted buckets list (for reference this is a good presentation: http://www.mongodb.com/presentations/storage-engine-internals it will explain everything I am talking about) and since MongoDB runs out of "steam" searching your list before it makes a whole new document you are most likely getting a new extent for every document you are inserting/updating.
You could run a compact
but then that is as bad as repair
in terms of performance but it will send those delete spaces to a free list which can be used by any size document.
You could also collmod with powerof2sizes: http://docs.mongodb.org/manual/reference/command/collMod/#usePowerOf2Sizes which may well fix your problem.
Ideally you need to redo your application, you underestimated how in-place updates/inserts into MongoDB works and now it is slaughtering you.

- 43,242
- 7
- 104
- 146