SQL SERVER – Fix: The operating system returned error 21(The device is not ready.)

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.

SQL SERVER - Fix: The operating system returned error 21(The device is not ready.) error21-800x430

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)

Computer Network, SQL Error Messages, SQL Server
Previous Post
Ask the Experts: Database Performance Roundtable by Quest
Next Post
SQL SERVER – What is Latch?

Related Posts

6 Comments. Leave new

  • Pinal, we received this error when we changed the disk in Azure.

    Reply
  • Guntur Sulaeman
    February 23, 2021 9:19 am

    Thank you very much sir. it was solve my problem

    Reply
  • Works like a charm. Thanks.

    Reply
  • The operating system returned error 21(The device is not ready.) to SQ
    Server during a read at offset 0x0000000017 c000 in file
    “D: RDSDBDATA\DATA\
    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 CHECKDE. This error can be caused by many factors; for more information, see SQL Server Books Online

    Reply
  • how to solve

    Reply
  • In my case I had to turn off fast startup (Windows 11) to solve the problem.

    Reply

Leave a Reply