• subscribe

When scheduled maintenance jobs collide…


Posted @ 12/15/2011 10:59 AM By Paul Randal

 

Question: I’ve started seeing a problem where periodically the scheduled DBCC job fails and I get 823 errors in the error log. I also see errors from the file system too. Is this an I/O subsystem problem?

Answer: These errors are not caused by I/O subsystem issues, although outwardly they seem to be.

Under the covers all of the DBCC CHECK commands create a hidden database snapshot. When the database snapshot is created, any active transactions in the database are effectively rolled back into the database snapshot (not affecting the real transactions, of course) so that the database snapshot is transactionally consistent. Also, while the database snapshot exists, any data file pages in the real database that are going to change need to be copied into the database snapshot before they change so that their state at the time the database snapshot was created is preserved.

These two factors mean that there is the potential for the database snapshot to grow very large – potentially up to the size of the real database. If that happens, there is the possibility that the database snapshot may exceed the size that NTFS can cope with and error 665 will result, as below:

The operating system returned error 665(The requested operation could not be completed due to a file system limitation) to SQL Server during a write at offset 0x000005bd3dc000 in file 'Test.mdf:MSSQL_DBCC8'

This error comes from Windows Server 2008 – Windows Server 2003 will give error 1450. You can read more about this in this blog post from Product Support. You may see a variety of SQL Server errors too – including 823, 7928, 1823, and 3314. Check to make sure that the 823 errors are referencing a file with a name like ‘MSSQL_DBCC’ (the database snapshot files) rather than one of the real database data files. If the latter then  you have a real I/O subsystem problem.

If you’re seeing these errors when you’re running your consistency checking job at a time when there shouldn’t be any user activity, the likely cause is that the consistency checking job has overlapped with another job that is causing a lot of activity in the database – maybe a data loading job or routine index maintenance.

We had one case recently that was caused by the index maintenance job running much longer than it should have been. When the database snapshot was created for the DBCC command, an entire index rebuild of a very large clustered index had to be rolled back, leading to the database snapshot size exceeding the NTFS limit and failing.

In this case, rather than relying on expected maintenance job run times, create a system where a potentially long-running job kicks off a job that cannot overlap with it – i.e. an index maintenance job that starts the consistency checking job.

Related Content:

Comments

Add A Comment
  • Posted @ December 23, 2011 08:55 AM by TheSQLGuru

    I absolutely LOVE the free SQLJOBVIS tool for showing SQL Agent jobs in a gantt-style layout so you can not only see completion status but much more importantly visually see job execution overlaps!

You must log on before posting a comment.

Are you a new visitor? Register Here


More about Kimberly and Paul . . .

Paul worked on the SQL Server team for nine years in development and management roles, writing many of the DBCC commands, and he was ultimately responsible for SQL Server 2008’s core storage engine. Paul blogs at SQLskills.com/blogs/Paul.

Kimberly worked on the SQL Server team in the early 1990s as a tester and writer before leaving to found SQLskills and embrace her passion for teaching and consulting. Kimberly blogs at SQLskills.com/blogs/Kimberly.

They've written Microsoft white papers and books for SQL Server 2008, 2005 and 2000, and they're regular, top-rated presenters worldwide on database maintenance, high availability, disaster recovery, design, performance tuning, and SQL Server internals. Together they teach SQLskills Immersion Events, which are wildly popular classes that teach the essential skills required to be an effective DBA; these classes also cover the required topics of the Microsoft Certified Master (MCM) certification.


Check out Kimberly and Paul’s SQLskills website for more information about their upcoming speaking engagements.