SQL Server Transaction Log from A to Z



Similar documents
Transaction Log Internals and Troubleshooting. Andrey Zavadskiy

Understanding and Controlling Transaction Logs

Boost SQL Server Performance Buffer Pool Extensions & Delayed Durability

Outline. Failure Types

Best Practices for Optimizing SQL Server Database Performance with the LSI WarpDrive Acceleration Card

Recovery and the ACID properties CMPUT 391: Implementing Durability Recovery Manager Atomicity Durability

W I S E. SQL Server 2008/2008 R2 Advanced DBA Performance & WISE LTD.

DBTech EXT Backup and Recovery Labs (RCLabs)

Hekaton: SQL Server s Memory-Optimized OLTP Engine

Information Systems. Computer Science Department ETH Zurich Spring 2012

sql server best practice

PERFORMANCE TUNING IN MICROSOFT SQL SERVER DBMS

Optimizing SQL Server 2012 for SharePoint SharePoint Saturday/Friday, Honolulu March 27, 2015

Microsoft SQL Server OLTP Best Practice

Configuring Apache Derby for Performance and Durability Olav Sandstå

Jason S Wong Sr. DBA IT Applications Manager DBA Developer Programmer M.S. Rice 88, MBA U.H. 94(MIS)

WITH A FUSION POWERED SQL SERVER 2014 IN-MEMORY OLTP DATABASE

tairways handbook SQL Server Transaction Log Management

SAP HANA - Main Memory Technology: A Challenge for Development of Business Applications. Jürgen Primsch, SAP AG July 2011

David Dye. Extract, Transform, Load

Improve Business Productivity and User Experience with a SanDisk Powered SQL Server 2014 In-Memory OLTP Database

SQL Server 2014 In-Memory Tables (Extreme Transaction Processing)

The Database is Slow

ESSENTIAL SKILLS FOR SQL SERVER DBAS

COS 318: Operating Systems

Everything a DBA Needs to Know About Storage

Administering Microsoft SQL Server 2012 Databases

Performance Monitoring AlwaysOn Availability Groups. Anthony E. Nocentino

Backup and Restore Back to Basics with SQL LiteSpeed

The 5-minute SQL Server Health Check

MS SQL Server 2014 New Features and Database Administration

Oracle Architecture. Overview

Recovery Principles in MySQL Cluster 5.1

Last Class Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications

Handling a Full SQL Server Transaction Log

Microsoft SQL Server Always On Technologies

Storage in Database Systems. CMPSCI 445 Fall 2010

Hardware/Software Guidelines

UVA. Failure and Recovery. Failure and inconsistency. - transaction failures - system failures - media failures. Principle of recovery

Mind Q Systems Private Limited

Windows NT File System. Outline. Hardware Basics. Ausgewählte Betriebssysteme Institut Betriebssysteme Fakultät Informatik

Outline. Windows NT File System. Hardware Basics. Win2K File System Formats. NTFS Cluster Sizes NTFS

Crashes and Recovery. Write-ahead logging

SQL Server 2012 Database Administration With AlwaysOn & Clustering Techniques

SQL Server Encryption Overview. September 2, 2015

SQL Server 2014 New Features/In- Memory Store. Juergen Thomas Microsoft Corporation

Transaction Management Overview

MS SQL Performance (Tuning) Best Practices:

Crash Recovery. Chapter 18. Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke

SQL Server Instance-Level Benchmarks with HammerDB

MOC 20462C: Administering Microsoft SQL Server Databases

CASE STUDY: Oracle TimesTen In-Memory Database and Shared Disk HA Implementation at Instance level. -ORACLE TIMESTEN 11gR1

Chapter 16: Recovery System

Transactions and Recovery. Database Systems Lecture 15 Natasha Alechina

SQL SERVER Anti-Forensics. Cesar Cerrudo

File System Management

Would-be system and database administrators. PREREQUISITES: At least 6 months experience with a Windows operating system.

Module 07. Log Shipping

Agenda. Transaction Manager Concepts ACID. DO-UNDO-REDO Protocol DB101

Informix Performance Tuning using: SQLTrace, Remote DBA Monitoring and Yellowfin BI by Lester Knutsen and Mike Walker! Webcast on July 2, 2013!

Recovery: Write-Ahead Logging

Parallel Replication for MySQL in 5 Minutes or Less

