Site icon TheWindowsUpdate.com

Manual Compaction of Service Fabric Actor Replicas

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.

The auto-compaction is not enabled by default . If you see the settings CompactionThresholdInMB mentioned at Deleting Actor is not freeing up the Disk space - Microsoft Tech Community

 

However to enable the auto-compaction, the prior requirement is to have disk space, that is adequate disk space should be present on the node to enable the auto-compaction i.e. if you bloated size of the replica is showing 100 GB then you will need twice the amount of disk space to be free for auto-compaction to be enabled, that is additional 100 GB should be free. 

 

if you don't have adequate space and DB are bloated or you don't want to enable auto-compaction then you may consider performing manual compaction of the replicas/DB. 

 

In this we perform the logical build to compact . The logical build replica doesn’t have the physical size it only contains the actual data, once secondary logical build is completed, it is swapped with primary and then other replica is built from new primary and other bloated replica are discarded/ dropped. 

 

Below are steps to perform manual compaction. 

 

IMPORTANT NOTE : Never kill the primary. 

Important

  1. Steps to make new compacted secondary as Primary:

    • When compaction is done, compacted replica will come up and join the replica set size as new secondary. Either standby or active.
    • If compacted secondary is standby,
      • Then Primary must already be building a new secondary which would be inbuild.
        • Remove the inbuild replica using Remove-ServiceFabricReplica** cmdlet. This will force SF to make the compacted standby replica an active secondary.
      • If not, then remove any active secondary using Remove-ServiceFabricReplica ** cmdlet. Make sure there are target-set - 1 ready replicas including primary before this.
    • Once compacted secondary becomes active,
      • Call Move-ServiceFabricPrimaryReplica that will make compacted secondary as new primary.
  2. Steps to build new compacted secondaries from compacted primary:

    • Call Remove-ServiceFaricReplica on down/inbuild/active secondary
    • SF will automatically trigger a new replica build.
    • Unless this new replica is up and you have checked by looking at corresponding replica_folder, don't perform Remove-ServiceFabricReplica** on other secondaries
    • Once new compacted secondary is up, follow similar steps for other secondary.
    • Move-ServiceFabricPrimaryReplica -PartitionId <PARTITION_ID> -NodeName "<SECONDARY_REPLICA_NODE_NAME>" -ServiceName <SERVICE_NAME>
    • Remove-ServiceFabricReplica -NodeName "<SECONDARY_REPLICA_TO_REMOVE_NODE>" -PartitionId <PARTITION_ID> -ReplicaOrInstanceId <SECONDARY_REPLICA_ID>
Exit mobile version