0% found this document useful (0 votes)
17 views

Transaction Log(T-Log) Architecture

Test

Uploaded by

Mukarram Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Transaction Log(T-Log) Architecture

Test

Uploaded by

Mukarram Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Transaction Log(T-Log) Architecture

SQL Server Uses LSN (Log Sequential Number) for identifying the transaction. Each and every transaction
that comes to log file will associated with LSN number. Roll forward and Rollback operations will be
done internally using these LSN numbers only.

WAL (Write A Head Log): Before commit data in mdf, every transaction should write a entry in log file is
called WAL. Transactions never comes to MDF directly.

Log File divided in to two parts

1. Active Portion or Physical Log


2. In Active Portion or Virtual Log

Active Log Portion: When user performs transactions it will have 3 states

1. Committed in log file and waiting for checkpoint to run


2. Failed in the middle
3. Transactions still running

All these state 3 transactions will be in active portion of log file. When check point runs committed
transactions make a copy in inactive portion and moves to mdf.

In-active Log:

SQL Server maintains fully committed transactions in these portions.

Inactive potion:

This portion only used for taking the backup of log. Whenever we take log backup it copies the inactive
portion and truncates the inactive portion log.

We have 2 types of backups for log portions

Full backup takes the backup of mdf and active portion of the log.

Log backup takes backup of the inactive log portion

This portion we call as virtual log. SQL Server does not use these records that’s y it calls as inactive
virtual logs.

Inactive portion further divided into more virtual logs. We have a property called log reusability. Log
backups copy the inactive portion to a file and truncates the log data. Same space can be used multiple
times called log reusability concept.

Transaction log is a cyclic process of writing log records into virtual logs file by SQL server. Whenever
one virtual log is filled up it will go to next virtual log. If all virtual logs files are filled up the inactive
portion will grow further and creates more virtual logs till, we have space allocated. If it can’t grow
further, it will throw an error “Transaction log for database is full and transaction will fail”

The only way to clear the inactive virtual log is to take the log backup it truncates logs. After truncation
this space will be released. Backup will not actively portion.
Advantages of T-Log:

1. It provides the Transactional consistency


2. It provides transactional recoverability
3. It provides log reusability

Enhancement in SQL Server 2012: Indirect check point

Checkpoint occurs automatically based on workload or by a certain operation internally. We can set SQL
server level recovery interval to run checkpoint by using sp_configure or manually issue a checkpoint
using checkpoint T-SQL Command.

In SQL server 2012, we have enhancement on checkpoint at database level using


TARGET_RECOVERY_TIME option. Increasing time of recovery to seconds or minutes.

Alter database databasename set target_recovery_time=5seconds

Here every 5 seconds checkpoint will run.

You might also like