The other day, I received an email from my client of Comprehensive Database Performance Health Check. The client was in very much panic as they were getting the following error – The operating system returned error 21(The device is not ready.)
The operating system returned error 21
Here is the complete description of the error on the screen.
The operating system returned error 21(The device is not ready.) to SQL Server during a read at offset 0x00000004e92000 in file ‘D:\data\AdventureWorks.mdf’. Additional messages in the SQL Server error log and operating system error log may provide more detail. This is a severe system-level error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online. (Microsoft SQL Server, Error: 823)
It was indeed scary for the client as the error suggested that there is an error at the system level and additionally, there may be issues with integrity. They very much panicked and reached out to me asking if I can help them.
While, in my career, I have resolved many database corruption issues and I know when the database is corrupted one should not start the SQL Server at all. It is best to leave this issue to the experts. However, in this case, I knew my client and I knew their workload as well as the error. Here is what I suggested to them and it fixed the issue.
Workaround / Solution:
I knew my client and their infrastructure, I also knew their workload very well. I suggested them to restart the SQL Server Services. Once they restarted their SQL Server services, everything came to normal like the error did not happen.
The error had happened in their case because of the network issue, where SQL Server could not reach the database file. When we restarted the server it fixed it.
However, if you have a real corruption and you start your SQL Server, you will be in big big trouble. I strongly suggest to reach out to expert when you get any error related to DBCC CHECKDB or error 21.
Reference: Pinal Dave (https://blog.sqlauthority.com)