Disclaimer: Since it turned out to be an access violation issue on SQL
server and not related to Sitecore not sure if this question belongs
to this community, I leave that up to the moderators. 😊
Issue Summary:
After a restart of SQL Server 2016, Core and Master databases are online and accessible on SQL Server. When the application starts, these two databases go into recovery pending state and cannot be accessed. Once SQL Server is restarted again they come back online. Each time the databases go into recovery pending, SQL Server issues a stack dump. After review of the dump, I have found an EXCEPTION_ACCESS_VIOLATION in function CSecCtxtCacheStore. We see the following error logs:
2019-04-15 11:35:15.00 spid67 SqlDumpExceptionHandler: Process 67 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
2019-04-15 11:35:15.00 spid67 * *******************************************************************************
2019-04-15 11:35:15.00 spid67 *
2019-04-15 11:35:15.00 spid67 * BEGIN STACK DUMP:
2019-04-15 11:35:15.00 spid67 * 04/15/19 11:35:15 spid 67
2019-04-15 11:35:15.00 spid67 *
2019-04-15 11:35:15.00 spid67 *
2019-04-15 11:35:15.00 spid67 * Exception Address = 00007FFD7876F4AE Module(sqllang+000000000000F4AE)
2019-04-15 11:35:15.00 spid67 * Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION
2019-04-15 11:35:15.00 spid67 * Access Violation occurred reading address 0000000000001278
An Access Violation (AV) occurs when a program performs an action on a memory address however that action is not allowed. Memory page will be set with proper memory protection option during allocating or protecting calls. If an application access a memory address which does not align with the page protection for that memory, Access Violation exception will be thrown.
The most common AV pattern will be a read or write to address 0 (zero). A common programming issue involves several scenarios where the programmer expects a value to be a valid address, but for whatever reason it did not get set properly (e.g. a function failed and returned 0 or null instead of the expected value).
Resolution:
We raised a case with Microsoft Support and they identified it as a known problem with SQL Server 2016. Support suggested us to apply a cumulative update which resolved the issue:
https://support.microsoft.com/en-us/help/4488536/cumulative-update-6-for-sql-server-2016-sp2