How to compact disk space after add new shard and rebalance?

Our MongoDB production database got high disk used percent, mongod data directory used percent over 90%. for reasons, we can’t allocate more space to existing data directory, so we solve the problem by add new shard to replicate set and let replicate set rebalance.
but the problem is , after add new shard and reblance, the existing disk space can’t be recycled to operating system, so the percent still over 90% so we still got warning message.
I tried to compact the only one collection , and db.push_task.stats show there’re a lot of bytes cacn be reused:
“file bytes available for reuse” : 997790101504,
I compact the collection by : db.runCommand( { compact : ‘push_task’ } )

but seems no help, after compact complete, the disk space still not recycled, is there any other methods to compact and recycle disk space of mongod?

Hi @hunter_huang,

A good way to reclaim space is by rolling resyncing the source shard replica set:

Having said that, since the bytes are ready for reuse the mongod could use them for future.

However, if other processes and logs require space you better reclaim it.


@Pavel_Duchovny Can I have solution for a similar situation too, where data balanced (100gb migrated) but there are only few bytes available to reUse (may be just 100mb to reUse), what to do in this situation?