DataBlitz Main Memory DataBase System

Deploying Affordable, High Performance Hybrid Flash Storage for Clustered SQL Server

Accelerating Server Storage Performance on Lenovo ThinkServer

Best Practices. Best Practices for Installing and Configuring SQL Server 2005 on an LSI CTS2600 System

Oracle Redo Log Performance Issues and Solutions

Whitepaper: performance of SqlBulkCopy

Course 55144: SQL Server 2014 Performance Tuning and Optimization

Google File System. Web and scalability

Optimising SQL Server CPU performance

VERITAS Database Edition for Oracle on HP-UX 11i. Performance Report

Module 14: Scalability and High Availability

Technical Note. Dell PowerVault Solutions for Microsoft SQL Server 2005 Always On Technologies. Abstract

Recover EDB and Export Exchange Database to PST 2010

File System & Device Drive. Overview of Mass Storage Structure. Moving head Disk Mechanism. HDD Pictures 11/13/2014. CS341: Operating System

Bulletproof your Database Backup and Recovery Strategy

Enhancing SQL Server Performance

! Volatile storage: ! Nonvolatile storage:

"Charting the Course... MOC AC SQL Server 2014 Performance Tuning and Optimization. Course Summary

Tivoli Storage Manager Explained

Best Practices for Using MySQL in the Cloud

Encrypting MySQL data at Google. Jonas Oreland and Jeremy Cole

Failure Recovery Himanshu Gupta CSE 532-Recovery-1

Introduction. Part I: Finding Bottlenecks when Something s Wrong. Chapter 1: Performance Tuning 3

DMS Performance Tuning Guide for SQL Server

SQL Server Version. Supported for SC2012 RTM*** Not supported for SC2012 SP1*** SQL Server 2008 SP1, SP2, SP3

Review: The ACID properties

SQL Server 2008 Designing, Optimizing, and Maintaining a Database Session 1

6. Storage and File Structures

Administering Microsoft SQL Server Databases

Administering Microsoft SQL Server Databases

Troubleshooting SQL Server Enterprise Geodatabase Performance Issues. Matthew Ziebarth and Ben Lin

How To Fix A Fault Fault Fault Management In A Vsphere 5 Vsphe5 Vsphee5 V2.5.5 (Vmfs) Vspheron 5 (Vsphere5) (Vmf5) V

COSC 6374 Parallel Computation. Parallel I/O (I) I/O basics. Concept of a clusters

The Revival of Direct Attached Storage for Oracle Databases

Transcription:

Media Partners

SQL Server Transaction Log from A to Z Paweł Potasiński Product Manager Data Insights pawelpo@microsoft.com http://blogs.technet.com/b/sqlblog_pl/

Why About Transaction Log (Again)? http://zine.net.pl/blogs/sqlgeek/archive/2008/07/25/pl-m-j-log-jest-za-du-y.aspx

Agenda Introduction Log Architecture Log Nature Tools Checkpoints Log Flushes and Limits Waits SQL Server 2014

Introduction to Transaction Log Captures changes that occur in the database Changes occur here first (mostly) Implements Atomicity & Durability of ACID Written sequentially, so one is enough per database Memory-Optimized Tables have different logging semantics Useful for data recovery

Recovery Models Simple Recovery No log backups allowed Potential data loss Full Recovery Log backups are a MUST Runaway log file otherwise Bulk Logged Recovery Model Save log space with minimally logged operations Makes log smaller, but not log backups TF 610 used for clustered index inserts

Best Practices Put the log on a fast drive (SSD, RAID-10, RAID-1) Separate log from data (LUNs) Turn off AutoShrink AutoGrow just as the last resort Regularly take transaction log backups

Virtual Log Files (VLF) The unit of truncation of the transaction log file Generated at log file creation or log file growth SQL Server 2012 and earlier SQL Server 2014 Log File Growth VLFs Added <= 64MB 4 Is the growth size less than 1/8 the size of the current log size? > 64 MB AND <= 1 GB 8 > 1 GB 16 NO Use this algorithm YES Create 1 new VLF equal to the growth size

The Number of VLFs Matters Too many is bad, too few is also bad FIX: https://support.microsoft.com/en-us/kb/2455009 SQL Server 2012+: https://support.microsoft.com/en-us/kb/2882905

