0

My output from db.stats() on a given database is

> db.stats()
{
    "db" : "stellar",
    "collections" : 525,
    "views" : 0,
    "objects" : 379961705,
    "avgObjSize" : 361.52269406202396,
    "dataSize" : 137364779232,
    "storageSize" : 181901602816,
    "numExtents" : 5043,
    "indexes" : 1137,
    "indexSize" : 47028065840,
    "fileSize" : 251066843136,
    "nsSizeMB" : 16,
    "extentFreeList" : {
        "num" : 114,
        "totalSize" : 364904448
    },
    "dataFileVersion" : {
        "major" : 4,
        "minor" : 22
    },
    "ok" : 1
}

and my disk space is at:

/dev/sdc1       252G  238G  1.8G 100% /datadrive

I know that mongo doesn't free up disk space after data has been deleted, which I have done to be safe. My understanding is that I have some storageSize - dataSize amount of space still available internally. Is that correct, or am I perilously close to running out of disk space?

Furthermore, how does the amount of free space map to the extentFreeList?

  • What specific version of MongoDB server are you using and what sort of deployment do you have (standalone, replica set, or sharded cluster)? It appears you are using the older (and now deprecated) MMAP storage engine which preallocates extent files in increasing increments. By default, the largest file increment is 2GB which would indeed be perilous if you only have 1.8 GB of free space on your data volume. Although you have reasonable preallocated free space based on your storageSize - dataSize, fragmentation can prevent this from being effectively reused. – Stennie Mar 22 at 1:51
  • MMAP allocates space at a database level, so if you want to free up disk space after deleting a significant number of documents or collections you would need to rebuild the data files (ideally by re-syncing via replication). WiredTiger, the default storage engine for new MongoDB 3.2+ deployments, includes data & index compression that could be a significant savings over your current MMAP deployment. WiredTiger is also generally more efficient about reuse of preallocated space (as compared to MMAP). – Stennie Mar 22 at 1:55
  • Thanks. Am using 3.4 and as you indicate it is using MMAP. Am setting up a replica set so I can migrate to wiredTiger. However, am hoping the 44GB of free space I have will hold up until that is ready. How does the this 44GB of free internal space relate to the extents which is only 360 MB? – farhadf Mar 22 at 3:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.