Because we are short for disk space , I droped one conllection that is not useful. But the disk space remains the same after I droped a conllection.
I went to the data directory find one metadata file is the biggest file (317G), and I can’t find which conllection is using this file, I checked every conllection’s uri, found no conllection has this uri, but this metadata file still exist in data dirctory and occupy a lot of disk space.
MongoDB / WiredTiger will keep the allocated disk space reserved because it assumes that you will re-use the space with new data at some point. I think if you want it to actually release the used space, you would have to run a compact operation. You can find the documentation here:
dropped the collection not just delete documents. This usually result in the collection file being removed.
Thanks for clarifying that and sorry for getting that wrong.
I already solved this problem by restart mongo, the secondary node had reclaimed the disk space and that big metadata file disappeared. and I renamed the metadata file on the primary node, it didn’t affect the service so I move it to other machine.
That is quite an old version of MongoDB (released way back in July 2017). This version is affected by SERVER-31101 which was fixed in MongoDB 3.4.11 and newer. Note that MongoDB 3.4 series are not supported anymore since January 2020.