[SERVER-10280] Too much database space with a queue collection Created: 22/Jul/13 Updated: 11/Jul/16 Resolved: 15/Dec/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Storage |
| Affects Version/s: | 2.4.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | David Verdejo | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | database, queue, space | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
rsstuff:SECONDARY> db.serverBuildInfo() |
||
| Operating System: | Windows |
| Steps To Reproduce: | Create a collection and insert a lot of documents and create a process to extract with findAndModify. For example: //server var dormir=1000; function sleep(milliseconds) { } } var i=0; while (i<umbral) { y ="Message " + i; db.queue.insert({_id:i,message:y}); i++; sleep(dormir); }; //client var dormir=100; var umbral=1; function sleep(milliseconds) { var start = new Date().getTime(); to=0; for (var i = 0; (i < 1e7 && to==0); i++) { if ((new Date().getTime() - start) > milliseconds){ to=1; } } var i=0; ,remove:true}); |
| Participants: |
| Description |
|
We have a database with some collection and we use these collection like a queue. We insert documents in the queue with db.<collection>.insert() and we extract them with db.<collection>.findAndModify({query:{},sort: {"_id":1},remove:true}) The problem is that we observe that the database size is bigger and bigger even when the size of the collection is small. Now, we have the following situation:
rsstuff:SECONDARY> db.stats(1024*1024) ,
rsstuff:SECONDARY> escala=1024*1024 ) |
| Comments |
| Comment by Daniel Pasette (Inactive) [ 23/Jul/13 ] |
|
In some workloads, mongodb can be susceptible to fragmentation and inefficient re-use of freed space in the collection. This is helped by using the powerOf2Sizes option on these collections. This can keep storage size steady in delete-heavy workloads. See: http://docs.mongodb.org/manual/reference/command/collMod/#usePowerOf2Sizes |