SharePoint 2016 Troubleshooting: Database with Id [ID] was not found in database collection. Returning null.

Problem

You mount a SharePoint Server 2013 content database to a SharePoint Server 2016 web application in order to perform a test upgrade.  You then launch a browser and connect to a site within the content database, but then experience an error:

Sorry, something went wrong

An unexpected error has occurred

TECHNICAL DETAILS

You had created this content database on the SharePoint Server 2013 farm and moved a couple of 2013 site collections into it that you had scheduled for test upgrade to 2016.  This was a second test upgrade.  Previously, the first time you performed this test, you had created the 2016 web application, mounted the 2013 content database, the upgrade had completed, and connecting to a site in the content database went just fine.  Therefore, it was unclear why an error was encountered for this second test upgrade of these same site collections. 

Reviewing the ULS log for the correlation ID, you find the following curious entries:

Getting content database 9cc07d24-90bd-4d28-8400-589ae4464272 from webApp 810db0f1-edf7-4998-8ccf-7171a17fbf78 version 3325622.

Database with Id 9cc07d24-90bd-4d28-8400-589ae4464272 was not found in database collection. Returning null.

The content database presented in this log entry was not the ID of the content database you had just mounted but the ID of the content database you had previously mounted for the first test and that you had dismounted just prior to mounting the current one.

You then dismount the current content database and then re-mount it again but still experience the error when connecting to a site in the content database.  You then dismount it and then mount it to another web application in the 2016 farm and find that now sites in the content database render successfully in the browser.  

Solution

Perform an IISRESET /NOFORCE of the farm's web front end servers after mounting the content database. In this particular case, an IISRESET is needed after performing a mount operation, if the new content database being mounted to the web application contains the same site collections as the content database you just dismounted from the web application.  In a sense, it appears that the farm web application retained some memory of the content database previously mounted to it and the site collections it contained:

  • If the current content database is dismounted from a web application and a new one is mounted in its place, if that content database contains different site collections than the previously mounted content database, everything is reset automatically and sites are rendered just fine in web browsers as soon as the mount operation completes.  In this case, the site collection IDs and the ID of the database containing these site collections are both different from what was previously mounted to the web application.
  • If however the current content database is dismounted from a web application and a new one is mounted in its place that contains the same site collections as the previous one, the web application attempts to return content from a database having the old ID.  In this case, the site collection IDs are the same as previous, but the ID of the content database containing these site collections is different.

References

Notes

  • The ULS log entries associated with the Mount-SPContentDatabase operation were found in the ULS logs on the farm server hosting Central Administration, which was also the server that Mount-SPContentDatabase was executed on.

SharePoint 2016 Troubleshooting: Database with Id [ID] was not found in database collection. Returning null. BrensArticles, en-US, has solution, Has TOC, SharePoint 2016 Administration, troubleshooting