Question

When Sql Server issues a checkpoint, does it block every other operation until the checkpoint is completed?

If I understand correctly, when a checkpoint occurs, the server should write all dirty pages.

When it's complete, it will write checkpoint to the transaction log, so in case of any failure it will process only transactions from that point of time (or transactions which already started at time of checkpoint).

How does sql server prevent some non dirty page to become dirty while the checkpoint is in progress?

Does it block all writes until the checkpoint is completed?

Was it helpful?

Solution

Checkpoints do not block writes.

A checkpoint has a start and an end LSN. It guarantees that all pages on disk are at least at the start LSN of the checkpoint. It does not matter if any page is at a later LSN (because it has been written to after the checkpoint has started).

The checkpoint only guarantees a minimum LSN for all pages on disk. It does not guarantee an exact LSN.

This makes sense because you can delete all transaction log records which contain information from LSNs which are earlier than the checkpoint start LSN. That is the purpose of a checkpoint: Allow parts of the log to become inactive.

Checkpoints are not needed for data consistency and correctness. They just free log space and shorten recovery times.

OTHER TIPS

when a checkpoint occurs, the server should write all dirty pages

And that's what it does. However the guarantee given by checkpoint is it writes all the pages that were dirty at the instant the checkpoint started. Any page that got dirty while the checkpoint was making progress may or may not be written, but is sure not guaranteed to be written. What this guarantee offers is an optimization that physical recovery can start REDO from the last checkpoint since everything in the log prior to it is already been applied to the data pages (does not have to be redone). Is even on Wikipedia page for ARIES:

The naive way for checkpointing involves locking the whole database to avoid changes to the DPT and the TT during the creation of the checkpoint. Fuzzy logging circumvents that by writing two log records. One Fuzzy Log Starts Here record and, after preparing the checkpoint data, the actual checkpoint. Between the two records other logrecords can be created

usr's answer explains how this is achieved (by using a checkpoint start LSN and end LSN).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top