Long Server Name Causing App Fabric Service to Crash

After a fresh installation of SharePoint 2013 I started noticing this error a lot in the ULS logs: “Unexpected Exception in SPDistributedCachePointerWrapper::InitializeDataCacheFactory for usage ‘DistributedViewStateCache’.” This error is related to the SharePoint service Distributed Cache, which is also related to the Windows service ‘App Fabric Caching Service’. I took a look at the services mmc snap-in and noticed that the windows service was stopped (The SharePoint service was started). I tried to start the service and it immediately stopped (and reported a faulting .dll error in the eventvwr application log). After some research I found some PowerShell that let me view the health of the “cache cluster.” Running the start-cachecluster cmdlet showed that the service was indeed down, and it also showed me that the HostName was shortened. The server name is 17 characters and it appears that this service doesn’t like the shortened HostName (Shortened after 15 characters).

app-fabric-cache1

I ran the following command to export the cache configuration:

And then changed the following line in the config (Added the missing characters): cacheHostName=”AppFabricCachingService” name=”SPDEV13LongServer”

And finally imported the edited config:

After importing the new configuration I confirmed that the host was the actual server name by running get-cachehost. After that I ran restart-cachecluster so the server could be added.

app-fabric-cache2

After I got the Windows Service healthy, I re-provisioned the Distributed Cache service in SharePoint:

I ran into this (along with some other interesting items) since the server name was over 15 characters so I would definitely recommend a server name less than the 15 character limit for NETBIOS names.

Some other things I learned from this:

  1. Always make sure that these 2 commands match up or else the User Profile Sync service will not start:

  2. If AppFabric gets uninstalled in a SharePoint farm, you must use the Prerequisites installer to reinstall WindowsServerAppFabricSetup_x64.exe. If the install does not work (Giving you a 1603 error code), look at the PSModulePath environmental variable. In my case SQL Server had added a quotation mark at the end of its path, which caused the installer to fail.
  3. The Distributed Cache being stopped could result in partial data loss and could cause some other issues around the farm such as giving errors when a site administrator goes to create a new subsite. http://technet.microsoft.com/en-us/library/jj219613.aspx