Locked file in SharePoint Configuration Cache

This post will deal with all of the following fantastic error messages:

Access to the path C:\ProgramData\Microsoft\SharePoint\Config\<guid>\<guid>.xml is denied.

File system cache monitor encountered error, flushing in memory cache: System.IO.InternalBufferOverflowException: Too many changes at once in directory:C:\ProgramData\Microsoft\SharePoint\Config\

It all began for me when attempting to do a routine clearing of the SharePoint configuration cache in the manner that is well documented by Microsoft and various bloggers.  All went well, so I thought, but there were two oddities left behind:

1. the cache.ini file never updated with a new value after resetting it to 1
2. there was an odd file with an xml.tmp extension on it that would never go away

I tried repeating the steps to clear the cache, but every time, those two results would occur.  Meanwhile, my ULS logs were getting flooded with the 888k File system cache monitor encountered error entries, and the CPU utilization on that server would spike to 100% about every 5 minutes.

Every other article discussing the configuration cache suggests that just clearing it will resolve these issues.  But not for me.

The next clue that something was not right was when I tried to issue a Powershell command to update a Web Application object.  There was a nervous pause, then the ‘Access denied’ error would be displayed.  Interestingly, the file that was indicated in the error had the same Guid filename (but without the .tmp extension) as the file that wouldn’t go away.

Thinking I could just delete this file manually, I opened Windows explorer and tried to delete it.  Nope, Access Denied.

I then looked a the properties of the file, and was told ‘You don’t have permissions to view the security information.’  What?  I’m an administrator.  Don’t tell me I don’t have permissions.

Googling…googling….googling.

After finally going down the ‘how to delete a locked file’ route, I came to this post on Serverfault, which introduced me to Lockhunter.

Download, install, browse to C:\ProgramData\Microsoft\SharePoint\Config\GUID.

Lockhunter showed about a half-dozen locked files, including the one I was getting the Access Denied error on.  The owner of the file?  miiserver.exe

This process is none other than the Microsoft Forefront Identity Manager service used by the SharePoint User Profile Synchronization feature.

After stopping the SharePoint Timer service and the SharePoint Administration service, I opened Central Admin, browsed to Services on server, found the User Profile Synchronization Service entry, and clicked Stop!

Ever so slowly the service stopped, and when I refreshed Lockhunter, the entry for miiserver.exe was gone.

A quick browse back to the Config directory showed that the xml.tmp file was gone, and the value in the cache.ini file had been restored back up to a value that wasn’t 1.

I definitely hope this helps others who find themselves in similar situations, at least offering a process to find out the culprit.


Posted

in

,

by

Tags:

Comments