VLF Reuse A VLF can be reused if: No active transactions are in the VLF or previous VLFs No unreplicated transactions are contained in the VLF Occurs at Checkpoint in the Simple Recovery Model Otherwise, ONLY occurs at log backup Use sys.databases (log_reuse_wait_desc) to check why log cannot be reused

VLF Reuse (ctnd) Log_reuse_wait_desc in sys.databases NOTHING CHECKPOINT LOG_BACKUP ACTIVE_BACKUP_OR_RESTORE ACTIVE_TRANSACTION DATABASE_MIRRORING REPLICATION DATABASE_SNAPSHOT_CREATION LOG_SCAN OTHER_TRANSIENT

Log Blocks & Log Records Log Block The atomic unit of physical commit to a log file Contains a Header, Log Records, and a Slot Array Size from 512B to 60KB Log Record An atomic database change Identified by Log Sequence Number Not only associated with committed transactions

Log Sequence Number (LSN) Uniquely identifies a Log Record Monotonically increasing VLF Number: Log Block Offset: Slot Number Every time a VLF is reused, it is given a new file sequence no

Checkpoint Minimizes the REDO portion of recovery Writes modified (dirty) buffer pages to disk (data file) Writes ALL dirty pages to disk transaction state does not matter Can be very IO intensive Does not remove pages from the buffer pool Lazy Writer does this when there is pressure

Checkpoint Options Option 'recovery interval' on the instance level In SQL Server 2012+ also on the database level Indirect checkpoint

Demo LOG NATURE DIGGING IN THE LOG

Tools for Transaction Log DBCC SQLPERF(LOGSPACE) DBCC LOGINFO sys.fn_dblog() sys.fn_dump_dblog() DMVs & system views Extended Events Trace flag 3004 (info on file growth in SQL Server logs)

Log Flushes On hidden scheduler Waiting on LOGMGR_QUEUE Processes completed log writes Background tasks LOG WRITER

Transaction Log Manager Limits Number of outstanding log IOs SQL 2012/SQL 2008 - limit 3840K SQL 2005 - limit of 480K at any given time Number of outstanding IOs SQL 2012 112 outstanding IO s (64 bit) Prior versions - 32 outstanding IO (64 bit), 8 on 32 bit No new IO issued until outstanding IO completes Wait type LOGMGR_FLUSH http://blogs.msdn.com/b/sqlcat/archive/2013/09/10/diagnosing-transactionlog-performance-issues-and-limits-of-the-log-manager.aspx

Log Wait Types WRITELOG LOGBUFFER LOGMGR_RESERVE_APPEND ASYNC_IO_COMPLETION Waiting on IO to Log file Slow disk possible Check log disk counters sys.dm_io_pending_io_req uests Waiting on a free log buffer All log buffers in use This causes flushing not fast enough Couldn t grow the log Waiting on log truncation Check sys.databases log_reuse_wait_desc Can be for "zeroing" out a transaction log file during log creation or growth https://sqlserverperformance.wordpress.com/tag/dmv-queries/

Demo TRANSACTIONS, WAITS, MONITORING

SQL Server 2014: In-memory OLTP All logging for memory-optimized tables is logical No log records for physical structure modifications No index-specific / index-maintenance log records Log Records Contains a log record header followed by memory optimized-specific log content Are written only on a commit, no UNDO information is logged None for Non-durable tables (SCHEMA_ONLY) No Minimal logging, everything is fully logged Each physical log record is 24 KB Logical records can exceed that limit and are chained New function sys.fn_dblog_xtp()

SQL Server 2014: Delayed Durability Transaction commits logged asynchronously Set at database devel or ATOMIC block DISABLED normal behavior durability guaranteed ALLOWED allowed at the database level, Transaction has to specify durability options, default is a durable transaction COMMIT TRAN. WITH (DELAYED_DURABILITY=ON) FORCED changes default durability for the database to delayed CREATE PROCEDURE MyProc WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER AS BEGIN ATOMIC WITH (DELAYED_DURABILITY = ON, TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'us_english') END -- Insert T-SQL here ALTER DATABASE Hekaton SET DELAYED_DURABILITY = FORCED GO

Recap Log file performance is critical to SQL Server performance Always have your backup strategy ready There are tools helpful for log maintenance Be aware of the new features in SQL Server 2014

Questions? PAWELPO@MICROSOFT.COM

Media Partners