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?
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.
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?