Replicaset member Initial sync -data shrink

So -i’m currently running a replicaset on mongodb 5(community version).
Im migrating to new servers by adding the new servers as additional replicaset members.
Adding a new member ofc triggers the initial sync -data is then transferred and synced to the new member -as intended.

What i noticed is -data synced to the new servers is occupying way less, like 40% less, space on the filesystem than the old instances. Everything seems to be in order though.

What this post basically boils down to is -what shrink operations are triggered during an initial sync?
Are the data getting compressed better, defraged, reclamation of empty space fired?

Please enlighten me.

Thanks

Hi @Donnie,

Yes, defragmented. As documents are updated or deleted the block are marked as free and will be reused at a later time. An initial sync is a logical replication1 so a newly added member will have a nicely packed collection file.

[1] MonogoDB Enterprise 6.0+ (Rapid Release 5.2+) also has File Copy Based Initial Sync

Much obliged @chris
That database had a lot of deleted and updated documents throughout the years. Definitely explains the 40% disk space refund.

If you dont mind i have another question on the subject -im reading about compact -in order to keep the fragmentation at bay -should that be triggered like yearly?

In most collections these freed blocks will get reused at a later date so regular compaction is not needed.

If a large amount of data is removed and won’t be replaced then a compaction could be used to reclaim the freed space to filesystem.

1 Like

Acknowledged.
Thank you for letting me borrow your brain, Chris

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.