
These are the steps that I'd followed and the issue finally resolved. All commands were ran on the App server.
- Ran below scripts that did not fix the issue
$db = Get-SPContentDatabase "dbName" ;$db.RefreshSitesInConfigurationDatabase(); - Ran Get-SPDeletedSite. Did not fix the issue
- Ran Get-SPDeletedSite | Restore-SPDeletedSite. Did not fix the issue
- Ran Dismount-SPContentDatabase "dbName". No error this time. It ran successfully.
- Checked in Central Administration that the DB was dismounted and it was.
- Checked the website in a browser to see if it did not load which was an expected behavior.
- Ran below script to test the DB. No errors.
test-spcontentdatabase -name "dbName" -webapplication "webURL" - Ran the below script. No errors returned.
Mount-SPContentDatabase "dbName" -DatabaseServer "dbServer" -WebApplication "webURL" - Checked in Central Administration to see if DB was attached and it was. Checked if DB was listed under site collection and it was.
- Checked the website in a browser and got the same error as before.
- Ran the below script to see if anything came up from the script and it did.
Get-SPSite "webURL" - Checked the website in a browser and got the same error as before.
- Ran below script again and checked site and it finally comes up.
$db = Get-SPContentDatabase "dbName";$db.RefreshSitesInConfigurationDatabase();
I still don't understand the cause of the issue. I'd dismounted and mounted a different web application before running the steps above and it worked fine. Maybe mounting the Prod DB before dismounting the Stage DB caused issues initially.