August 13, 2012 at 11:44 am
Possibly an easy question, and one I hope I'll never find the answer to in person. If I have a problem that causes SQL to have to recover databases (say a power failure on a server with no UPS {HYPOTHETICAL!!}) will SQL recover the databases in sequence (perhaps via the database ID,) or will it recover them in parallel (work on bringing up all of the databases at once)
Presumably, the system DBs would need to come up first, so this would be after that.
I'm partly looking for this for my own personal knowledge, and partly to disaster plan for a system.
Thanks,
Jason A.
(I suppose if no one is entirely sure, I will go ahead and setup a couple test DBs on my workstation, start inserting rows in a transaction, then pull the power cord...):Whistling:
August 13, 2012 at 11:55 am
they are recovered , sequentially, master database first.; but each database seems to get it's own spid to startup, and some spids finish before others spids created after it.
if one fails, it moves on to the next database, so you might see some that do not recover at all.
if you look at the SQL Logs , you can see it for yourself;
SSMS Object Explorer:
>> Expand Server Name>>Management>>SQL Server Logs>>Current
on my server, on the last reboot, i see them in this order:
i don't see them recovering in db_id order, which i kind of expected.
I do see the spids created in database id order, though.
master
model
tempdb
[one specific userdatabase]
msdb
[other user Databases]
Lowell
August 13, 2012 at 12:00 pm
SQL recovers all databases every time it starts. It's not something that happens in a disaster, it's a normal operation on startup.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 13, 2012 at 12:24 pm
Plan on restoring them one at a time. You can open multiple windows and start multiple restores, but you'll see very poor performance. Better to know the order that you wish to recover in rather than trying to do them all at the same time. This is especially true if the backups are on shared media (all the backups in the same location).
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
August 13, 2012 at 12:51 pm
GilaMonster (8/13/2012)
SQL recovers all databases every time it starts. It's not something that happens in a disaster, it's a normal operation on startup.
So in terms of the user DBs, is it sequential, or serial?
Thanks,
Jason A.
August 13, 2012 at 1:01 pm
They recover in parallel. Multiple spids are spawned to recover each of the user databases. User databases will only get recovered after the system ones are recovered.
You can see this for yourself if you look at the SQL error log and look at the sequence of the database recovery messages.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 13, 2012 at 1:02 pm
GilaMonster (8/13/2012)
They recover in parallel. Multiple spids are spawned to recover each of the user databases. User databases will only get recovered after the system ones are recovered.You can see this for yourself if you look at the SQL error log and look at the sequence of the database recovery messages.
Cool, thank you!
Jason A.
August 13, 2012 at 1:18 pm
Why is knowing this important for disaster recovery?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 13, 2012 at 2:25 pm
It was primarily to be able to give a rough estimate of how long it might take for a system to be ready to use again for all the DBs on it. I know the time to recover will depend on if there was a transaction in progress, and how big that transaction was, but with the DBs in question, there should be few, if any, long-running transactions.
Thanks again,
Jason
August 13, 2012 at 2:53 pm
Be careful with that assumption...
I've had a DB that only had long-running transactions overnight. During the day it was short transactions and mostly reads. After a crash at 3pm one day it took a little over 12 hours to recover.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 13, 2012 at 2:56 pm
Yeah, I know what they say about assumptions...
Ouch.
My hope is that I'll never need to worry about this, that the system will rarely need to be restarted and that the SQL service will never need to be restarted...
(need a fingers crossed smiley)
Jason
August 13, 2012 at 3:17 pm
Generally it's not the controlled restarts that are the problem. 😉
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 12 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply