What happens when a SQL Server instance is restarted?
Have
you ever wondered or got curious to know what will happen or what are
the activities carried out when an SQL Server instance get a restart
request?
With this post I am trying to list down the activities that happen during the restart of a SQL server instance, may be the sequence is not correct and the list might be incomplete. In that case, you can always correct me and complete the list. J
First of all, the service stops and before the service stops,
Recovery Phases - Drill Down
SQL Server instance will stop
and then start again. Yes, this is obvious and there are lot more things
that happen when a restart command is issued on an SQL Server instance.
With this post I am trying to list down the activities that happen during the restart of a SQL server instance, may be the sequence is not correct and the list might be incomplete. In that case, you can always correct me and complete the list. J
First of all, the service stops and before the service stops,
- Checkpoint is issued on all databases
- Check for the jobs that are running and stop them
- Release the locks on database files to Operating System
- Release the memory used by SQL Server instance
- Flush the metadata collected for DMV’s and DMF’s
- Record an event in default trace and event viewer regarding the SQL Server instance shutdown
- The service is authenticated by verifying the credentials provided in the logon account and the service is started.
- Startup parameters (master database data file path, log file path and error log file path, etc… if any) are verified
- The port on which SQL server is listening is opened.
- Memory is allocated
- Read master database metadata for information about user databases
- Attach all the user database
- Undergo database recovery phases (Analysis, redo and undo phases.)
- Obtain lock on the database files
- tempdb files are allocated based on the initial size settings and other setting like collation are copied from model database.
- An entry to default trace is recorded about the start of SQL Server instance
- All the events are recorded to SQL Server log file and event viewer
- Accept connections to databases
- Start the metadata collection for DMV’s and DMF’s
- Recompile Stored Procedures
Phases of Database recovery
From my previous post “What happens when a SQL Server instance is restarted?” we know what activities will be carried out when the SQL Server instance gets restart request.
Now, it’s time to understand what recovery phases the database will undergo.
The databases undergo recovery phases in two scenarios
The databases undergo recovery phases in two scenarios
- When the SQL server or service is restarted
- When the database is being restored.
Recovery Phases - Drill Down
Recovery Phases - Graphical
No comments:
Post a Comment