I've been working with SharePoint for about 5 /12 years now and never had any issues with SharePoint cache.
Two weeks ago, I restored a web app/site collection on Production using database backup. I could navigate to the site collection and contents just fine from one Web Front End, but the other WFE was throwing errors. I found that i had to reset the sharepoint cache on that server. Once I did that, all was golden.
Yesterday, I found this error going off every hour:
Error shows up hourly: failure trying to synch site 28961a6e-da6c-dddd-96a1-9a3d0d979d6e for ContentDB ad130497-9927-4976-hiya-0f51777acf6c WebApp 6593083c-6926-4ecb-boot-13ba9e96c2d7. Exception message was Cannot insert duplicate key row in object 'dbo.UserMemberships' with unique index 'CX_UserMemberships_RecordId_MemberGroupId_SID'. The duplicate key value is (0c37852b-34d0-418e-rock-2ac25af4be5b, 3617, 67, 0x010500000000000515000000b375ce907e0574cfe5fbbe0d5b780000).
The statement has been terminated..
Doing some investigation (Googling), I found this helpful post from Guna K:
http://gunakuppusamy.wordpress.com/2012/07/06/sharepoint-2010-failure-trying-to-synch-site-issue/
Ran the Powershell script on DEV first, and after I found no issues, I ran it on the one troubled server and the errors stopped occuring.
If you don't learn something new every day, you are not having fun.
Powershell from Guna's page:
if ( (Get-PSSnapin -Name Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PsSnapin Microsoft.SharePoint.Powershell
}
# Variables Declerations
$GUID = [Guid](Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Secure\ConfigDB' -Name Id).Id
$ConfigDir = "c$\ProgramData\Microsoft\SharePoint\Config\$GUID"
# Function which is used to STOP the Timer Service
Function StopTimer()
{
Write-Host "The SPTimerV4 service will be stopped on " $Server.Name
$Service = Get-WmiObject -computer $Server.Name Win32_Service -Filter "Name='SPTimerV4'"
$Service.InvokeMethod('StopService',$Null)
start-sleep -s 5
Write-Host "The SPTimerV4 service has been stopped on " $Server.Name
}
# Function which is used to CLEAR the cache and resetting the value to 1
Function ClearCache()
{
Write-Host "Cached config items will be cleared on " $Server.Name
$ServerName = $Server.Name
$ConfigDirPath = "\\$ServerName\$ConfigDir"
$CacheIni = Get-Item "$ConfigDirPath\Cache.ini"
Get-ChildItem "$ConfigDirPath\*" -Filter *.xml | Remove-Item
Set-Content -Path $CacheIni -Value "1"
Write-Host "Cached config items have been cleared on " $Server.Name
}
# Function which is used to START the Timer Service
Function StartTimer()
{
Write-Host "The SPTimerV4 service will be started on " $Server.Name
$Service = Get-WmiObject -computer $Server.Name Win32_Service -Filter "Name='SPTimerV4'"
$Service.InvokeMethod('StartService',$Null)
start-sleep -s 5
Write-Host "The SPTimerV4 service has been started on " $Server.Name
}
# Get SPFarm object
$Farm = Get-SPFarm
# Loop through all the servers in the Farm and carry out all the functions (START and STOP the Timer and clear the Cache
foreach ($Server in $Farm.Servers)
{
# This will make sure that other types of servers (DB, SMTP etc.,) will not be affected
if ($Server.Role -eq "Application")
{
try
{
StopTimer
ClearCache
}
catch
{
Write-Host "Error Occured " ; $error[0]
}
finally
{
StartTimer
}
}
}