Cannot Delete SharePoint Web App (Orphaned DB)
I recently encountered a frustrating SharePoint issue that I hadn't seen in many years and had almost forgotten about. It's a rare problem, but it resurfaced while I was configuring a new SharePoint Subscription Edition farm. I was unable to delete a web application, neither through Central Administration nor with PowerShell using Remove-SPWebApplication due to this error:
Diagnosis
There could be multiple possible causes for this symptom, but one way to reproduce the error is attempting to delete the web application and its content database without the sufficient permission on the SharePoint configuration database. In that scenario, the physical content database is dropped in SQL Server, but removing its reference from the config DB fails -- leaving behind the orphaned entry:
When attempting to delete the web application again after the database permission failure, it triggers the same error as seen in PowerShell above.
Once in this state, standard troubleshooting steps proved ineffective. Without knowing what happened behind the scenes, I tried locating the associated Timer job, restarting the SPTimerV4 and SPAdminV4 services, running iisreset across all farm servers, and even rebooting all the servers. I had no idea which "other objects depended on it", and standard administrative views showed no obvious clues, yet the web application still refused to delete.
The problem lies with the orphaned or corrupted content database object in the config DB that needs to be cleaned up. As you can see below, when you run Get-SPContentDatabase, nothing is returned. However, when you run Get-SPDatabase, it reveals the database of type "Content Database" (ignore the SpFarmAdmin database; it's for the content DB of Central Admin):
Comments
Post a Comment