Does SQL recover databases sequentially, or in parallel?

  • 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:

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • 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

  • 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.

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • 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.

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • 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

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • 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

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply