Monday, September 24, 2018

SharePoint 2016 TIP: successfully patching/upgrading a farm when PSCONFIG fails

Sometimes, psconfig fails and you are unable to upgrade the farm due to problems associated with a content database due to various upgrade-blocking issues discovered in the content database.  Perhaps it's a development farm, and you are testing a content database having a various missing items or other issues.  Not to worry.  You can still upgrade the farm: just leave the problematic content database out of the initial upgrade.  Then, once you get the farm upgraded successfully, you can go back to the content database, mount it, troubleshoot it, and then upgrade it individually. Here's what you do:
  1. After executing psconfig and it fails, review the upgrade report and identify which content database was raising upgrade-blocking problems.
  2. Next, launch an elevated SharePoint Management Shell (if you haven't done so already) and execute the following commandlet to generate a list of content databases and their IDs:
    Get-SPContentDatabase | Select -Property Name,ID,WebApplication, @{e={$_.CurrentSiteCount};l='Sites'}, @{e={($_.DiskSizeRequired/1GB).ToString("0.##")};l='Size(GB)'} | ft -auto
    This commandlet generates a listing of content databases that conveniently also lists the number of sites in the content database as well as its site (in GB).
  3. Note down the ID of the problematic content database.
  4. In the same SMS, execute this commandlet to dismount the content database from the farm:
    Dismount-SPContentDatabase -Identity "[database ID]" -Confirm:$False
  5. Now re-execute psconfig:
    PSCONFIG -cmd upgrade -inplace b2b -wait
  6. Once the farm is successfully upgraded, mount the problematic content database using this commandlet:
    Mount-SPContentDatabase -Name "[database name]" -DatabaseServer "[alias]" -WebApplication "[web application URL]"
    Once you mount the content database, you will eventually see the usual health rule issue popping up, "Databases running in compatibility range: upgrade recommended."
  7. Review the Upgrade log files to identify the upgrade-blocking issues that prevented upgrade earlier.  
  8. Once you get these issues resolved, execute the following commandlet:
    Upgrade-SPContentDatabase -Identity [database ID or name] -UseSnapshot
    Use the -UseSnapshot switch to enable your users to continue to at least read their content while the upgrade process engages.
  9. If this still fails, use the data generated by the test upgrade report to guide your troubleshooting efforts.  First, dismount the database again, and then run this commandlet:
    SCRIPT Test-SPContentDatabase -name "[database name]" -webapplication "[web app URL]" | Export-CSV -Path "C:\UPGRADE.TEST.001.CSV"
  10. tbd

References

Notes

  • If you run psconfigui.exe and it fails, this failure will be entered into the Upgrade Status page in Central Administration.  Oddly, I have found that if I run psconfigui.exe again and it succeeds, this success won't be entered into the Upgrade Status list, even though the psconfigui.exe dialog plainly states that the upgrade succeeded.  What I have done then, to ensure that successful configuration is also noted on the Upgrade Status page, is to execute psconfig.exe (the non-UI version), and the successful completion of this is then reflected in the Central Administration Upgrade Status page.