8 responses to “Locked file in SharePoint Configuration Cache”

  1. sachin Avatar
    sachin

    Thanks,

    Same thing happened to me. Your post was the only one i could find reagarding this error. I ended up rebooting the server as i found this post at the very last moment befor server was going to reboot. Anyway whatever you explained, i was able to see from the process and was exact same issue.

    Thank you very much for the post.

  2. Chet Chudasama Avatar
    Chet Chudasama

    Thats absolutely fantastic – thanks you!!!

  3. Rich Avatar

    Here is a script you can use… buddy sent this my way:

    # Script created by Ingo Karstein (http://ikarstein.wordpress.com)
    # http://support.microsoft.com/kb/939308

    $cacheFolderRoot = Join-Path ${env:ProgramData} “Microsoft\SharePoint\Config”
    $cacheFileCopy = Join-Path ${env:temp} “cacheFileTmp.ini.ik”

    Write-Host “” -ForegroundColor DarkBlue
    Write-Host “Starting” -ForegroundColor DarkBlue

    if( Test-Path $cacheFileCopy -PathType Leaf) {
    write-host “Cache File copy lopcation does already exist. Please remove it: $($cacheFileCopy)” -ForegroundColor Red
    return
    }

    Write-Host “Looking for cache folder” -ForegroundColor DarkBlue
    $cacheFolder = @(GEt-ChildItem -Path $cacheFolderRoot | ? {Test-Path $_.FullName -PathType Container} | ? {Test-Path -Path (Join-Path $_.FullName “cache.ini”) -PathType Leaf})

    if( $cacheFolder -ne $null -and $cacheFolder.Count -eq 1) {
    $cacheFolder0 = $cacheFolder[0].FullName
    Write-Host “Cache folder found: $($cacheFolder0)” -ForegroundColor DarkBlue
    $cacheFile = join-path $cacheFolder0 “cache.ini”
    Write-Host “Cache ini file: $($cacheFile)” -ForegroundColor DarkBlue

    Write-Host “Stop SharePoint timer service” -ForegroundColor DarkBlue
    stop-service sptimerv4

    Write-Host “Copy cache.ini to it’s temp location ($($cacheFileCopy))” -ForegroundColor DarkBlue
    copy-item -path $cacheFile -Destination $cacheFileCopy -force

    Write-Host “Set the content of cache.ini to “”1″”” -ForegroundColor DarkBlue
    “1” | set-content $cacheFile -encoding ascii -force

    Write-Host “Remove all .XML files from the cache folder” -ForegroundColor DarkBlue
    get-childitem $cacheFolder0 -filter “*.xml” | remove-item -force -confirm:$false

    Write-Host “Start SharePoint timer service” -ForegroundColor DarkBlue
    start-service sptimerv4

    $xmlFound = -1
    $xmlFoundLast = -1
    $eqCount = 0

    Write-Host “Now the cache will be recreated… Waiting… This will take a minute or so…” -ForegroundColor DarkBlue
    write-host “(every second a dot will appear on the end of the next line)” -ForegroundColor gray
    do {
    write-host “.” -nonewline -ForegroundColor Magenta
    start-sleep -second 1
    $xmlFoundLast = $xmlFound
    $xmlFound = (@(get-childitem $cacheFolder0 -filter “*.xml”)).Count
    if( $xmlFound -eq $xmlFoundLast ) {
    $eqCount++
    } else {
    $eqCount = 0
    }
    } while ($eqCount -lt 30)

    Write-Host “”
    Write-Host “Done” -ForegroundColor DarkBlue

    $a = get-content $cacheFileCopy
    $b = get-content $cacheFile

    if( $a -ne $b ) {
    if( [int]$a -gt [int]$b ) {
    write-host “An error occured. the content of the cache file is not identically to it’s value before processing.” -ForegroundColor Red
    write-host “Old: $($a)”
    write-host “New: $($b)”
    } else {
    write-host “MAYBE an error occured. the content of the cache file is not identically to it’s value before processing.” -ForegroundColor DarkYellow
    write-host “Old: $($a)”
    write-host “New: $($b)”
    }
    } else {
    write-host “Processing finished successfully! You need to execute the script on every server!!” -foregroundcolor darkgreen
    remove-item $cacheFileCopy -Force -confirm:$false
    }
    } else {
    write-host “Could not find the cache folder or found too much cache folders!” -foregroundcolor red
    }

  4. Thembane Avatar
    Thembane

    Thanks mate, i googled for days before your valuable info.

    1. derek Avatar
      derek

      Glad to help. Sorry it took so long for you to find the post!

      1. Nektar A Avatar
        Nektar A

        Dear Derek,

        you’d be happy to know that even in 2020 your article is a lifesaver! 🙂
        There are still many old systems under maintenance that need this to get
        back to normal.
        I can’t thank you enough!

  5. Susan Barnes Avatar

    Great post Derek. After reading, I stopped both Forefront services, and then the bad file was deleted, This way I did not have to re-provision the User Profile Sync (always a chore). Thanks for the assist!

  6. Super Dave Avatar
    Super Dave

    you’re Awesome!

Leave a Reply to Chet Chudasama Cancel reply