While doing this for one of my clients, they had an interesting issue. The informed that they noticed that sometimes, very randomly, one of their databases go to recovery pending state. As a usual troubleshooting step, I checked SQL Server ERRORLOG to see if there is anything interesting about the database. SQL SERVER – Where is ERRORLOG? Various Ways to Find ERRORLOG Location
Here is the filtered information for one of the database HRFINDB
2018-05-16 11:16:00.38 spid58 Starting up database ‘HRFINDB’.
2018-05-16 11:16:01.40 spid58 Error: 17204, Severity: 16, State: 1.
2018-05-16 11:16:01.40 spid58 FCB::Open failed: Could not open file T:\MSSQL12.MSSQLSERVER\MSSQL\DATA\HRFINDB_log.ldf for file number 2. OS error: 32(The process cannot access the file because it is being used by another process.).
2018-05-16 11:16:01.42 spid58 Error: 5105, Severity: 16, State: 1.
2018-05-16 11:16:01.42 spid58 A file activation error occurred. The physical file name ‘T:\MSSQL12.MSSQLSERVER\MSSQL\DATA\HRFINDB_log.ldf’ may be incorrect. Diagnose and correct additional errors, and retry the operation.
2018-05-16 11:16:01.45 spid58 Error: 5170, Severity: 16, State: 1.
2018-05-16 11:16:01.45 spid58 Cannot create file ‘T:\MSSQL12.MSSQLSERVER\MSSQL\DATA\HRFINDB_log.ldf’ because it already exists. Change the file path or the file name, and retry the operation.
I also found many starting up messages like below.
2018-05-14 15:27:03.80 spid61 Starting up database ‘HRFINDB’.
2018-05-14 15:27:08.23 spid54 Starting up database ‘HRFINDB’.
2018-05-14 15:28:20.02 spid52 Starting up database ‘HRFINDB’.
2018-05-14 15:29:46.88 spid54 Starting up database ‘HRFINDB’.
2018-05-14 15:29:48.20 spid54 Starting up database ‘HRFINDB’.
I immediately recalled message as I blogged about it long ago.
So, have changed the Auto_Close to OFF for database ‘HRFINDB’ and we didn’t see same behavior again. I also help them to configure antivirus settings as per above article.
Reference: Pinal Dave (https://blog.sqlauthority.com)