SharePointDsc
SharePointDsc copied to clipboard
SPDistributedCacheService - Resource takes to long and does not complete correctly
Using the SPDistributedCacheService instance to provision a Distributed Cache on a server takes way to long and does not complete correctly. The service instance is stuck in the unprovisioning state after the resource is run.
After a quick look into the resource I came across this command: https://github.com/PowerShell/SharePointDsc/blob/4e9e1216da0412ac206889729e8f791bb51b79f5/Modules/SharePointDsc/DSCResources/MSFT_SPDistributedCacheService/MSFT_SPDistributedCacheService.psm1#L249-L251
I tried to change it to Stop-SPDistributedCacheServiceInstance
and the service instance gets stopped immediately.
Is there any reason to use Stop-SPServiceInstance
instead of Stop-SPDistributedCacheServiceInstance
?
Update: I did a quick check of the PowerShell Methods used to stop the service.
Stop-SPDistributedCacheServiceInstance
cmdlet uses the internal method: Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheServiceInstance.UnProvisionInternal()
to stop the service.
Stop-SPServiceInstance
cmdlet calls the public method Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheServiceInstance.Unprovision()
wich will also call the internal one.
I do not see, why there is a difference in the execution.
I know Stop-SPDistributedCacheServiceInstance has an issue where a graceful shutdown wasn't performed gracefully. The stop command is send to DC and then the DC process is terminated before it was able to complete gracefully. That is why the official gracefull shutdown procedure has been changed: https://docs.microsoft.com/en-us/sharepoint/administration/manage-the-distributed-cache-service#graceful
This is probably why you see the difference in behavior.
@andikrueger With the merge of #997, can you please test if this issue is also resolved with the version of Dev