I get the following error within my maintenance plans:
Executing the query "DBCC CHECKDB(N'master') WITH NO_INFOMSGS "
failed with the following error: "The database could not be
exclusively locked to perform the operation. Check statement aborted.
The database could not be checked as a database snapshot could not be
created and the database or table could not be locked. See Books
Online for details of when this behavior is expected and what
workarounds exist. Also see previous errors for more details.".
Possible failure reasons: Problems with the query, "ResultSet"
property not set correctly, parameters not set correctly, or
connection not established correctly.
I get the following when I run the code from the query analyzer:
USE [master]
GO
DBCC CHECKDB(N'master') WITH NO_INFOMSGS, PHYSICAL_ONLY
Msg 5030, Level 16, State 12, Line 1 The database could not be
exclusively locked to perform the operation. Msg 7926, Level 16, State
1, Line 1 Check statement aborted. The database could not be checked
as a database snapshot could not be created and the database or table
could not be locked. See Books Online for details of when this
behavior is expected and what workarounds exist. Also see previous
errors for more details.
I've searched high and low trying to find a fix, but no dice.
FACTS:
- SQL Server 2008 R2 Standard 64-bit (10.50.4000.0)
- Windows Server 2008 R2 64-bit w/SP1
- VMWare Virtual Machine
- Production server, so I can't reboot server/instance without internal change management process
- SQL Server Agent & Database Engine service accounts have full access to the folders and files where the MDFs and LDFs are housed
- Restarted SQL Server Agent via Config Mgr.
- SQL Server Agent has read permissions on the entire volume
- There are no read-only FGs
- DBs are not in Single-user mode, read-only, or in emergency mode
- Not running TABLOCK with DBCC command
- The DBs are on NTFS
The following are a few places I've read out of many, but these are the most applicable to my matter as I see it. I've performed the suggested "fixes" with no change in result or error message output from the SQL Server Error Logs.
Best Answer
There is an internal snapshot that SQL Server will try to create when you run certain DBCC commands. There is really good information about this on the BOL reference for DBCC.
The master database is particularly interesting with this, as if the internal snapshot can't be created then DBCC CHECKDB will fail against master. As per the above reference:
So, what can cause the internal snapshot creation to fail? The above reference has a nice list:
My recommendation is to look at that information and find which one is applying to your situation. That should answer your question and move towards the resolution.