+ All Categories
Home > Documents > Transaction Log Internals Dharmendra Keshari President - KDSSG.

Transaction Log Internals Dharmendra Keshari President - KDSSG.

Date post: 19-Jan-2016
Category:
Upload: marion-dean
View: 237 times
Download: 4 times
Share this document with a friend
Popular Tags:
17
Transaction Log Internals Dharmendra Keshari President - KDSSG
Transcript
Page 1: Transaction Log Internals Dharmendra Keshari President - KDSSG.

Transaction Log InternalsDharmendra KeshariPresident - KDSSG

Page 2: Transaction Log Internals Dharmendra Keshari President - KDSSG.

Who Am I….

Reachable at:https://sg.linkedin.com/pub/dharmendra-keshari/98/433/a70https://www.facebook.com/dharmendra.keshari.9Dharmendra.Keshari@[email protected] - +65-83895125

With 8+ years of working experience, Dharmendra Keshari has strong and in-depth Experience in Database Management. Currently, work as Senior Database Administrator in Working one of the best Semi-Government companyIn Singapore. His experience in executing critical projects on large scale,combined with providing day-to-day solutions, gives him unique ability to solve several complex Database problems. He is an avid and regular mentor on social media, helping several techies in solving problems related to Database management.

Certified on Administering; – Microsoft SQL Server® 2008, Implementation and Maintenance– Administering Microsoft SQL Server 2012 Database

Major Key skills set areas;

Performance and Tuning of SQL Server Database Virtualization and Consolidation HA Solution on Instance and Database Level

Page 3: Transaction Log Internals Dharmendra Keshari President - KDSSG.

Transaction Log File

• Transaction file is the place where we store transaction log records.

Basic Terminology of Transaction Log…..

Transaction• Any change to a database is done within confine, the confine is known as

a transaction & every transaction will have TransactionID.

• There are some transactions which are non-transactional.

Log Record• A Log records is a description of a single change or small change to a

database. A transaction may be consisting of single or multiple log records.

Commit• It means finalizing a transaction. In other words, Commit makes

transaction durable meaning we can’t roll back any transaction if they have been committed.

Roll Back• Roll back transaction means aborting a transaction. It means it is going to

remove all the changes that have been marked to a database and it will bring the database in the old state where it was.

Page 4: Transaction Log Internals Dharmendra Keshari President - KDSSG.

Checkpoint • Checkpoint is a mechanism that write out dirty data-file pages to disk after an interval. It helps to reduce disk I/O and recovery interval time.

Basic Terminology of Transaction Log (2)

Crash• If a SQL Server instance shuts down unexpectedly and databases couldn’t

get chance to close all the active transactions. This is known as crashing of SQL Server.

Recovery• When a database needs to be made transitionally consistent, after a fraction

of second crashes occurred then recovery has to run. If the recovery is running because of crash that is called crash recovery.

Page 5: Transaction Log Internals Dharmendra Keshari President - KDSSG.

Transaction Log Architecture

Page 6: Transaction Log Internals Dharmendra Keshari President - KDSSG.
Page 7: Transaction Log Internals Dharmendra Keshari President - KDSSG.
Page 8: Transaction Log Internals Dharmendra Keshari President - KDSSG.

VLF Sequence Number

Log Block Sequence Number Log Record Sequence Number

Page 9: Transaction Log Internals Dharmendra Keshari President - KDSSG.

DEMO : Basic Terminology & Log Architecture

Page 10: Transaction Log Internals Dharmendra Keshari President - KDSSG.

VLFs Algorithm & Management

Page 11: Transaction Log Internals Dharmendra Keshari President - KDSSG.

<= 2012

VLF Creation Algorithm…..• <=1MB, it is going to create 2 new VLF (Each VLF’s ½ of the growth size)

• >1MB to <=64MB, it’s going to create 4 new VLFs (Each VLF’s ¼ of the growth size)

• >64MB to <=1GB, it’s going to create 8 new VLFs (Each VLF’s 1/8 of the growth size)

• >1 GB, it is going to created 16 new VLF (Each VLF’s 1/16 of the growth size)

For

SQL Server 2014

• If the growth size is less than 1/8 the size of the current log size?

• YES : Create 1 new VLF equal to the growth size

• NO: use the above formula

Page 12: Transaction Log Internals Dharmendra Keshari President - KDSSG.

DBCC LOGINFO…..Recovery Unit ID • Added in SQL server 2012 but as of now it is unused.

FileId • Transaction log file ID with in the database.

FileSize • It is the size of the VLF in bytes not of the transaction log file.

StartOffset • The offset of the VLF within the entire transaction log files; starts with 8192 bytes that’s because file header and it does not store log records.

Status • Whether the VLF is active or not (0 = inactive, 2 = active, 1 is not used)

FSeqNo • VLF sequence number for very first VLF in a new database is whatever the model database highest VLF sequence number is + 1.

Parity • Every time a VLF is reused, the parity value is switched. It has three different values.

CreateLSN • When the log file (or DB was first created) was initially created, LSN number is 0. All other VLF that added after the initial creation of the log file will have non zero CreateLSN

Page 13: Transaction Log Internals Dharmendra Keshari President - KDSSG.

Log Records…..• What are Log Records?

• What are “Log Record” Contents?

• Log Records in Transactions?

• What is Log Space Reservation?

• What are the “Log Record” Types?

• What is COMPENSATION Log Records ?

Lo

g R

eco

rds

Op

erat

ion

s

Page 14: Transaction Log Internals Dharmendra Keshari President - KDSSG.

DEMO :

VLF CREATION|DBCC LOGINFO|LOG RECORD

Page 15: Transaction Log Internals Dharmendra Keshari President - KDSSG.

Known Issues…..• Slow performance when you recover a database if there are many VLFs inside the

transaction log in SQL Server 2005, in SQL Server 2008 or in SQL Server 2008 R2

https://support.microsoft.com/en-us/kb/2455009

• Certain database operations take a very long duration to complete or encounter errors when the transaction log has numerous virtual log files

https://support.microsoft.com/en-us/kb/2028436

• Transaction Log VLFs – too many or too few?

http://www.sqlskills.com/blogs/kimberly/transaction-log-vlfs-too-many-or-too-few/

• Bug: log file growth broken for multiples of 4GB

http://www.sqlskills.com/blogs/paul/bug-log-file-growth-broken-for-multiples-of-4gb/

• Can log files growth affect DML? Post-CU Update http://blogs.msdn.com/b/blogdoezequiel/archive/2011/04/26/can-log-files-growth-affect-dml-post-cu6-update.aspx#.VbDOpukViM9

• Can log files growth affect DML? http://blogs.msdn.com/b/blogdoezequiel/archive/2010/10/26/can-log-files-growth-affect-dml.aspx#.VbDIXukViM9

VLF

Fra

gmen

tatio

n’s

Issu

e

Page 16: Transaction Log Internals Dharmendra Keshari President - KDSSG.

Question and Answer !!!!

Page 17: Transaction Log Internals Dharmendra Keshari President - KDSSG.

Thank you for attending Tech Unite


Recommended