Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Viewing all articles
Browse latest Browse all 3160

SQL SERVER Database going to Recovery Pending Automatically and Coming Back

$
0
0

I love connecting community via various channels. One of my clients explained an interesting issue to me. He explained that he has a production database which is going to Recovery Pending state by itself and without any user intervention, it’s coming back as well.


SQL SERVER   Database going to Recovery Pending Automatically and Coming Back

As you might have seen my earlier post, I always start by asking SQL Server ERRORLOG file to see if there are some interesting messages.

SQL SERVER Where is ERRORLOG? Various Ways to Find ERRORLOG Location

Here is what I saw in ERROLOG which made complete sense about the behavior.

2016-07-16 17:06:00.38 spid58 Starting up database ‘ProdDB’.

2016-07-16 17:06:01.40 spid58 Error: 17204, Severity: 16, State: 1.

2016-07-16 17:06:01.40 spid58 FCB::Open failed: Could not open file G:\mssql11.MSSQLSERVER\MSSQL\DATA\ProdDB_log.ldf for file number 2. OS error: 32(The process cannot access the file because it is being used by another process.).

2016-07-16 17:06:01.42 spid58 Error: 5105, Severity: 16, State: 1.

2016-07-16 17:06:01.42 spid58 A file activation error occurred. The physical file name ‘G:\MSSQL11.MSSQLSERVER\MSSQL\DATA\ProdDB_log.ldf’ may be incorrect. Diagnose and correct additional errors, and retry the operation.

2016-07-16 17:06:01.45 spid58 Error: 5170, Severity: 16, State: 1.

2016-07-16 17:06:01.45 spid58 Cannot create file ‘G:\MSSQL11.MSSQLSERVER\MSSQL\DATA\ProdDB_log.ldf’ because it already exists. Change the file path or the file name, and retry the operation.

2016-07-16 17:06:01.45 spid58 Error: 5170, Severity: 16, State: 1.

2016-07-16 17:06:01.45 spid58 Cannot create file ‘G:\MSSQL11.MSSQLSERVER\MSSQL\DATA\ProdDB_log.ldf’ because it already exists. Change the file path or the file name, and retry the operation.

Since the database was getting started (another issue) it was trying to get the file handle and open the files. Due to “OS error: 32(The process cannot access the file because it is being used by another process.).” SQL was unable to open files and hence going to Recovery Pending state.

Now, the questions are

Why database is getting started automatically? Which is the “another” process which is having open handle on the files.

For the first issue, you can read my earlier blog!

SQL SERVER Starting Up Database Why Multiple Times in Errorlog?

While investigating I found that they had Antivirus running on the server, which was doing “On-Access” scan which was causing SQL to not get handle and cause OS error 32. If you have not seen earlier, here is the Microsoft knowledge base article on the same topic.

How to choose antivirus software to run on computers that are running SQL Server

Once we fixed Auto_Close setting and added file exception for MDF, LDF files, the issue never occurred.

Have you ever encountered such behavior?

Reference: Pinal Dave ( http://blog.sqlauthority.com )


Viewing all articles
Browse latest Browse all 3160

Trending Articles