17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 14-1<br />

Data needed<br />

Data in cache? No<br />

Yes<br />

Read or modify<br />

data in cache<br />

Data changed?<br />

Yes<br />

Write changes<br />

to log<br />

Failure and Recovery<br />

Room in cache<br />

for new data?<br />

A recovery happens every time that <strong>SQL</strong> <strong>Server</strong> starts. <strong>SQL</strong> <strong>Server</strong> takes the database file, then applies (by<br />

writing them out to the physical database file) any committed changes that are in the log since the last<br />

checkpoint. Any changes in the log that do not have a corresponding commit are rolled back — that is,<br />

they are essentially forgotten.<br />

Let’s take a look at how this works depending on how transactions have occurred in your database.<br />

Imagine five transactions that span the log as pictured in Figure 14-2.<br />

Yes<br />

Read data<br />

into cache so<br />

placing least<br />

recently used<br />

data<br />

Let’s look at what would happen to these transactions one by one.<br />

Chapter 14: Transactions and Locks<br />

No<br />

Issue checkpoint<br />

Write any<br />

modified<br />

cache<br />

pages to disk<br />

431

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!