Database (In Recovery) – Should I panic?

You can if you want, but there’s no need really. But go on, have a bit of a panic….

Done? Great!

Going through some stuff here in preparation for me leaving my current job, and it occurred to me that while I have experienced this, and dealt with it now, that back when I first saw it, I almost did a little wee. This is the fellow I’m talking about

Fire Fire Fire Fire Fire Fire Fire!

I had no idea what it meant, I’d heard terms like “Suspect database” thrown around, and was told I was doomed if I ever saw that (Not necessarily, but have backups!), so naturally I assumed “In Recovery” was what appeared when a database was Suspect (Just FYI, if your database is in suspect mode, it says (Suspect) beside it. Chances are you are all brighter than I am, and would have realised that yourselves).

The good news is, that “In Recovery” is not the same thing, and is in fact not something to panic about. All it means is that the database is performing crash recovery (Read more here), and is blocking access until it gets itself to a transactionally consistent point. It brings the database online, and cycles through the log file making sure it can account for all transactions, re-does any that need applying, and rolls back any that may not have completed at the time of the crash. Just sit tight until it completes, and your database should come back online.

It is possible that it won’t come back up, but they are quite rare, and if it is going to struggle, it will tell you by marking the database suspect. If it seems to be running for an extraordinarily long time, check your error logs to see if it’s giving any hint why. (If not, just let it keep running)

The reason I’m writing about this is that it is quite a common occurrence after certain tasks, so chances are you will come across it at some point. Some of the tasks in question are:

  • Restarts after patching (OS forces the server down, causing in flight transactions to drop)
  • Server crashes
  • SQL Restarts for any purpose (Manual or Automatic)
  • Your database is set to auto_close. Crash recovery will occur any time it’s brought back online
These are all quite common tasks, so don’t panic if you open up management studio and see your databases in that state, just sit tight and crash recovery will complete eventually. It can be quite slow if there was a heavy workload on the DB at the time of the crash, or if there are a lot of VLF’s (Virtual Log Files) in your log file, so once again, don’t panic, it’ll complete eventually.
Just a short one as I came across it. As usual, any questions/comments, please don’t hesitate to contact me.
Stephen

Leave A Comment