Hi Friends,

This is my 12th blog on SQL Server Trace Flag 3004 in the series of One Trace Flag a Day. You can go to all blogs under that series by clicking here.

In our day to day work, many times we perform restore operations. Whenever we perform restore operation SQL Server logged some type of restore information in SQL Server error log. This message contains information like how many pages have been processed and how much time taken etc.

There are approx four phases behind a restore operation.

1-      File creation and initialization

2-      Data copy

3-      Roll forward or redo phase

4-      Roll back or undo phase

Now the question is: Can we get restore internal information phase by phase? Yes, we can get that information by using trace flag 3004.

Let me show you this thing practically. First I will show you the message logged under backup operation without any trace flag.

trace_flag_3004_1

Now I will show you the detail information by using trace flag 3004 and 3605.

The message logged in error log is mention below. It contains lots of information for you and sometimes it can be useful for you.

————- Start —————
RestoreDatabase: Database CheckpointTest3
Opening backup set
SetTargetRestoreAge: 0
Restore: Configuration section loaded
Restore: Backup set is open
Restore: Planning begins
Restore: Planning complete
Restore: BeginRestore (offline) on CheckpointTest3
Restore: Attached database CheckpointTest3 as DBID=13
Restore: PreparingContainers
Zeroing F:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014A\MSSQL\DATA\CheckpointTest3.mdf from page 1 to 15872 (0x2000 to 0x7c00000)
Zeroing F:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014A\MSSQL\DATA\CheckpointTest3_log.ldf from page 1 to 8192 (0x2000 to 0x4000000)
Zeroing completed on F:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014A\MSSQL\DATA\CheckpointTest3_log.ldf
Zeroing completed on F:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014A\MSSQL\DATA\CheckpointTest3.mdf
Restore: Containers are ready
Restore: Restoring backup set
Restore: Transferring data to CheckpointTest3
Restore: Waiting for log zero on CheckpointTest3
Restore: LogZero complete
SetTargetRestoreAge: 0
FileHandleCache: 0 files opened. CacheSize: 12
Restore: Data transfer complete on CheckpointTest3
Restore: Backup set restored
Starting up database ‘CheckpointTest3’.
The database ‘CheckpointTest3’ is marked RESTORING and is in a state that does not allow recovery to be run.
Restore-Redo begins on database CheckpointTest3
Restore VLF headers for 4 headers on database CheckpointTest3
Restore VLF headers completed on database CheckpointTest3
RunOfflineRedo logIter.Init(): FirstLsn(PruId: 0): 0x4f:0x4040:0x25
RunOfflineRedo logIter.Init(): LastLsn(PruId: 0): 0x4f:0x4060:0x1
offlineRollforward: StopLsn/LastLsn(PruId: 0): 0x4f:0x4060:0x1
Rollforward complete on database CheckpointTest3
Restore: Done with fixups
Restore: Transitioning database to ONLINE
Restore: Restarting database for ONLINE
Starting up database ‘CheckpointTest3’.
Zeroing F:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014A\MSSQL\DATA\CheckpointTest3_log.ldf from page 5111 to 5591 (0x27ee000 to 0x2bae000)
Zeroing completed on F:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014A\MSSQL\DATA\CheckpointTest3_log.ldf
PostRestoreContainerFixups: fixups complete
PostRestoreReplicationFixup for CheckpointTest3 starts
PostRestoreReplicationFixup for CheckpointTest3 complete
Restore: Database is restarted
Restore is complete on database ‘CheckpointTest3’. The database is now available.
Resuming any halted fulltext crawls
Restore: Writing history records
Database was restored: Database: CheckpointTest3, creation date(time): 2014/09/29(12:06:10), first LSN: 79:16448:37, last LSN: 79:16480:1, number of dump devices: 1, device information: (FILE=1, TYPE=DISK: {‘E:\Checkpoint3_Full_Native_30092014.bak’}). Info
Writing backup history records
Restore: Done with MSDB maintenance
RESTORE DATABASE successfully processed 338 pages in 0.493 seconds (5.356 MB/sec).
RestoreDatabase: Finished
————- End —————

PS: Do not use trace flags in production environment without testing it on non production environments and without consulting because everything comes at a cost.

HAPPY LEARNING!

Regards:
Prince Kumar Rastogi

Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook

Follow Prince Rastogi on Twitter | Follow Prince Rastogi on FaceBook